SlideShare a Scribd company logo
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
;; kill the buffer imediate 
(global-set-key (kbd "C-x k") ’kill-this-buffer) 
;; hide tool bar 
(tool-bar-mode -1) 
;; hide menu bar 
(menu-bar-mode -1) 
;;hide scroll bar 
(scroll-bar-mode -1) 
;; 
(setq use-dialog-box nil) 
;; 
(setq mouse-yank-at-point t) 
;; Emacs 
(setq auto-image-file-mode t) 
;;shelltelnetw3m, 
(add-hook ’comint-output-filter-functions 
’comint-watch-for-password-prompt) 
;;emacs 
(setq x-select-enable-clipboard t) 
;; 
(setq mouse-yank-at-point t) 
;;, 
(setq user-full-name "lkong") 
(setq user-mail-address "lkong@redhat.com") 
;; 
(setq require-final-newline t) 
;;F9Emacs 
(global-set-key [f9] ’calendar) 
2
;;F10 
(global-set-key [f10] ’list-bookmarks) 
;; dired 
(setq dired-recursive-copies ’top) 
(setq dired-recursive-deletes ’top) 
;;[C-f9]dired 
;;(global-set-key [C-f9] ’dired) 
;;control+spacemark 
(global-set-key (kbd "C-SPC") ’nil) 
;; C-@ setmark , C-@ 
;;(global-set-key (kbd "M-<SPC>") ’set-mark-command) 
(global-set-key [?S- ] ’set-mark-command) 
;; 
(setq backup-directory-alist ’(("." . "~/emacs_backup"))) 
;; 
;;(setq make-backup-files nil) 
;; 
(setq-default cursor-type ’bar) 
;; 
;; (setq-default cursor-type ’box) 
;; “” 
(setq inhibit-startup-message t) 
;; 
(transient-mark-mode t) 
;; 
(setq mouse-wheel-mode t) 
;; 
(setq column-number-mode t) 
3
;; 
(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
;; 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
;; ============================== 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
(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
* 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
(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
(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
(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
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
;; GTD -- start 
(setq org-todo-keywords 
(quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") 
(sequence "SOMEDAY(s@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)")))) 
(setq org-todo-keyword-faces 
(quote (("TODO" :foreground "red" :weight bold) 
("NEXT" :foreground "blue" :weight bold) 
("DONE" :foreground "forest green" :weight bold) 
("SOMEDAY" :foreground "orange" :weight bold) 
("HOLD" :foreground "magenta" :weight bold) 
("CANCELLED" :foreground "forest green" :weight bold)))) 
(setq org-todo-state-tags-triggers 
(quote (("CANCELLED" ("CANCELLED" . t)) 
("SOMEDAY" ("SOMEDAY" . t)) 
("HOLD" ("SOMEDAY" . t) ("HOLD" . t)) 
(done ("SOMEDAY") ("HOLD")) 
("TODO" ("SOMEDAY") ("CANCELLED") ("HOLD")) 
("NEXT" ("SOMEDAY") ("CANCELLED") ("HOLD")) 
("DONE" ("SOMEDAY") ("CANCELLED") ("HOLD"))))) 
(setq org-directory "~/Org-mode") 
(global-set-key (kbd "C-c c") ’org-capture) 
(setq org-capture-templates 
(quote (("t" "todo" entry (file "~/Org-mode/todo.org") 
"* TODO %?n%an" :clock-in t :clock-resume t) 
("i" "idea" entry (file+datetree "~/Org-mode/idea.org") 
"* %? n") 
("s" "someday" entry (file "~/Org-mode/someday.org") 
"* SOMEDAY %? :SOMEDAY:n%an" :clock-in t :clock-resume t) 
("n" "note" entry (file "~/Org-mode/diary.org") 
"* %? :NOTE:n%an" :clock-in t :clock-resume t) 
("w" "org-protocol" entry (file "~/Org-mode/refile.org") 
"* TODO Review %cn%Un" :immediate-finish t)))) 
;;(setq org-tag-alist ’(("office" . ?o) ("home" . ?h) ("notes" . ?n) ("slide" . ?s))) 
;; GTD -- end 
;; Only show the last star 
13
;;(setq org-hide-leading-stars t) 
;;org mode 
(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))) 
;; Remove empty LOGBOOK drawers on clock out 
(defun bh/remove-empty-drawer-on-clock-out () 
(interactive) 
(save-excursion 
(beginning-of-line 0) 
(org-remove-empty-drawer-at "LOGBOOK" (point)))) 
(add-hook ’org-clock-out-hook ’bh/remove-empty-drawer-on-clock-out ’append) 
(defun gtd () 
(interactive) 
(find-file "~/Org-mode/todo.org") 
) 
(global-set-key (kbd "<f12>") ’list-bookmarks) 
(defun insert-current-time () 
"Insert the current time" 
(interactive "*") 
;;(insert (format-time-string "%Y/%m/%d %H:%M:%S" (current-time)))) 
(insert (format-time-string "%Y-%m-%d" (current-time)))) 
;;(insert (format-time-string "%H:%M:%S" (current-time)))) 
(global-set-key "C-xt" ’insert-current-time) 
;; ============================ Org-mode Configure END ================================= 
7 Reference slide 
• Configure python as a IDE 
14

More Related Content

TXT
Interfaz Grafica En Java
PPT
11 Things About 11gr2
PDF
PostgreSQL and PL/Java
PDF
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
PDF
Writing MySQL User-defined Functions in JavaScript
PDF
Debugging: Rules & Tools
PDF
PostgreSQL Procedural Languages: Tips, Tricks and Gotchas
PDF
Python sqlite3 - flask
Interfaz Grafica En Java
11 Things About 11gr2
PostgreSQL and PL/Java
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
Writing MySQL User-defined Functions in JavaScript
Debugging: Rules & Tools
PostgreSQL Procedural Languages: Tips, Tricks and Gotchas
Python sqlite3 - flask

What's hot (19)

ODP
3. writing MySql plugins for the information schema
PDF
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
PDF
Pdxpugday2010 pg90
PDF
ZFINDALLZPROGAM
PDF
Stacki: Remove Commands
PPT
Endevor api an introduction to the endevor application programming interface
TXT
C99.php
PDF
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
TXT
Pontos para criar_instancia_data guard_11g
DOCX
Linked lists
PDF
Strategic autovacuum
PPTX
Basic ASM by @binaryheadache
PDF
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
PPTX
Call stack, event loop and async programming
PDF
Perl Sucks - and what to do about it
PPT
OOUG: Oracle transaction locking
PDF
Commencer avec le TDD
PDF
Noinject
TXT
Mona cheatsheet
3. writing MySql plugins for the information schema
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
Pdxpugday2010 pg90
ZFINDALLZPROGAM
Stacki: Remove Commands
Endevor api an introduction to the endevor application programming interface
C99.php
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
Pontos para criar_instancia_data guard_11g
Linked lists
Strategic autovacuum
Basic ASM by @binaryheadache
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
Call stack, event loop and async programming
Perl Sucks - and what to do about it
OOUG: Oracle transaction locking
Commencer avec le TDD
Noinject
Mona cheatsheet
Ad

Viewers also liked (7)

PDF
Python学习笔记
PDF
Beamer guide By KiJoo Kim (a.k.a. Daisyweb)
PDF
Shell实现的windows回收站功能的脚本
PDF
It经典图书(附免费下载地址)
PDF
PDF
Emacs presentation
ODP
SR-IOV Introduce
Python学习笔记
Beamer guide By KiJoo Kim (a.k.a. Daisyweb)
Shell实现的windows回收站功能的脚本
It经典图书(附免费下载地址)
Emacs presentation
SR-IOV Introduce
Ad

Similar to Congfigure python as_ide (20)

PDF
GNU Emacs Reference Card.pdf
PPT
Emacs, a performant IDE for Perl
PDF
我在豆瓣使用Emacs
PPT
Emacs tutorial
PDF
Emacs talk
PDF
PDF
PDF
unix-editors.pdf
PDF
Emacs - COSCUP 2012
PDF
20090622 Vimm4
PDF
Kick my mouse away
PDF
Emacs intro
PDF
VIM for Programmers
ODP
Perfect? clojure environment
PPT
Unix Lec2
PDF
Emacs Cheatsheet
PDF
Vi reference
PDF
Vi reference
PDF
はじめてのanything-c-source-*
PDF
Vim Hacks
GNU Emacs Reference Card.pdf
Emacs, a performant IDE for Perl
我在豆瓣使用Emacs
Emacs tutorial
Emacs talk
unix-editors.pdf
Emacs - COSCUP 2012
20090622 Vimm4
Kick my mouse away
Emacs intro
VIM for Programmers
Perfect? clojure environment
Unix Lec2
Emacs Cheatsheet
Vi reference
Vi reference
はじめてのanything-c-source-*
Vim Hacks

Congfigure python as_ide

  • 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
  • 2. ;; kill the buffer imediate (global-set-key (kbd "C-x k") ’kill-this-buffer) ;; hide tool bar (tool-bar-mode -1) ;; hide menu bar (menu-bar-mode -1) ;;hide scroll bar (scroll-bar-mode -1) ;; (setq use-dialog-box nil) ;; (setq mouse-yank-at-point t) ;; Emacs (setq auto-image-file-mode t) ;;shelltelnetw3m, (add-hook ’comint-output-filter-functions ’comint-watch-for-password-prompt) ;;emacs (setq x-select-enable-clipboard t) ;; (setq mouse-yank-at-point t) ;;, (setq user-full-name "lkong") (setq user-mail-address "lkong@redhat.com") ;; (setq require-final-newline t) ;;F9Emacs (global-set-key [f9] ’calendar) 2
  • 3. ;;F10 (global-set-key [f10] ’list-bookmarks) ;; dired (setq dired-recursive-copies ’top) (setq dired-recursive-deletes ’top) ;;[C-f9]dired ;;(global-set-key [C-f9] ’dired) ;;control+spacemark (global-set-key (kbd "C-SPC") ’nil) ;; C-@ setmark , C-@ ;;(global-set-key (kbd "M-<SPC>") ’set-mark-command) (global-set-key [?S- ] ’set-mark-command) ;; (setq backup-directory-alist ’(("." . "~/emacs_backup"))) ;; ;;(setq make-backup-files nil) ;; (setq-default cursor-type ’bar) ;; ;; (setq-default cursor-type ’box) ;; “” (setq inhibit-startup-message t) ;; (transient-mark-mode t) ;; (setq mouse-wheel-mode t) ;; (setq column-number-mode t) 3
  • 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
  • 13. ;; GTD -- start (setq org-todo-keywords (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") (sequence "SOMEDAY(s@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)")))) (setq org-todo-keyword-faces (quote (("TODO" :foreground "red" :weight bold) ("NEXT" :foreground "blue" :weight bold) ("DONE" :foreground "forest green" :weight bold) ("SOMEDAY" :foreground "orange" :weight bold) ("HOLD" :foreground "magenta" :weight bold) ("CANCELLED" :foreground "forest green" :weight bold)))) (setq org-todo-state-tags-triggers (quote (("CANCELLED" ("CANCELLED" . t)) ("SOMEDAY" ("SOMEDAY" . t)) ("HOLD" ("SOMEDAY" . t) ("HOLD" . t)) (done ("SOMEDAY") ("HOLD")) ("TODO" ("SOMEDAY") ("CANCELLED") ("HOLD")) ("NEXT" ("SOMEDAY") ("CANCELLED") ("HOLD")) ("DONE" ("SOMEDAY") ("CANCELLED") ("HOLD"))))) (setq org-directory "~/Org-mode") (global-set-key (kbd "C-c c") ’org-capture) (setq org-capture-templates (quote (("t" "todo" entry (file "~/Org-mode/todo.org") "* TODO %?n%an" :clock-in t :clock-resume t) ("i" "idea" entry (file+datetree "~/Org-mode/idea.org") "* %? n") ("s" "someday" entry (file "~/Org-mode/someday.org") "* SOMEDAY %? :SOMEDAY:n%an" :clock-in t :clock-resume t) ("n" "note" entry (file "~/Org-mode/diary.org") "* %? :NOTE:n%an" :clock-in t :clock-resume t) ("w" "org-protocol" entry (file "~/Org-mode/refile.org") "* TODO Review %cn%Un" :immediate-finish t)))) ;;(setq org-tag-alist ’(("office" . ?o) ("home" . ?h) ("notes" . ?n) ("slide" . ?s))) ;; GTD -- end ;; Only show the last star 13
  • 14. ;;(setq org-hide-leading-stars t) ;;org mode (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))) ;; Remove empty LOGBOOK drawers on clock out (defun bh/remove-empty-drawer-on-clock-out () (interactive) (save-excursion (beginning-of-line 0) (org-remove-empty-drawer-at "LOGBOOK" (point)))) (add-hook ’org-clock-out-hook ’bh/remove-empty-drawer-on-clock-out ’append) (defun gtd () (interactive) (find-file "~/Org-mode/todo.org") ) (global-set-key (kbd "<f12>") ’list-bookmarks) (defun insert-current-time () "Insert the current time" (interactive "*") ;;(insert (format-time-string "%Y/%m/%d %H:%M:%S" (current-time)))) (insert (format-time-string "%Y-%m-%d" (current-time)))) ;;(insert (format-time-string "%H:%M:%S" (current-time)))) (global-set-key "C-xt" ’insert-current-time) ;; ============================ Org-mode Configure END ================================= 7 Reference slide • Configure python as a IDE 14