SlideShare a Scribd company logo
Pymacs 初體驗
PyConTW 2013
Superbil <superbil@gmail.com>
0.0.1
13年5月30⽇日星期四
About Me
•軟體⼯工程師、Mobile App 開發
•Emacs 使⽤用經驗⼤大約 1 年
•Python 使⽤用經驗⼤大約 1 年
•PyHUG 主持⼈人
•about.me/superbil
•freenode #python.tw #emacs.tw
on RPi
13年5月30⽇日星期四
什麼是 Emacs ?
13年5月30⽇日星期四
編輯器
13年5月30⽇日星期四
編輯器學習曲線
13年5月30⽇日星期四
為什麼要⽤用 Emacs ?!
13年5月30⽇日星期四
You can hack it !
你不⽤用把⼿手從鍵盤上移開
13年5月30⽇日星期四
What is a hacker ?
• hacker 是那些勇於挑戰既有體制,改變
系統讓世界更進步的玩家,決定⼀一個⼈人
是否為 hacker 的關鍵在於思維。hacker
其實是⼀一種思考模式
羅根.拉普蘭特:⽤用駭客思維學習
Logan LaPlante: Hackschooling Makes Me Happy
13年5月30⽇日星期四
Emacs 基本介紹
• Ctrl + h t // emacs tutorial
• Ctrl + {b,n,p,f} // h j k l
• Ctrl + x b // 切換 buffer
• Ctrl + x Ctrl + e // 執⾏行 ( ) 中的 elisp
• Ctrl + h m // 查詢當下 mode 的⽂文件
13年5月30⽇日星期四
Emacs 的熱鍵很難按
13年5月30⽇日星期四
更換你的 Ctrl 鍵位置
• 你記得你上次⽤用到 Caps Lock 是什麼時
候嗎?
• Ctrl 在下⾯面的位置其實是⾮非常難按的
巨⼈人出現了阿!!!
13年5月30⽇日星期四
Emacs vsVim
13年5月30⽇日星期四
Emacs vsVim
vs Sublime Text
13年5月30⽇日星期四
Emacs vsVim
vs Sublime Text
vs More...
13年5月30⽇日星期四
Emacs vsVim
• 其實這是個陳年⽼老問題…
• 沒有好或不好,只有合不合⽤用
13年5月30⽇日星期四
為何不同時使⽤用
Emacs 和Vim ?
by 程序员时髦值指南
同时⽤用 Vim 和
Emacs,这⼈人早
被烧死了
13年5月30⽇日星期四
Install Emacs
on Server ?
13年5月30⽇日星期四
為什麼要⽤用 Pymacs ?
13年5月30⽇日星期四
因為沒有⼈人會寫 lisp
emacs lisp
13年5月30⽇日星期四
因為沒有⼈人會寫 lisp
• 想要 hack Emacs ⼜又不想學 lisp
你就可以⽤用 Pymacs
13年5月30⽇日星期四
How to install Pymacs
• Python side
• make install
• Emacs side
• M-x package-install RET pymacs RET
Emacs 24.x +
13年5月30⽇日星期四
Pymacs Debug
要切換到 *Pymacs* 這個 Buffer
13年5月30⽇日星期四
Pymacs 運作原理
• 建⽴立 server process 跑到 loop 等待
• 當接收到指令之後執⾏行,並回傳到
emacs
• 實際上是遞迴
13年5月30⽇日星期四
Pymacs 的簡單應⽤用
• pymacs-exec
• (pymacs-exec "print 'Hello PyConTw'")
• 在 Python 的執⾏行環境裡⾯面執⾏行程式碼
執⾏行 python 的 statement,回傳值永遠都是 nil
13年5月30⽇日星期四
Hello World
Python side
from Pymacs import lisp
interactions = {}
def hello_world():
"Hello world' from Python."
lisp.insert("Hello from Python!")
interactions[hello_world] = ''
13年5月30⽇日星期四
Hello World
Emacs side
• 讀取⼀一個名為 helloEmacs 的套件,並使
⽤用 hm- 來當作前綴詞
(pymacs-load "helloEmacs" "hm-")
13年5月30⽇日星期四
產⽣生出 lisp function
• (hm-hello-world)
hm-hello-world is an interactive Lisp function.
(hm-hello-world &rest ARGUMENTS)
It interfaces to a Python function.
Hello world' from Python.
13年5月30⽇日星期四
M-x hm-hello-world
(hm-hello-world)Hello from Python!
13年5月30⽇日星期四
Sample - winkler
from Pymacs import lisp
interactions = {}
def break_on_whitespace():
start, end = lisp.point(), lisp.mark(True)
words = lisp.buffer_substring(start,
end).split()
lisp.delete_region(start, end)
lisp.insert('n'.join(words))
interactions[break_on_whitespace] = ''
13年5月30⽇日星期四
Sample - winkler result
Hello PyCon Taiwan
M-x winkler-break-on-whitespace
Hello
PyCon
Taiwan
Marked
from Pymacs import lisp
interactions = {}
def break_on_whitespace():
start, end = lisp.point(), lisp.mark(True)
words = lisp.buffer_substring(start, end).split()
lisp.delete_region(start, end)
lisp.insert('n'.join(words))
interactions[break_on_whitespace] = ''
13年5月30⽇日星期四
Live Demo
13年5月30⽇日星期四
到那邊問問題?
• Pymacs 0.25
• Emacswiki.org
• stackoverflow.com
• Emacs on Google Plus
• freenode#emacs.tw
• planet.emacsen.org
13年5月30⽇日星期四
13年5月30⽇日星期四
Happy Hacking
Keyboard
13年5月30⽇日星期四
Thank you
13年5月30⽇日星期四

More Related Content

PPT
Xml Lab 電腦&網路
aecro
 
PDF
Emacs Cheat Sheet
guest9ebed9
 
ODP
SLIME
chaitanyagupta
 
PDF
On editing text and Emacs: 9 habits of highly effective text editing
dmgerman
 
PDF
20130404 emacs conf 2013 sketchnotes
Sacha Chua
 
PDF
Quantified Awesome: Tracking Clothes, Groceries, and Other Small Things
Sacha Chua
 
PDF
Emacs Modes I can't work without
Hitesh Sharma
 
PDF
How Emacs changed my life
yukihiro_matz
 
Xml Lab 電腦&網路
aecro
 
Emacs Cheat Sheet
guest9ebed9
 
On editing text and Emacs: 9 habits of highly effective text editing
dmgerman
 
20130404 emacs conf 2013 sketchnotes
Sacha Chua
 
Quantified Awesome: Tracking Clothes, Groceries, and Other Small Things
Sacha Chua
 
Emacs Modes I can't work without
Hitesh Sharma
 
How Emacs changed my life
yukihiro_matz
 

Similar to Pymacs 初體驗 (20)

PDF
《Python 3.5 技術手冊》第二章草稿
Justin Lin
 
PPTX
[3]投影片 futurewad樹莓派研習會 141204
CAVEDU Education
 
PPTX
Python 入門初體驗
政斌 楊
 
PDF
Python系列3
數真 蔡
 
ODP
新北市教師工作坊 -- Bash script programming 介紹
fweng322
 
PDF
linux 從無到有
alex867
 
PDF
Python 2 - 快速簡介
Cheyin L
 
PDF
Python 工作坊 (NCTU)
柏瑀 黃
 
PDF
Command line 初級寶典
Tom Chen
 
PDF
Mac os Terminal 常用指令與小技巧
Chen Liwei
 
PPTX
從 REPL 到 IDE
Justin Lin
 
PDF
Ruby on Rails 開發環境建置 for Mac
MarsZ Chen
 
PDF
2. 從 REPL 到 IDE
Justin Lin
 
PPTX
Elastic stack day-2
YI-CHING WU
 
PDF
Learn python 2 - Real World Case
Chia-Hao Tsai
 
PDF
Python系列1
數真 蔡
 
PDF
優雅的在 Emacs 中使用 git
Kai-Yuan Cheng
 
PDF
Python meetup 1
Vic Yang
 
PPTX
Mercurial簡介與教學
芳本 林
 
PDF
Python 實戰 WMS 系統開發 Python 實戰 WMS 系統開發 Python 實戰 WMS 系統開發
Leon08241
 
《Python 3.5 技術手冊》第二章草稿
Justin Lin
 
[3]投影片 futurewad樹莓派研習會 141204
CAVEDU Education
 
Python 入門初體驗
政斌 楊
 
Python系列3
數真 蔡
 
新北市教師工作坊 -- Bash script programming 介紹
fweng322
 
linux 從無到有
alex867
 
Python 2 - 快速簡介
Cheyin L
 
Python 工作坊 (NCTU)
柏瑀 黃
 
Command line 初級寶典
Tom Chen
 
Mac os Terminal 常用指令與小技巧
Chen Liwei
 
從 REPL 到 IDE
Justin Lin
 
Ruby on Rails 開發環境建置 for Mac
MarsZ Chen
 
2. 從 REPL 到 IDE
Justin Lin
 
Elastic stack day-2
YI-CHING WU
 
Learn python 2 - Real World Case
Chia-Hao Tsai
 
Python系列1
數真 蔡
 
優雅的在 Emacs 中使用 git
Kai-Yuan Cheng
 
Python meetup 1
Vic Yang
 
Mercurial簡介與教學
芳本 林
 
Python 實戰 WMS 系統開發 Python 實戰 WMS 系統開發 Python 實戰 WMS 系統開發
Leon08241
 
Ad

Pymacs 初體驗