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
220
Emacs Lisp 学习笔记
Chi Zhang
October 17, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
2.4k
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
180
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
330
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
6k
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
250
CSC307 Lecture 07
javiergs
PRO
0
550
AtCoder Conference 2025
shindannin
0
1k
高速開発のためのコード整理術
sutetotanuki
1
390
CSC307 Lecture 01
javiergs
PRO
0
690
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
250
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
Apache Iceberg V3 and migration to V3
tomtanaka
0
150
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
100
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Ethics towards AI in product and experience design
skipperchong
2
190
Darren the Foodie - Storyboard
khoart
PRO
2
2.3k
Embracing the Ebb and Flow
colly
88
5k
Navigating Team Friction
lara
192
16k
Paper Plane
katiecoart
PRO
0
46k
The World Runs on Bad Software
bkeepers
PRO
72
12k
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: