1. Configure Emacs As a Python IDE
Lingfei Kong
2014-11-10
Contents
1 My Emacs Configure 1
2 Emacs basic setting 1
3 Packages or plugins need to install (Configure emacs as a
python IDE) 6
4 Install ECB 9
5 Set font for emacs (you can ignore this if you already have
a satisfactory font) 11
6 Configure org-mode 12
7 Reference 14
1 My Emacs Configure slide
2 Emacs basic setting slide
;; .emacs
;; ============================== Basic Configure START =====================================
;; set TAB=4 for C
;;(setq c-basic-offset 4)
;;
;; show colume number
;;(setq column-number-mode t)
1
4. ;;
(global-linum-mode 1)
;; kill ring
(setq kill-ring-max 200)
;; fill-column 60.
(setq default-fill-column 60)
;;
;;(show-paren-mode t)
;;(setq show-paren-style ’parentheses)
;; buffer emacs@wangyin.com
(setq frame-title-format "emacs@%b")
;;
(put ’set-goal-column ’disabled nil)
(put ’narrow-to-region ’disabled nil)
(put ’upcase-region ’disabled nil)
(put ’downcase-region ’disabled nil)
(put ’LaTeX-hide-environment ’disabled nil)
;; dired
(setq dired-recursive-copies ’top)
(setq dired-recursive-deletes ’top)
;; auto enter new line
(add-hook ’org-mode-hook (lambda () (setq truncate-lines nil)))
;; set key f11 to switch to full
(global-set-key [f11] ’my-fullscreen) ;; full screen
(fset ’yes-or-no-p’y-or-n-p)
;; statment highlight
(global-font-lock-mode t)
;; use a large kill ring
(setq kill-ring-max 1024)
4
5. ;; Show the corse in which function
(which-function-mode t)
;; set default tab width
(setq default-tab-width 4)
;; do not use space to instead TAB
(setq-default indent-tabs-mode t)
;; enable global line number
;;(global-linum-mode 1)
;;M-ggoto-line
(global-set-key (kbd "M-g") ’goto-line)
;; No backup
;;(setq backup-inhibited t)
(defun my-fullscreen ()
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
’(2 "_NET_WM_STATE_FULLSCREEN" 0))
)
;; let emacs to max frame
(add-to-list ’load-path "~/.emacs.d/elpa/maxframe-20120725.639/")
(require ’maxframe)
(add-hook ’window-setup-hook ’maximize-frame t)
;;#yum install wqy-microhei-fonts.noarch first
;;(set-default-font "WenQuanYi Micro Hei Mono-19.5")
(set-default-font "WenQuanYi Zen Hei Mono-25")
;;(set-fontset-font (frame-parameter nil ’font) ’han "WenQuanYi Zen Hei Mono-24")
;;(set-fontset-font (frame-parameter nil ’font) ’gb18030 "WenQuanYi Zen Hei Mono-24")
;;(set-fontset-font (frame-parameter nil ’font) ’bopomofo "WenQuanYi Zen Hei Mono-24")
;;(set-fontset-font (frame-parameter nil ’font) ’cjk-misc "WenQuanYi Zen Hei Mono-24")
;;(set-fontset-font (frame-parameter nil ’font) ’nil "WenQuanYi Zen Hei Mono-24")
;;(set-fontset-font (frame-parameter nil ’font) ’symbol "WenQuanYi Zen Hei Mono-24")
;;(set-fontset-font (frame-parameter nil ’font) ’kana "WenQuanYi Micro Hei Mono-24")
5
6. ;; ============================== Basic Configure END ======================================
3 Packages or plugins need to install (Configure
emacs as a python IDE) slide
• Use yum to install packages in linux
yum install packagename
• Use list-packages or package-list-packages to install plugins in emacs
You need first configure your package archives like:
(setq package-archives ’(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
• Packages need to install
– YASnippet
* Install yasnippet via list-packages
Here is a link about list-packages: packages installation in
emasc
* Add configure for yasippet in .emacs
(add-to-list ’load-path "~/.emacs.d/elpa/yasnippet-0.8.0/")
(require ’yasnippet)
(yas-global-mode 1)
– auto-completion
* Install auto-completion via list-packages
* Add configure for auto-completion in .emacs
6
7. (add-to-list ’load-path "~/.emacs.d/elpa/popup-20140815.629/")
(require ’popup)
(add-to-list ’load-path "~/.emacs.d/elpa/auto-complete-20140824.1658/")
(require ’auto-complete-config)
(add-to-list ’ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-20140824.1658/(ac-config-default)
– python-mode
* Install python-mode via list-packages
* Add configure for python-mode in .emacs
(add-to-list ’load-path "~/.emacs.d/elpa/python-mode-6.1.3")
(require ’python-mode)
– ipython
* Install ipython via yum install
* Install ipython plugin via list-packages
* Add configure for ipython in .emacs
(add-to-list ’load-path "~/.emacs.d/elpa/ipython-2927/")
(require ’ipython)
– python document
* Download pylookup from pylookup (this link is a git repo)
You may download it to ~/.emacs.d/
* Download the newest python html document from python
document
download it to ~/.emacs.d/pylookup/
* ./pylookup.py -u python-2.7.1-docs-html to generate py-lookup.
db
7
8. * cp pylookup.py, pylookup.db, pylookup.el to ~/.emacs.d/plugins/pylookup
* Add configure for python document in .emacs
(setq pylookup-dir "~/.emacs.d/plugins/pylookup")
(add-to-list ’load-path pylookup-dir)
(require ’pylookup)
;; load pylookup when compile time
(setq pylookup-program (concat pylookup-dir "/pylookup.py"))
(setq pylookup-db-file (concat pylookup-dir "/pylookup.db"))
;; set search option if you want
(setq pylookup-search-options ’("--insensitive" "0" "--desc" "0"))
;; to speedup, just load it on demand
(autoload ’pylookup-lookup "pylookup"
"Lookup SEARCH-TERM in the Python HTML indexes." t)
(autoload ’pylookup-update "pylookup"
"Run pylookup-update and create the database at ‘pylookup-db-file’." (global-set-key "C-ch" ’pylookup-lookup)
(setq browse-url-browser-function ’w3m-browse-url)
* Install w3m via yum install
* Install w3m via list-packages
– anything
– pylint
* Install pylint via ‘yum install pylint‘
* Install pylint via list-packages
* Add configure for pylint in .emacs
8
9. (add-to-list ’load-path "~/.emacs.d/elpa/pylint-20140729.1117/")
(require ’pylint)
– pep8
* Install pep8 via ‘easy_install pep8‘
* Install pep8 via list-packages
* Add configure for pep8 in .emacs
(add-to-list ’load-path "~/.emacs.d/elpa/pep8-1.2/")
(require ’pep8)
(require ’tramp)
(add-hook ’before-save-hook ’delete-trailing-whitespace)
– xcscope
* Install cscope via ‘yum install cscope‘
* Install xcscope via list-packages
* Add configure for xcscope in .emacs
(add-to-list ’load-path "~/.emacs.d/elpa/xcscope-20140510.1437")
(require ’xcscope)
4 Install ECB slide
• Install ecb via list-packages
• Add configure for ecb in .emacs
(add-to-list ’load-path "~/.emacs.d/elpa/ecb-20140215.114/")
(setq ecb-tip-of-the-day nil)
(require ’ecb)
(require ’ecb-autoloads)
(setq ecb-auto-activate t)
9
10. (global-set-key [M-left] ’windmove-left)
(global-set-key [M-right] ’windmove-right)
(global-set-key [M-up] ’windmove-up)
(global-set-key [M-down] ’windmove-down)
(define-key global-map [(control f1)] ’ecb-hide-ecb-windows)
(define-key global-map [(control f2)] ’ecb-show-ecb-windows)
;;(define-key global-map [(control f3)] ’ecb-change-layout "left2")
;;(define-key global-map [(control f3)] ’ecb-change-layout)
;;(define-key global-map "C-c3" ’ecb-change-layout)
(define-key global-map "C-c1" ’ecb-maximize-window-directories)
(define-key global-map "C-c2" ’ecb-maximize-window-sources)
(define-key global-map "C-c3" ’ecb-maximize-window-methods)
(define-key global-map "C-c4" ’ecb-maximize-window-history)
(define-key global-map "C-c‘" ’ecb-restore-default-window-sizes)
(global-set-key [f12] ’ecb-activate) ;; ecb activate
;;(define-key global-map "C-c1" ’ecb-maximize-window-methods)
;;(define-key global-map "C-c2" ’ecb-maximize-window-history)
;;(define-key global-map "C-c‘" ’ecb-restore-window-sizes)
;; Disable buckets so that history buffer can display more entries
(setq ecb-history-make-buckets ’never)
(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.
’(ecb-create-layout-frame-height 10)
’(ecb-create-layout-frame-width 50)
’(ecb-layout-name "lkong")
’(ecb-layout-window-sizes nil)
’(ecb-options-version "2.40")
’(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
’(ecb-toggle-layout-sequence (quote ("lkong2" "lkong")))
’(ecb-windows-width 0.225))
;;ecbTip
10
11. (set-foreground-color "grey")
(set-background-color "black")
;;(setq ecb-layout-name "left10")
(setq ecb-history-make-buckets ’never)
(setq ecb-fix-window-size t)
(ecb-activate)
;; Ecb:
;; C-c . g d
;; C-c . g s
;; C-c . g m
;; C-c . g h
;; C-c . g l
;; C-c . g 1 1
;; C-c . g n n
;; C-c . l c
;; C-c . l r
;; C-c . l t switch layout
;; C-c . l w ecb
;; C-c . /
;; C-c . e: jump to the eshell buffer
;; C-c . n: histroy back
;; C-c . p: histroy forwad
;; C-c .h: Show ECB help pager
;; left2: directory + source
;; left6: source + method + history
;; left8: directory + source + method + history
– You may create your own layout via ’ecb-create-new-layout’, just
follow the prompt
5 Set font for emacs (you can ignore this if you
already have a satisfactory font) slide
• Install wqy font
yum -y install wqy-zenhei-fonts.noarch
11
12. yum -y install wqy-microhei-fonts.noarch
yum -y install wqy-bitmap-fonts.noarch
• fc-cache
• fc-list |grep wqy
• Add configre for wqy font in .emacs
(set-default-font "WenQuanYi Zen Hei Mono-24")
6 Configure org-mode slide
In emacs24 org-mode is installed by default, if not you should install the
following packages:
• Install org via list-packages
• Install emacs-common via yum install
;; ============================ Org-mode Configure START =================================
(require ’org-install)
(require ’org-publish)
(add-to-list ’auto-mode-alist ’(".org’" . org-mode))
(add-hook ’org-mode-hook ’turn-on-font-lock)
(add-hook ’org-mode-hook
(lambda () (setq truncate-lines nil)))
(global-set-key "C-cl" ’org-store-link)
(global-set-key "C-ca" ’org-agenda)
(global-set-key "C-cb" ’org-iswitchb)
;;(global-set-key "C-cc" ’org-capture)
(global-set-key "C-cc" ’org-remember)
(add-to-list ’auto-mode-alist ’(".org’" . org-mode))
12