.emacs(company)配置

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)




(setenv "HOME" "D:/emacs")
(setenv "PATH" "D:/emacs")
(setenv "PATH" "D:/emacs/bin")
(setenv "PATH" "D:/Python27")
(setenv "PATH" "D:/Python27/Scripts")








;;set the default file path
(setq default-directory "~/")




(add-to-list 'load-path "~/emacs/.emacs.d/lisps")




;;Using IE proxy
(eval-after-load "url"
  '(progn
     (require 'w32-registry)
     (defadvice url-retrieve (before
                              w32-set-proxy-dynamically
                              activate)
       "Before retrieving a URL, query the IE Proxy settings, and use them."
       (let ((proxy (w32reg-get-ie-proxy-config)))
         (setq url-using-proxy proxy
               url-proxy-services proxy)))))
;;(setq url-using-proxy t)
;;(setq url-proxy-services  '(("http" . "proxy.huawei.com:8080")))








;; cancel welcome page
;;(setq inhibit-splash-screen t)
;;open up with full screen
;;(setq initial-frame-alist (quote ((fullscreen . maximized))))












(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(column-number-mode t)
 '(inhibit-startup-screen t)
 '(initial-frame-alist (quote ((fullscreen . maximized))))
 '(menu-bar-mode nil)
 '(package-archives
   (quote
    (("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa_stable" . "http://stable.melpa.org/packages/")
     ("melpa" . "http://melpa.org/packages/"))))
 '(package-selected-packages (quote (py-autopep8 flycheck elpy)))
 '(scroll-bar-mode nil)
 '(tool-bar-mode nil))








(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "宋体" :foundry "outline" :slant normal :weight normal :height 98 :width normal)))))
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)






(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
(global-set-key "\C-x\ t" 'beginning-of-buffer)
(global-set-key "\C-x\ e" 'end-of-buffer)
(global-set-key "\M-r" 'isearch-backward-regexp)
(global-set-key "\M-s" 'isearch-forward-regexp)
(global-set-key "\C-j" 'goto-line)
(global-set-key (kbd "M-SPC") 'set-mark-command);set mark
(defalias 'qrr'query-replace-regexp)
(global-set-key [f5] 'call-last-kbd-macro)
(require 'recentf)
(recentf-mode 1)




















;;BUFFER AND WINDOWS BEGIN HERE
;; --------------------------------------
;;从一窗口模式可以变为四窗口模式
(defun split-window-4() 
"Splite window into 4 sub-window"
 (interactive) 
 (if (= 1 (length (window-list))) 
    (progn (split-window-vertically) 
    (split-window-horizontally) 
    (other-window 2) 
    (split-window-horizontally) 
))) 
(global-set-key  (kbd "C-x w 4") (quote split-window-4))








;;如果是在三窗口模式下运行该命令,可以将window+buffer作为整体进行旋转,有利于大窗口的内容在横竖之间倒换
 (defun change-split-type-3 () 
  "Change 3 window style from horizontal to vertical and vice-versa"
  (interactive) 




  (select-window (get-largest-window)) 
  (if (= 3 (length (window-list))) 
      (let ((winList (window-list))) 
            (let ((1stBuf (window-buffer (car winList))) 
                  (2ndBuf (window-buffer (car (cdr winList)))) 
                  (3rdBuf (window-buffer (car (cdr (cdr winList))))) 




                  (split-3 
                   (lambda(1stBuf 2ndBuf 3rdBuf split-1 split-2) 
                     "change 3 window from horizontal to vertical and vice-versa"
                     (message "%s %s %s" 1stBuf 2ndBuf 3rdBuf) 




                     (delete-other-windows) 
                     (funcall split-1) 
                     (set-window-buffer nil 2ndBuf) 
                     (funcall split-2) 
                     (set-window-buffer (next-window) 3rdBuf) 
                     (other-window 2) 
                     (set-window-buffer nil 1stBuf)))         




                  (split-type-1 nil) 
                  (split-type-2 nil) 
                  ) 
              (if (= (window-width) (frame-width)) 
                  (setq split-type-1 'split-window-horizontally 
                        split-type-2 'split-window-vertically) 
                (setq split-type-1 'split-window-vertically  
       split-type-2 'split-window-horizontally)) 
              (funcall split-3 1stBuf 2ndBuf 3rdBuf split-type-1 split-type-2) 




 )))) 
 (global-set-key (kbd "C-x w c") (quote change-split-type-3)) 












;; 如果是在三窗口模式下运行该命令,可以将三窗口模式的buffer进行旋转,windows固定不动,有利于不同的buffer轮流滚入大window
  (defun roll-v-3 (&optional arg) 
    "Rolling 3 window buffers (anti-)clockwise"
    (interactive "P") 
    (select-window (get-largest-window)) 
    (if (= 3 (length (window-list))) 
        (let ((winList (window-list))) 
          (let ((1stWin (car winList)) 
                (2ndWin (car (cdr winList))) 
                (3rdWin (car (last winList)))) 
            (let ((1stBuf (window-buffer 1stWin)) 
                  (2ndBuf (window-buffer 2ndWin)) 
                  (3rdBuf (window-buffer 3rdWin))) 
              (if arg (progn                                
 ; anti-clockwise
                        (set-window-buffer 1stWin 3rdBuf) 
                        (set-window-buffer 2ndWin 1stBuf) 
                        (set-window-buffer 3rdWin 2ndBuf)) 
                (progn                                      ; clockwise
                  (set-window-buffer 1stWin 2ndBuf) 
                  (set-window-buffer 2ndWin 3rdBuf) 
                  (set-window-buffer 3rdWin 1stBuf)) 
                ))))))
 (global-set-key (kbd "C-x w r")  (quote roll-v-3)) 




;; --------------------------------------
;;BUFFER AND WINDOWS END HERE
















;;you can use "/c-c ←" to back the windows mode 
 (when (fboundp 'winner-mode) 
  (winner-mode) 
  (windmove-default-keybindings))








;; python configuration begin here
;; --------------------------------------




;;emacs lisp python environment(elpy).
;;note:you need install flake8 and jedi for your python befor you install elpy package for your emacs
(elpy-enable)








;;ipython
(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "-i --simple-prompt")








;;flycheck
;;package install flycheck to instead of flymake
;;better syntax checking
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))




;;auto pep8 compliance
;;note: you need install autopep8 for your python befor you install py-autopep8 package for your emacs
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)




;; --------------------------------------
;; python configuration end here










猜你喜欢

转载自blog.csdn.net/superwen_go/article/details/80888874