SlideShare a Scribd company logo
1 of 34
Download to read offline
㐱⥈幦䜃↟䝈'OCEU 
! 
嚃ℿ㠮
Outline 
! 
. 初学emacs建议 
. vimer - emacser 
. 让emacs不再神秘 
. ⾖豆瓣⽤用到的emacs设置 
. emacs插件 
. 我的emacs.d 
. emacs开发⼊入⻔门
3 
初学emacs建议 
1.Emacs tutorial(C-h t) 
2. ⼊入⻔门 http://www.slideshare.net/yinhm/emacs-7324447 
3. 学习emacs需要忘记⿏鼠标,⽆无视菜单 
4. 快捷键控制⼀一切 
5. prelude 
6. 使⽤用=24.3版本(brew install emacs)
4 
没有⽤用Undo-tree会很惨
5 
学会这些快捷键就可以⽤用emacs 
Keystroke Command Name 
! 
C-x C-f 打开⽂文件 
C-x C-s 保存 
C-x C-c 保存并退出 
C-v 向上翻⻚页 
M-v 向下翻⻚页 
C-a 到⾏行⾸首 
C-e 到⾏行尾 
M-x 执⾏行命令 
C-g 取消输⼊入 
C-h b 查看快捷键 
M-g g 跳到某⾏行
6 
vimer - emacser 
alias emacs=/usr/local/opt/emacs/bin/emacs 
alias e='/usr/local/opt/emacs/bin/emacsclient -t' 
alias vi='e' 
alias vim=‘e' 
alias chop_hand_with_vim='/usr/bin/vim'
7 
让emacs不再神秘
8 
mode-line 
$emacs -q ../dongxi/dongxi/models/story/__init__.py 
-UUU:**--F1 __init__.py Top L30 Git-master (Python)——— 
1. %e -- print error message about full memory. 2. mode-line-front-space 
3. mode-line-mule-info: 语⾔言环境, buffer编码 U=utf-16 
4. ** 被修改过了 — 未被修改过 
%* 只读,但是被修改过 %% 只读,未被修改过 
6. 默认的frame(框架)名字是F1 
7. buffer名字或者⽂文件名字 
8. 在buffer的位置. Top/Bot/nn%/All 9. 当前⾏行号 
10. minor-mode 可以多个次要模式(vc-mode) 
11. major-mode 只能⼀一个主模式 
http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_360.html
9 
包管理源 
gnu - http://elpa.gnu.org/packages/ 
marmalade - http://marmalade-repo.org/packages/ 
melpa - http://melpa.milkbox.net/packages/
10 
Package.el 
—- 内建于emacs24包管理 
(require 'package) 
(package-initialize) 
(mapc 
(lambda (package) 
(unless (package-installed-p package) 
(package-install package))) 
‘(smex s f dash flycheck))
11 
el-get 
(setq my:el-get-packages 
‘(smex 
s 
f 
dash 
flycheck 
)) 
! 
(el-get 'sync my:el-get-packages)
12 
! 
Cask 
! 
$cat Cask 
(source gnu) 
(source melpa) 
(source marmalade) 
! 
(depends-on smex) 
(depends-on s) 
(depends-on f) 
(depends-on “dash) 
(depends-on flycheck) 
$cask
13 
bookmark 
— 保存缓冲区中位置 
Keystroke Command Name 
! 
C-x r m Bo 设置⼀一个名为 Bo 的书签 
C-x r l 列出所有已保存的书签 
C-x r b Bo 跳转到书签Bo 
M-x bookmark-delete 删除书签 
M-x bookmark-save 将所有的书签保存到/.emac.bmk 中 
! 
(setq bc-bookmark-file “~/emacs.d/bookmark”) 设置书签的保存位置 
(setq bc-bookmark-limit 300) 设置书签的最⼤大数量 
saveplace.el : automatically save place in files.
14 
eshell 
— 可以使⽤用elisp的shell 
1.很多内置命令其实替代了*nix命令 
$ which ls 
eshell/ls is a compiled Lisp function in `em-ls.el' 
2. 内置变量 
$$, $? … 
$ echo $+ 
/Users/dongweiming/shire-in-vagrant 
3. Tricks 
ls  #buffer ttt
15 
emacs的宏 
— ⼀一组被记录下来的按键记录 
1.开始录制宏: C-x ( 
2.你要执⾏行的操作 
3.结束录制宏: C-x ) 
4.⽤用C-x e来使⽤用宏(也就是call-last-kbd-macro) 
5. M-x name-last-kbd-macro 
# 可选 
6.打你的.emacs⽂文件并把光标跳转到特定的位置 
7.M-x insert-kbd-macro 
! 
调⽤用⽅方法: M-x 宏名
16 
elisp的宏 
— defmacro 
FUNCTION VS MACRO 
! 
函数只是对表达式求值;⽽而宏先展开表达式,然后再对展开后的表达式求值 
(defun test-fun (a b) 
(list '+ a b)) 
(defmacro test-macro (a b) 
(list '+ a b)) 
(test-fun 1 2) = (+ 1 2) 
(test-macro 1 2) = 3
17 
font-lock 
— 让buffer语法⾼高亮 
(global-font-lock-mode 0) ; 全局关闭 
M-x font-lock-mode ; 开启/关闭 
; 开启单个模式 
(add-hook 'lisp-mode-hook ‘turn-on-font-lock) 
(add-hook 'lisp-mode-hook 
(lambda () 
(font-lock-add-keywords nil 
'(((TODO): 1 font-lock-warning-face t)))))
18 
⾖豆瓣⽤用到的emacs设置 
(setq-default show-trailing-whitespace t) ; 显⽰示⾏行尾空格 
;; ⾃自动删掉⾏行尾空格 
(add-hook 'before-save-hook ‘delete-trailing-whitespace) 
(setq-default indent-tabs-mode nil) ; 使⽤用空格替代TAB 
;; Makefile 需要TAB 
(add-hook 'makefile-mode-hook ‘indent-tabs-mode) 
(setq column-number-mode t) ; 显⽰示列号 
(show-paren-mode t) ; 显⽰示括号匹配 
;; 光标在 TAB 字符上会显⽰示为⼀一个⼤大⽅方块 
(setq x-stretch-cursor t) 
(setq undo-outer-limit 5000000) ; 撤销限制 
! 
(setq css-indent-offset 4)
19 
假如你在⾖豆瓣⽤用python 
(setq 
python-shell-interpreter ipython 
python-shell-interpreter-args  
python-shell-prompt-regexp In [[0-9]+]:  
python-shell-prompt-output-regexp Out[[0-9]+]:  
python-shell-completion-setup-code 
from IPython.core.completerlib import module_completion 
python-shell-completion-module-string-code 
';'.join(module_completion('''%s'''))n 
python-shell-completion-string-code 
';'.join(get_ipython().Completer.all_completions('''%s'''))n)
20 
emacs插件
21 
elisp编程库 
1.s.el : 处理字符串相关 
2.f.el : ⽂文件相关 
3.dash.el : 列表相关 
4.ht.el : 哈希表相关 
5.bind-key : 更快的绑定快捷键 
6.use-package : 更快的使⽤用包和配置
22 
yasnippet 
— ⼀一个模板系统 
yas-new-snippet 
# -*- mode: snippet; require-final-newline: nil -*- 
# name: namespace 
# key: namespace 
# binding: direct-keybinding 
# -- 
%namespace name=$1 file=$2/ 
yas-reload-all
23 
其它 
1.isend-mode : 把buffer内容发送到解释器 
2.anzu : 显⽰示总匹配的数⺫⽬目和当前匹配 
3.jedi : python代码补全 
4.nyan-mode : ⼀一只可爱的猫 
5.rainbow-mode : 显⽰示样式为背景⾊色 
6.powerline : 状态⾏行插件 
7.zencoding : 快速写html代码 
8.hs-mode : 代码折叠
24 
我的emacs.d 
! 
㷯⁊⃚挝㤩†⁊吊】䢤GOCEU
25 
常⻅见配置中⽤用到 
1. nil/t ⾮非nil都为真 
2. quote '(+ 1 2) (quote (+ 1 2)) 
3. set/setq 
(set 'name '(Dong Weiming)) 
(setq name '(Dong Weiming)) 
4. require 当没有加载包时加载之 
5. add-hook/remove-hook 
6. global-set-key 
(global-set-key (kbdC-f9”) ‘compile)
26 
理由 
1.保存⽂文件⾃自动执⾏行autopep8 
2.保存⽂文件⾃自动执⾏行flycheck, 使⽤用pep8/flake8检查python规范 
3.使⽤用我认为舒服的快捷键 
4.⽀支持plim 
5.⾃自定义多个函数实现我想要的功能: 
. 打开没有权限⽂文件⾃自动提⽰示sudo 
. 在emacs⾥里可以打开google/github/code 
. 可以快速切换到前⼀一个buffer 
. 不刷屏向下/上翻⾏行 
. 快速搜索python函数/类位置 
. Gui下切换全屏 
. 根据等号对⻬齐⽂文本
27 
emacs开发⼊入⻔门 
每个快捷键实质是执⾏行⼀一个函数
28 
interactive 
(defun other-window-backward (optional n) 
Select Nth previous window. 
(interactive “p) ; C-u加数字就会传进来 
(other-window (- (or n 1)) 
(message %d n)) 
! 
Interactive-Codes
29 
visit-target-instead 
(defun visit-target-instead () 
Replace this buffer with a buffer visiting the link target. 
(interactive) 
(if buffer-file-name 
(let ((target (file-symlink-p buffer-file-name))) 
(if target 
(find-alternate-file target) 
(error Not visiting a symlink))) 
(error Not visiting a file)))
30 
clobber-symlink 
(defun clobber-symlink () 
Replace symlink with a copy of the file. 
(interactive) 
(if buffer-file-name 
(let ((target (file-symlink-p buffer-file-name))) 
(if target 
(if (yes-or-no-p (format Replace %s with %s? buffer-file-name 
target)) 
(progn 
(delete-file buffer-file-name) 
(write-file buffer-file-name))) 
(error Not visiting a symlink))) 
(error Not visiting a file)))
31 
defadvice 
— AOP 
(defadvice find-file (around th-find-file activate) 
Open FILENAME using tramp's sudo method if it's read-only. 
(if (and (not (file-writable-p (ad-get-arg 0))) 
(y-or-n-p (concat File  
(ad-get-arg 0) 
 is read-only. Open it as root? ))) 
(th-find-file-sudo (ad-get-arg 0)) 
ad-do-it)) 
! 
http://www.gnu.org/software/emacs/manual/html_node/elisp/Advising- 
Functions.html
32 
define-minor-mode 
(defun insert-some-text () 
(interactive) 
(insert “Just for test)) 
! 
(define-minor-mode auto-pep8-mode 
:init-value t 
:keymap (let ((map (make-sparse-keymap))) 
(define-key map (kbd C-c t) 'insert-some-text) 
map)) 
Autopep8 “) 
! 
!
33 
写个Major-mode 
https://gist.github.com/dongweiming/67cceb80748c091f85d3
34 
Thanks

More Related Content

What's hot

20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会Hiroki Mizuno
 
Playing 44CON CTF for fun and profit
Playing 44CON CTF for fun and profitPlaying 44CON CTF for fun and profit
Playing 44CON CTF for fun and profit44CON
 
プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話tatsunori ishikawa
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The AnswerIan Barber
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionIan Barber
 
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...Zabbix BR
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleIan Barber
 
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...Security Session
 
Exploring slides
Exploring slidesExploring slides
Exploring slidesakaptur
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialGagah Arifianto
 
Meet up symfony 16 juin 2017 - Les PSR
Meet up symfony 16 juin 2017 -  Les PSRMeet up symfony 16 juin 2017 -  Les PSR
Meet up symfony 16 juin 2017 - Les PSRJulien Vinber
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegeninovex GmbH
 
Python opcodes
Python opcodesPython opcodes
Python opcodesalexgolec
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges✅ William Pinaud
 

What's hot (20)

20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会20110424 action scriptを使わないflash勉強会
20110424 action scriptを使わないflash勉強会
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Playing 44CON CTF for fun and profit
Playing 44CON CTF for fun and profitPlaying 44CON CTF for fun and profit
Playing 44CON CTF for fun and profit
 
Duralexsedregex
DuralexsedregexDuralexsedregex
Duralexsedregex
 
Yg byev2e
Yg byev2eYg byev2e
Yg byev2e
 
プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話プログラム実行の話と
OSとメモリの挙動の話
プログラム実行の話と
OSとメモリの挙動の話
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
C99.php
C99.phpC99.php
C99.php
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
 
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
 
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
Robots against robots: How a Machine Learning IDS detected a novel Linux Botn...
 
Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018
 
Exploring slides
Exploring slidesExploring slides
Exploring slides
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline Tutorial
 
Meet up symfony 16 juin 2017 - Les PSR
Meet up symfony 16 juin 2017 -  Les PSRMeet up symfony 16 juin 2017 -  Les PSR
Meet up symfony 16 juin 2017 - Les PSR
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
 

Viewers also liked

Emacs intro
Emacs introEmacs intro
Emacs introKhon
 
My Emacs Configs
My Emacs ConfigsMy Emacs Configs
My Emacs ConfigsQin Jian
 
Emacs入门
Emacs入门Emacs入门
Emacs入门yinhm .
 
Emacs, a performant IDE for Perl
Emacs, a performant IDE for PerlEmacs, a performant IDE for Perl
Emacs, a performant IDE for PerlLaurent Dami
 
Emacs - COSCUP 2012
Emacs - COSCUP 2012Emacs - COSCUP 2012
Emacs - COSCUP 2012Kan-Ru Chen
 
Emacs Modes I can't work without
Emacs Modes I can't work withoutEmacs Modes I can't work without
Emacs Modes I can't work withoutHitesh Sharma
 
Emacs presentation
Emacs presentationEmacs presentation
Emacs presentationLingfei Kong
 
Code4vn - Linux day - linux boot process
Code4vn - Linux day - linux boot processCode4vn - Linux day - linux boot process
Code4vn - Linux day - linux boot processCường Nguyễn
 
How Emacs changed my life
How Emacs changed my lifeHow Emacs changed my life
How Emacs changed my lifeyukihiro_matz
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
(IDEユーザのための) ClojureのEmacs開発環境について
(IDEユーザのための) ClojureのEmacs開発環境について(IDEユーザのための) ClojureのEmacs開発環境について
(IDEユーザのための) ClojureのEmacs開発環境についてKazuhiro Hara
 
IoT - Além da Telemetria
IoT - Além da TelemetriaIoT - Além da Telemetria
IoT - Além da TelemetriaAndré Curvello
 
SMART International Symposium for Next Generation Infrastructure: An integrat...
SMART International Symposium for Next Generation Infrastructure: An integrat...SMART International Symposium for Next Generation Infrastructure: An integrat...
SMART International Symposium for Next Generation Infrastructure: An integrat...SMART Infrastructure Facility
 

Viewers also liked (20)

Emacs intro
Emacs introEmacs intro
Emacs intro
 
My Emacs Configs
My Emacs ConfigsMy Emacs Configs
My Emacs Configs
 
Emacs入门
Emacs入门Emacs入门
Emacs入门
 
Emacs, a performant IDE for Perl
Emacs, a performant IDE for PerlEmacs, a performant IDE for Perl
Emacs, a performant IDE for Perl
 
Emacs - COSCUP 2012
Emacs - COSCUP 2012Emacs - COSCUP 2012
Emacs - COSCUP 2012
 
Learn Linux: Emacs
Learn Linux: EmacsLearn Linux: Emacs
Learn Linux: Emacs
 
Emacs tutorial
Emacs tutorialEmacs tutorial
Emacs tutorial
 
Emacs Modes I can't work without
Emacs Modes I can't work withoutEmacs Modes I can't work without
Emacs Modes I can't work without
 
Emacs presentation
Emacs presentationEmacs presentation
Emacs presentation
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
 
Code4vn - Linux day - linux boot process
Code4vn - Linux day - linux boot processCode4vn - Linux day - linux boot process
Code4vn - Linux day - linux boot process
 
How Emacs changed my life
How Emacs changed my lifeHow Emacs changed my life
How Emacs changed my life
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
(IDEユーザのための) ClojureのEmacs開発環境について
(IDEユーザのための) ClojureのEmacs開発環境について(IDEユーザのための) ClojureのEmacs開発環境について
(IDEユーザのための) ClojureのEmacs開発環境について
 
Final pink panthers_03_30
Final pink panthers_03_30Final pink panthers_03_30
Final pink panthers_03_30
 
SMART Data Workshop: Geosocial Intelligence
SMART Data Workshop: Geosocial IntelligenceSMART Data Workshop: Geosocial Intelligence
SMART Data Workshop: Geosocial Intelligence
 
IoT - Além da Telemetria
IoT - Além da TelemetriaIoT - Além da Telemetria
IoT - Além da Telemetria
 
SIC 2016 Market Update with Harvey Gluckman
SIC 2016 Market Update with Harvey GluckmanSIC 2016 Market Update with Harvey Gluckman
SIC 2016 Market Update with Harvey Gluckman
 
Selling Solutions
Selling SolutionsSelling Solutions
Selling Solutions
 
SMART International Symposium for Next Generation Infrastructure: An integrat...
SMART International Symposium for Next Generation Infrastructure: An integrat...SMART International Symposium for Next Generation Infrastructure: An integrat...
SMART International Symposium for Next Generation Infrastructure: An integrat...
 

Similar to 我在豆瓣使用Emacs

Congfigure python as_ide
Congfigure python as_ideCongfigure python as_ide
Congfigure python as_ideLingfei Kong
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdfmaheshkumar12354
 
Apache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteApache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteAllen Wittenauer
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foobrian_dailey
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japanujihisa
 
2005_Structures and functions of Makefile
2005_Structures and functions of Makefile2005_Structures and functions of Makefile
2005_Structures and functions of MakefileNakCheon Jung
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
 
我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具dennis zhuang
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()Kiwamu Okabe
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Maarten Mulders
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationJacobMenke1
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and TricksKevin Cross
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 

Similar to 我在豆瓣使用Emacs (20)

Congfigure python as_ide
Congfigure python as_ideCongfigure python as_ide
Congfigure python as_ide
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
 
Apache Hadoop Shell Rewrite
Apache Hadoop Shell RewriteApache Hadoop Shell Rewrite
Apache Hadoop Shell Rewrite
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japan
 
Emacs Key Bindings
Emacs Key BindingsEmacs Key Bindings
Emacs Key Bindings
 
2005_Structures and functions of Makefile
2005_Structures and functions of Makefile2005_Structures and functions of Makefile
2005_Structures and functions of Makefile
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
Gun make
Gun makeGun make
Gun make
 
我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Unix executable buffer overflow
Unix executable buffer overflowUnix executable buffer overflow
Unix executable buffer overflow
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and Tricks
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 

Recently uploaded

Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Krijn Poppe
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationNathan Young
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...marjmae69
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Pooja Nehwal
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxFamilyWorshipCenterD
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptxBasil Achie
 
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)Basil Achie
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Salam Al-Karadaghi
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxaryanv1753
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸mathanramanathan2005
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...NETWAYS
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...NETWAYS
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfhenrik385807
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...NETWAYS
 
Philippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptPhilippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptssuser319dad
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...NETWAYS
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxJohnree4
 

Recently uploaded (20)

Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism Presentation
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
 
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptx
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
 
Philippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptPhilippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.ppt
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptx
 

我在豆瓣使用Emacs

  • 2. Outline ! . 初学emacs建议 . vimer - emacser . 让emacs不再神秘 . ⾖豆瓣⽤用到的emacs设置 . emacs插件 . 我的emacs.d . emacs开发⼊入⻔门
  • 3. 3 初学emacs建议 1.Emacs tutorial(C-h t) 2. ⼊入⻔门 http://www.slideshare.net/yinhm/emacs-7324447 3. 学习emacs需要忘记⿏鼠标,⽆无视菜单 4. 快捷键控制⼀一切 5. prelude 6. 使⽤用=24.3版本(brew install emacs)
  • 5. 5 学会这些快捷键就可以⽤用emacs Keystroke Command Name ! C-x C-f 打开⽂文件 C-x C-s 保存 C-x C-c 保存并退出 C-v 向上翻⻚页 M-v 向下翻⻚页 C-a 到⾏行⾸首 C-e 到⾏行尾 M-x 执⾏行命令 C-g 取消输⼊入 C-h b 查看快捷键 M-g g 跳到某⾏行
  • 6. 6 vimer - emacser alias emacs=/usr/local/opt/emacs/bin/emacs alias e='/usr/local/opt/emacs/bin/emacsclient -t' alias vi='e' alias vim=‘e' alias chop_hand_with_vim='/usr/bin/vim'
  • 8. 8 mode-line $emacs -q ../dongxi/dongxi/models/story/__init__.py -UUU:**--F1 __init__.py Top L30 Git-master (Python)——— 1. %e -- print error message about full memory. 2. mode-line-front-space 3. mode-line-mule-info: 语⾔言环境, buffer编码 U=utf-16 4. ** 被修改过了 — 未被修改过 %* 只读,但是被修改过 %% 只读,未被修改过 6. 默认的frame(框架)名字是F1 7. buffer名字或者⽂文件名字 8. 在buffer的位置. Top/Bot/nn%/All 9. 当前⾏行号 10. minor-mode 可以多个次要模式(vc-mode) 11. major-mode 只能⼀一个主模式 http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_360.html
  • 9. 9 包管理源 gnu - http://elpa.gnu.org/packages/ marmalade - http://marmalade-repo.org/packages/ melpa - http://melpa.milkbox.net/packages/
  • 10. 10 Package.el —- 内建于emacs24包管理 (require 'package) (package-initialize) (mapc (lambda (package) (unless (package-installed-p package) (package-install package))) ‘(smex s f dash flycheck))
  • 11. 11 el-get (setq my:el-get-packages ‘(smex s f dash flycheck )) ! (el-get 'sync my:el-get-packages)
  • 12. 12 ! Cask ! $cat Cask (source gnu) (source melpa) (source marmalade) ! (depends-on smex) (depends-on s) (depends-on f) (depends-on “dash) (depends-on flycheck) $cask
  • 13. 13 bookmark — 保存缓冲区中位置 Keystroke Command Name ! C-x r m Bo 设置⼀一个名为 Bo 的书签 C-x r l 列出所有已保存的书签 C-x r b Bo 跳转到书签Bo M-x bookmark-delete 删除书签 M-x bookmark-save 将所有的书签保存到/.emac.bmk 中 ! (setq bc-bookmark-file “~/emacs.d/bookmark”) 设置书签的保存位置 (setq bc-bookmark-limit 300) 设置书签的最⼤大数量 saveplace.el : automatically save place in files.
  • 14. 14 eshell — 可以使⽤用elisp的shell 1.很多内置命令其实替代了*nix命令 $ which ls eshell/ls is a compiled Lisp function in `em-ls.el' 2. 内置变量 $$, $? … $ echo $+ /Users/dongweiming/shire-in-vagrant 3. Tricks ls #buffer ttt
  • 15. 15 emacs的宏 — ⼀一组被记录下来的按键记录 1.开始录制宏: C-x ( 2.你要执⾏行的操作 3.结束录制宏: C-x ) 4.⽤用C-x e来使⽤用宏(也就是call-last-kbd-macro) 5. M-x name-last-kbd-macro # 可选 6.打你的.emacs⽂文件并把光标跳转到特定的位置 7.M-x insert-kbd-macro ! 调⽤用⽅方法: M-x 宏名
  • 16. 16 elisp的宏 — defmacro FUNCTION VS MACRO ! 函数只是对表达式求值;⽽而宏先展开表达式,然后再对展开后的表达式求值 (defun test-fun (a b) (list '+ a b)) (defmacro test-macro (a b) (list '+ a b)) (test-fun 1 2) = (+ 1 2) (test-macro 1 2) = 3
  • 17. 17 font-lock — 让buffer语法⾼高亮 (global-font-lock-mode 0) ; 全局关闭 M-x font-lock-mode ; 开启/关闭 ; 开启单个模式 (add-hook 'lisp-mode-hook ‘turn-on-font-lock) (add-hook 'lisp-mode-hook (lambda () (font-lock-add-keywords nil '(((TODO): 1 font-lock-warning-face t)))))
  • 18. 18 ⾖豆瓣⽤用到的emacs设置 (setq-default show-trailing-whitespace t) ; 显⽰示⾏行尾空格 ;; ⾃自动删掉⾏行尾空格 (add-hook 'before-save-hook ‘delete-trailing-whitespace) (setq-default indent-tabs-mode nil) ; 使⽤用空格替代TAB ;; Makefile 需要TAB (add-hook 'makefile-mode-hook ‘indent-tabs-mode) (setq column-number-mode t) ; 显⽰示列号 (show-paren-mode t) ; 显⽰示括号匹配 ;; 光标在 TAB 字符上会显⽰示为⼀一个⼤大⽅方块 (setq x-stretch-cursor t) (setq undo-outer-limit 5000000) ; 撤销限制 ! (setq css-indent-offset 4)
  • 19. 19 假如你在⾖豆瓣⽤用python (setq python-shell-interpreter ipython python-shell-interpreter-args python-shell-prompt-regexp In [[0-9]+]: python-shell-prompt-output-regexp Out[[0-9]+]: python-shell-completion-setup-code from IPython.core.completerlib import module_completion python-shell-completion-module-string-code ';'.join(module_completion('''%s'''))n python-shell-completion-string-code ';'.join(get_ipython().Completer.all_completions('''%s'''))n)
  • 21. 21 elisp编程库 1.s.el : 处理字符串相关 2.f.el : ⽂文件相关 3.dash.el : 列表相关 4.ht.el : 哈希表相关 5.bind-key : 更快的绑定快捷键 6.use-package : 更快的使⽤用包和配置
  • 22. 22 yasnippet — ⼀一个模板系统 yas-new-snippet # -*- mode: snippet; require-final-newline: nil -*- # name: namespace # key: namespace # binding: direct-keybinding # -- %namespace name=$1 file=$2/ yas-reload-all
  • 23. 23 其它 1.isend-mode : 把buffer内容发送到解释器 2.anzu : 显⽰示总匹配的数⺫⽬目和当前匹配 3.jedi : python代码补全 4.nyan-mode : ⼀一只可爱的猫 5.rainbow-mode : 显⽰示样式为背景⾊色 6.powerline : 状态⾏行插件 7.zencoding : 快速写html代码 8.hs-mode : 代码折叠
  • 24. 24 我的emacs.d ! 㷯⁊⃚挝㤩†⁊吊】䢤GOCEU
  • 25. 25 常⻅见配置中⽤用到 1. nil/t ⾮非nil都为真 2. quote '(+ 1 2) (quote (+ 1 2)) 3. set/setq (set 'name '(Dong Weiming)) (setq name '(Dong Weiming)) 4. require 当没有加载包时加载之 5. add-hook/remove-hook 6. global-set-key (global-set-key (kbdC-f9”) ‘compile)
  • 26. 26 理由 1.保存⽂文件⾃自动执⾏行autopep8 2.保存⽂文件⾃自动执⾏行flycheck, 使⽤用pep8/flake8检查python规范 3.使⽤用我认为舒服的快捷键 4.⽀支持plim 5.⾃自定义多个函数实现我想要的功能: . 打开没有权限⽂文件⾃自动提⽰示sudo . 在emacs⾥里可以打开google/github/code . 可以快速切换到前⼀一个buffer . 不刷屏向下/上翻⾏行 . 快速搜索python函数/类位置 . Gui下切换全屏 . 根据等号对⻬齐⽂文本
  • 28. 28 interactive (defun other-window-backward (optional n) Select Nth previous window. (interactive “p) ; C-u加数字就会传进来 (other-window (- (or n 1)) (message %d n)) ! Interactive-Codes
  • 29. 29 visit-target-instead (defun visit-target-instead () Replace this buffer with a buffer visiting the link target. (interactive) (if buffer-file-name (let ((target (file-symlink-p buffer-file-name))) (if target (find-alternate-file target) (error Not visiting a symlink))) (error Not visiting a file)))
  • 30. 30 clobber-symlink (defun clobber-symlink () Replace symlink with a copy of the file. (interactive) (if buffer-file-name (let ((target (file-symlink-p buffer-file-name))) (if target (if (yes-or-no-p (format Replace %s with %s? buffer-file-name target)) (progn (delete-file buffer-file-name) (write-file buffer-file-name))) (error Not visiting a symlink))) (error Not visiting a file)))
  • 31. 31 defadvice — AOP (defadvice find-file (around th-find-file activate) Open FILENAME using tramp's sudo method if it's read-only. (if (and (not (file-writable-p (ad-get-arg 0))) (y-or-n-p (concat File (ad-get-arg 0) is read-only. Open it as root? ))) (th-find-file-sudo (ad-get-arg 0)) ad-do-it)) ! http://www.gnu.org/software/emacs/manual/html_node/elisp/Advising- Functions.html
  • 32. 32 define-minor-mode (defun insert-some-text () (interactive) (insert “Just for test)) ! (define-minor-mode auto-pep8-mode :init-value t :keymap (let ((map (make-sparse-keymap))) (define-key map (kbd C-c t) 'insert-some-text) map)) Autopep8 “) ! !