$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Emacs Lisp 学习笔记
Search
Chi Zhang
October 17, 2012
Programming
1
210
Emacs Lisp 学习笔记
Chi Zhang
October 17, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
愛される翻訳の秘訣
kishikawakatsumi
3
340
Deno Tunnel を使ってみた話
kamekyame
0
220
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
130
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.3k
チームをチームにするEM
hitode909
0
370
マスタデータ問題、マイクロサービスでどう解くか
kts
0
110
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
440
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
390
AIエージェントの設計で注意するべきポイント6選
har1101
5
2k
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
270
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
170
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
120
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
260
WENDY [Excerpt]
tessaabrams
8
35k
The Language of Interfaces
destraynor
162
25k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
130
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
0
31
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
BBQ
matthewcrist
89
9.9k
Prompt Engineering for Job Search
mfonobong
0
120
Fireside Chat
paigeccino
41
3.8k
GitHub's CSS Performance
jonrohan
1032
470k
Transcript
Emacs Lisp 学习笔记 Zhang Chi @ClvrObj
⼀一个简单目标
写⼀一个方法检查文件是否有 # -*- coding: utf-8 -*- 没有就给加上
⼀一步⼀一步来
基本元素
list, number, string, t, nil
在Emacs中执行和测试
M-x lisp-interaction-mode then C-j or C-x C-e
自带的⼀一些常用方法
+ - * / 1+ 1- /= = > <
equal and or not
方法声明
(defun func-name (arg, ...) "documentation..." body-of-function)
方法调用
(func-name arg, ...)
接受用户输入
(defun func-name (arg, ...) "documentation..." (interactive) body-of-function)
逻辑控制
let, if, cond, progn
(let ((variable value) (variable value) ...) body...)
(if true-or-false-test action-if-true action-if-false)
相当于switch case (cond (first-true-or-false-test first- consequent) (second-true-or-false-test second- consequent) (third-true-or-false-test
third- consequent) ...)
执行多个步骤 (progn body...)
回到目标
写⼀一个方法检查文件是否有 # -*- coding: utf-8 -*- 没有就给加上
目标达成
(defun add-py-header () "check and add # -*- coding: utf-8
-*-" (interactive) (let ((pyheader "# -*- coding: utf-8 -*-")) (if (not (equal pyheader (buffer-substring-no- properties 1 (1+ (length pyheader))))) (progn (goto-char 1) (insert (concat pyheader "\n\n")))))) https://gist.github.com/3795035/
Lisp
Born in 1958 by John McCarthy (1927 - 2011)
参考 • [为什么Lisp语言如此先进?(译文)](http://www.ruanyifeng.com/blog/ 2010/10/why_lisp_is_superior.html) • [Programming in Emacs Lisp](http://www.gnu.org/software/emacs/emacs- lisp-intro/html_mono/emacs-lisp-intro.html#multiply_002dby_002dseven-in-
detail) • [Learning GNU Emacs](http://book.douban.com/subject/1431970/) Chapter 11 • [Common Emacs Lisp Functions](http://ergoemacs.org/emacs/ elisp_common_functions.html)
:sparkles:Thanks!:sparkles: