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
220
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Emacs Lisp 学习笔记
Chi Zhang
October 17, 2012
Other Decks in Programming
See All in Programming
源内ハンズオン概要編
hideg
0
190
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
800
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
390
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
0
130
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
120
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
110
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
330
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
600
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
240
Building a Meta Ray-Ban display app
akkeylab
0
170
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
340
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
270
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
300
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
370
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1.1k
It's Worth the Effort
3n
188
29k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
270
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
720
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Navigating Team Friction
lara
192
16k
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: