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
On Emacs modes
Search
dotemacs
May 20, 2014
Programming
2
180
On Emacs modes
Presentation about Emacs modes, given at London Emacs meetup 20th May 2014
dotemacs
May 20, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
孤独のCTOグルメという やや奇抜な企画をやった目的と効果
shoheimitani
3
1k
両面どころかインフラもTSでできるよ ~ 全方位TypeScriptによるプロダクト開発 ~
myfinder
8
2.2k
SwiftUI, Jetpack Composeの導入で変化した「家族アルバム みてね」のアプリ開発体験
hicka04
6
400
Introduction for Open Source Swift Workshop
giginet
PRO
0
180
Ruby製社内ツールのGo移行
bgpat
2
260
Compiling Python to WebAssembly with py2wasm
syrusakbary
0
130
Cloud RunとCloud PubSubでサーバレスなデータ基盤2024 with Terraform / Cloud Run and PubSub with Terraform
shinyorke
7
1.9k
ここ1~2年くらいで 使えるようになった(主要ブラウザーの最新版 がすべて対応した ) ウェブの新機能について ランダムに喋る!
myzkyy
9
6.5k
object-oriented-conference-2024
fuwasegu
6
1.9k
Migrating to Signals: A Practical Workshop
manfredsteyer
PRO
0
280
Dockerで始めるAWS Lambda開発
stutkhd0709
13
2.5k
コミュニティに参加したことで起きた変化
ohmori_yusuke
3
130
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
257
12k
The Mythical Team-Month
searls
214
42k
Agile that works and the tools we love
rasmusluckow
323
20k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Designing with Data
zakiwarfel
94
4.8k
VelocityConf: Rendering Performance Case Studies
addyosmani
319
23k
Keith and Marios Guide to Fast Websites
keithpitt
407
22k
YesSQL, Process and Tooling at Scale
rocio
160
13k
The Invisible Customer
myddelton
114
12k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
The Pragmatic Product Professional
lauravandoore
24
5.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
Transcript
M-x emacs-meetup London 20th May 2014 by @dotemacs
About modes
What are modes?
"...encapsulate a set of editing behaviours." - Bob Glickstein
Yukihiro Matz chief designer of the Ruby programming language
"I started Ruby development with influence from Emacs implementation"
"But as an Emacs addict I needed a language mode"
"auto-indent was a must"
"Back in 1993, there was no auto-indenting language mode for
a language with such syntax"
"I somehow succeeded in implementing auto-indent for a language with
'end' delimiters"
"If I couldn't make ruby-mode work the syntax of Ruby
would have changed to more C-like one, too similar to other scripting languages and as a result, Ruby would not have gained current popularity"
How was it done before?
Bob Glickstein & Scott Andrew Borton
Modes
two types
minor & major
Minor mode
Definition (define-minor-mode <name>-mode ....)
name :lighter
keymap Specific for the minor-mode :keymap
variable <name>-mode
command called <name>-mode that can toggle the mode on/off
Add it to a hook (add-hook 'some-mode 'your-mode)
Major mode
name
hooks <name>-mode-hook
syntax table
Entry function <name>-mode
Which should do the following:
syntax highlighting write optimised regexps or use regexp-opt
indentation
syntax table "behaviour" & movement
remove all buffer-local variables (kill-all-local-variable)
set the variables major-mode to <name>-mode mode-name to string "<name>"
install mode specific keymap
Options for keymap sparse-keymap define your own
bind mode to files (add-to-list 'auto-mode-alist '("\\.BAR\\'" . FOO-mode))
run user defined hooks for the mode Defined with <name>-mode-hook
provide mode (provide '<name>)
cookies ;;;###autoload
This sounds like a lot of work. Why re-invent the
wheel?
Cookie cutter sample-mode - 2001 derived-mode
checkdoc
Thank you ❤
Notes » Yukihiro Matz's notes on Ruby syntax design »
How to write a minor mode » Book "Writing GNU Emacs Extensions" by Bob Glickstein » Mode Tutorial » sample-mode » checkdoc