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
200
Emacs Lisp 学习笔记
Chi Zhang
October 17, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
Conform を推す - Advocating for Conform
mizoguchicoji
3
690
仕様変更に耐えるための"今の"DRY原則を考える / Rethinking the "Don't repeat yourself" for resilience to specification changes
mkmk884
0
120
『GO』アプリ データ基盤のログ収集システムコスト削減
mot_techtalk
0
120
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
840
Honoとフロントエンドの 型安全性について
yodaka
7
1.2k
ソフトウェアエンジニアの成長
masuda220
PRO
10
1.1k
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
10
3.6k
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
110
Linux && Docker 研修/Linux && Docker training
forrep
24
4.5k
Formの複雑さに立ち向かう
bmthd
1
840
Pulsar2 を雰囲気で使ってみよう
anoken
0
240
昭和の職場からアジャイルの世界へ
kumagoro95
1
370
Featured
See All Featured
How GitHub (no longer) Works
holman
314
140k
The Invisible Side of Design
smashingmag
299
50k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
Writing Fast Ruby
sferik
628
61k
Practical Orchestrator
shlominoach
186
10k
Adopting Sorbet at Scale
ufuk
74
9.2k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
10
1.3k
Thoughts on Productivity
jonyablonski
69
4.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
174
51k
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: