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
型で語るカタ
irof
0
700
ふつうの技術スタックでアート作品を作ってみる
akira888
1
1.3k
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
15
5.6k
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
240
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
680
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
260
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
1k
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
140
レトロゲームから学ぶ通信技術の歴史
kimkim0106
0
110
Vibe Codingの幻想を超えて-生成AIを現場で使えるようにするまでの泥臭い話.ai
fumiyakume
9
3.8k
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
240
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
13k
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Building an army of robots
kneath
306
45k
Making Projects Easy
brettharned
116
6.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
830
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
How GitHub (no longer) Works
holman
314
140k
It's Worth the Effort
3n
185
28k
A Tale of Four Properties
chriscoyier
160
23k
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: