Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
AIと”コードの評価関数”を共有する / Share the "code evaluation function" with AI
euglena1215
1
120
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
260
LINEヤフー データグループ紹介
lycorp_recruit_jp
0
1.9k
Goで作る、開発・CI環境
sin392
0
190
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
110
RailsGirls IZUMO スポンサーLT
16bitidol
0
160
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
220
WindowInsetsだってテストしたい
ryunen344
1
230
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
280
A2A プロトコルを試してみる
azukiazusa1
2
1.3k
“いい感じ“な定量評価を求めて - Four Keysとアウトカムの間の探求 -
nealle
1
5.5k
ふつうの技術スタックでアート作品を作ってみる
akira888
0
390
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Side Projects
sachag
455
42k
A better future with KSS
kneath
239
17k
Designing for humans not robots
tammielis
253
25k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
For a Future-Friendly Web
brad_frost
179
9.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.9k
Designing for Performance
lara
610
69k
It's Worth the Effort
3n
185
28k
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: