1 Install
apt-get install python
apt-get install prolog-eland download python-mode.el
http://sourceforge.net/projects/python-mode2 Compile python-mode.el
C-x C-f /path/to/python-mode.el RET
M-x byte-compile-file RET
3 Check if python-mode.el has compiled
M-x locate-library RET python-mode RET
if no, then add below to .emacs
(setq load-path (cons "/dir/of/python-mode/" load-path))
4 Link .py and python-mode, add below to .emacs
(setq auto-mode-alist
(cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
(cons '("python" . python-mode)
interpreter-mode-alist))
5 Link python-mode and python-mode.elc, add below to .emacs
(autoload 'python-mode "python-mode" "Python editing mode." t)
6 Add these linns if you like color-based syntax highlighting
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
7 For Chinese
(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'euc-cn)
(set-clipboard-coding-system 'euc-cn)
(set-terminal-coding-system 'euc-cn)
(set-buffer-file-coding-system 'euc-cn)
(set-selection-coding-system 'euc-cn)
(modify-coding-system-alist 'process "*" 'euc-cn)
(setq default-process-coding-system
'(euc-cn . euc-cn))
(setq-default pathname-coding-system 'euc-cn)
8 Example from Internet
(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.
'(transient-mark-mode (quote identity)))
(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.
)
;;设置个人信息
(setq user-full-name "Border")
(setq user-mail-address "
borderj@gmail.com")
;;禁用启动信息
(setq inhibit-startup-message t)
;;关闭烦人的出错时的提示声
(setq visible-bell t)
;; 设置光标为竖线
(setq-default cursor-type 'bar)
;; 设置光标为方块
;;(setq-default cursor-type 'box)
;;Tab设置4
(setq default-tab-width 4)
(setq tab-width 4)
;;光标靠近鼠标的时候,让鼠标自动让开,别挡住视线
(mouse-avoidance-mode 'animate)
;;下面的这个设置可以让光标指到某个括号的时候显示与它匹配的括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;; 加载显示行号模块
(require 'display-line-number)
;; 如果想所有打开的文件都显示行的话就打开下面的注释
(global-display-line-number-mode 1)
;;显示当前所在的行号和列号
(column-number-mode t)
;;防止页面滚动时跳动
(setq scroll-margin 3
scroll-conservatively 10000)
;; 所有的备份文件转移到~/backups目录下
;(setq backup-directory-alist (quote (("." . "~/backups"))))
;(setq version-control t)
;(setq kept-old-versions 2)
;(setq kept-new-versions 5)
;(setq delete-old-versions t)
;(setq backup-directory-alist '(("." . "~/backups")))
;(setq backup-by-copying t)
;; Emacs 中,改变文件时,默认都会产生备份文件(以 ~ 结尾的文件)。可以完全去掉
;; (并不可取),也可以制定备份的方式。这里采用的是,把所有的文件备份都放在一
;; 个固定的地方("~/var/tmp")。对于每个备份文件,保留最原始的两个版本和最新的
;; 五个版本。并且备份的时候,备份文件是复本,而不是原件
;;不产生备份文件
(setq make-backup-files nil)
;;设置kill-ring-max(我不知道怎么翻译这个词:)为200,以防不测:)
(setq kill-ring-max 200)
;; 当有两个文件名相同的缓冲时,使用前缀的目录名做 buffer 名字,不用原来的
;; foobar 形式。
(setq uniquify-buffer-name-style 'forward)
;;显示日期
(setq display-time-day-and-date t)
(display-time)
;;显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-use-mail-icon t)
(setq display-time-interval 10)
;; 设置时间戳,标识出最后一次保存文件的时间。
(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S K.T")
;;设置默认工作目录
(setq default-directory "f:/border")
;;'y' for 'yes', 'n' for 'no'
(fset 'yes-or-no-p 'y-or-n-p)
;; 代码折叠
(load-library "hideshow")
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'perl-mode-hook 'hs-minor-mode)
(add-hook 'php-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 启动最大化窗口设置 - START ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun w32-restore-frame ()
"Restore a minimized frame"
(interactive)
(w32-send-sys-command 61728))
(defun w32-maximize-frame ()
"Maximize the current frame"
(interactive)
(w32-send-sys-command 61488))
;;; Maximum Windows Frame
(w32-maximize-frame)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 启动最大化窗口设置 - END
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Reference
Set up python environment:
http://blog.czug.org/panjy/python-emacsBasic commands:
http://jasonal.spaces.live.com/blog/cns!E9B3AD00B7B35ECC!1655.entry