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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Chi Zhang
October 17, 2012
Programming
220
1
Share
Emacs Lisp 学习笔记
Chi Zhang
October 17, 2012
Other Decks in Programming
See All in Programming
Talking to terminals (and how they talk back) (KotlinConf 2026)
jakewharton
PRO
1
130
横断組織出身のQAEがインプロセスQAEでつまずいたこと・活かせたこと
ty89
0
290
AIとRubyの静的型付け
ukin0k0
0
130
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
0
110
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
240
TSKaigi2026-静的解析への投資がAI時代のコード品質を支える ── カスタムESLintルールの設計と運用
hayatokudou
6
1.2k
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
130
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
260
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
380
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
150
[BalkanRuby 2026] Drop your app/services!
palkan
3
690
RTSPクライアントを自作してみた話
simotin13
0
190
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
200
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
190
Exploring anti-patterns in Rails
aemeredith
3
370
A better future with KSS
kneath
240
18k
Building AI with AI
inesmontani
PRO
1
1k
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
210
Designing for Performance
lara
611
70k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
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: