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
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
390
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
550
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
300
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8.3k
The free-lunch guide to idea circularity
hollycummins
0
320
AHC061解説
shun_pi
0
410
How to stabilize UI tests using XCTest
akkeylab
0
140
Everything Claude Code OSS詳細 — 5層構造の中身と導入方法
targe
0
150
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
6
1.1k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
760
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.1k
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
7
3k
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
150
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.2k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
130
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
140
Evolving SEO for Evolving Search Engines
ryanjones
0
170
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
180
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
480
We Are The Robots
honzajavorek
0
200
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
130
The Limits of Empathy - UXLibs8
cassininazir
1
270
How to make the Groovebox
asonas
2
2k
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: