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'
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
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
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