Weitere ähnliche Inhalte
Mehr von Kenichirou Oyama (8)
Fukuoka Emacs #X02
- 2. (self-introduce quot;k1LoWquot;)
• type:
–Programmer (PHPer)
• Emacs Level:
–Enjoy Emacs Lisp
• Emacs Lisp:
– cake.el
– drill-instructor.el(鬼軍曹.el)
– and more.
• membership:
– Fusic Co.,Ltd >> http://fusic.co.jp
– codecheck.in >> http://trac.codecheck.in
and 101000code / 3rdSTONE
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 2
- 4. What is Emacs?
• たぶんテキストエディタ
• Emacs Lispと呼ばれるプログラ
ミング言語で自由度の高すぎる拡
張が可能
–テキストエディタの範疇を軽く超
えている
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 4
- 5. Emacsの歴史
1970 MIT AI研で誕生
(略)
1984 GNU Emacs project start.
2007 anything.el first release.
2008 (tokyo-emacs #x01)
2009 (fukuoka-emacs #x02) in テキストエディタ勉強会←今ココ
2009 Emacserが増える。Emacs Lisperが増える。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 5
- 7. Why Emacs?
• 現在よく使われているテキストエ
ディタとしてはたぶん古いほう
• 別に他に選択肢はたくさんある
– FusicのPHPの開発で言えば
• NetBeans
• Peggy
• VisualStudio
• Vim
• Emacs
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 7
- 9. Emacsに対するかつてのイメージ
• 黒白画面
–ネットワークごしに使うもの
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 9
- 10. Emacsに対するかつてのイメージ
• 黒白画面
–ネットワークごしに使うもの
• マウスが使えない
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 10
- 11. Emacsに対するかつてのイメージ
• 黒白画面
–ネットワークごしに使うもの
• マウスが使えない
• キーバインド(ショートカット)が変態
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 11
- 12. Emacsに対するかつてのイメージ
• 黒白画面
–ネットワークごしに使うもの
• マウスが使えない
• キーバインド(ショートカット)が変態
• 古い
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 12
- 13. Emacsに対するかつてのイメージ
• 黒白画面
–ネットワークごしに使うもの
• マウスが使えない
• キーバインド(ショートカット)が変態
• 古い
• めちゃくちゃすごい人が使っている
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 13
- 14. Emacsに対するかつてのイメージ
• 黒白画面
–ネットワークごしに使うもの
• マウスが使えない
• キーバインド(ショートカット)が変態
• 古い
• めちゃくちゃすごい人が使っている
• めちゃくちゃすごい人しか使えない
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 14
- 16. Emacsに対する今のイメージ
• シンタックスハイライト可能
–ネットワークごしでもカラー
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 16
- 17. Emacsに対する今のイメージ
• シンタックスハイライト可能
–ネットワークごしでもカラー
• マウスを使いたくなくなる
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 17
- 18. Emacsに対する今のイメージ
• シンタックスハイライト可能
–ネットワークごしでもカラー
• マウスを使いたくなくなる
• キーバインド(ショートカット)は慣れ
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 18
- 19. Emacsに対する今のイメージ
• シンタックスハイライト可能
–ネットワークごしでもカラー
• マウスを使いたくなくなる
• キーバインド(ショートカット)は慣れ
• 超拡張可能。超可能。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 19
- 20. Emacsに対する今のイメージ
• シンタックスハイライト可能
–ネットワークごしでもカラー
• マウスを使いたくなくなる
• キーバインド(ショートカット)は慣れ
• 超拡張可能。超可能。
• 使っているとできる気になる
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 20
- 21. Emacsに対する今のイメージ
• シンタックスハイライト可能
–ネットワークごしでもカラー
• マウスを使いたくなくなる
• キーバインド(ショートカット)は慣れ
• 超拡張可能。超可能。
• 使っているとできる気になる
• すごくなくても使える
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 21
- 22. Emacs VS 一般的なエディタ/IDEで
機能比較してみた
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 22
- 23. 機能比較
Emacs Popular Text Popular IDE
Editor
インストール インストーラで インストーラで インストーラで
すぐ すぐ すぐ
初期設定 不必要(一部必要) 不必要 不必要
拡張 Emacs Lispで超 あまりできない プラグイン
可能
ネットワーク 可能 不可能 不可能
ごしの使用
マウス 使用可能 ないと使えない ないと使えない
シンタックス 可能 可能 可能
ハイライト
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 23
- 24. 機能比較
Emacs Popular Text Popular IDE
Editor
メール 可能 不可能 不可能
Web 可能 不可能 不可能
RSS購読 可能 不可能 不可能
スケジュール 可能 不可能 不可能
管理
2chブラウズ 可能 不可能 不可能
Twitter 可能 不可能 不可能
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 24
- 25. 機能比較
Emacs Popular Text Popular IDE
Editor
IRC 可能 不可能 不可能
Skypeチャッ 可能 不可能 不可能
ト
ブログ投稿 可能 不可能 不可能
Wiki編集 可能 不可能 不可能
ゲーム 可能 不可能 不可能
プログラムイ 可能 不可能 不可能
ンタプリタ
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 25
- 26. 感想:
Emacsはなんかおかしい(いい意味で)
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 26
- 28. Emacs Now
※注意:以下はかなり主観的内容です
• Emacsの機能拡張は基本的にEmacs
Lispになるので、Emacs Lispのトレ
ンドがEmacsをとりまく現状になる?
–EmacsWikiのRSSを日々購読
–話題になるEmacs Lispをチェック
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 28
- 29. Emacs Now
• 個々のPCの処理能力の向上によって、そ
のリソースを有効に使ったEmacs Lispが
登場している。
–quot;情報の集約quot;がキーワード
• 候補選択
• 補完/自動挿入
• 自動生成/自動チェック
–Emacsの特殊なキーバインド(Ctrl+a、
Ctrl+x sなど※)の解消を目指すものも多い
–ユーザの思考を止めないようにEmacsで処理
を行う
※以下quot;C-xquot;、quot;C-x squot;と書く
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 29
- 30. anything.el
• 候補選択フレームワーク
–Emacs版QuickSilver
–Emacs版Google Suggest
• 何でも候補選択→さまざまな操作
が可能
• 詳しくはid:IMAKADOで
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 30
- 31. auto-complete.el
• 単語補完フレームワーク
– IDEなどでよくあるポップアップ型単語の候補選択
• m2ym謹製
• フレームワークなので、補完候補部分の実装(何を補完
候補にするか)を独自に作成することが可能
• さらに複数の補完候補の集約が可能
(de|
defun
defva
defvar
defadvice
define-key
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 31
- 33. key-chord.el
• キーバインド拡張
– quot;キー同時押しquot;やquot;キー連続押しquot;をキーバインドとし
て使用することができる
• quot;C-aquot;やquot;C-x aquot;だけではなくquot;aaquot;や ”hj同時押し”
も使える
– 内部的には2つキーの押す時間を測定し、ある閾値以
下だったら同時押しや連続押しと判定する
• キーを押すたびに処理が走るが、特に体感速度は
変わらない
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 33
- 35. smartchr.el
• キー入力拡張
–id:IMAKADO謹製
–例えばquot;=quot;キーを押したときに、quot;=quot;
キーの連続入力回数によってquot; = quot;,quot; ==
quot;,quot; === quot;,quot;=quot;とトグルで入力できるよ
うな設定が可能
•ソースコードを書くときに楽
–元ネタ:smartchr.vim
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 35
- 37. sequential-command.el
• コマンド入力拡張
–id:rubikitch謹製
–例えばquot;C-aquot;を押したときに、quot;C-aquot;の連続入
力回数によってquot;行頭へ移動quot;,quot;バッファの先頭
に移動quot;,quot;元の場所に移動quot;とトグルでコマンド
実行できるような設定が可能
•楽
–つい今週にリリースアナウンス
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 37
- 39. for Emacs Lisp Beginner
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 39
- 40. Emacs Lisp
• Emacsを拡張できるLisp言語
• 今回紹介した拡張は全てEmacs
Lispで書かれている
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 40
- 41. 例:smartchr.el
(eval-when-compile (require 'cl))
(defun smartchr (list-of-string)
(lexical-let ((los list-of-string)
(last-word quot;quot;)
(count 0))
(lambda ()
(interactive)
(if (eq this-command real-last-command)
(incf count)
(setq count 0))
(when (>= count (length los))
(setq count 0))
(let ((word (nth count los)))
(when (eq this-command real-last-command)
(delete-backward-char (length last-word)))
(setq last-word word)
(insert word)))))
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 41
- 45. 括弧は空気だ。
by id:hayamiz from tokyo-emacs
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 45
- 46. Emacs Lisp Sample
(message quot;hello worldquot;)
messageという関数を
引数quot;hello worldquot;で
評価する。(メッセージバッファにquot;hello worldquot;を表示)
返り値はquot;hello worldquot;。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 46
- 47. Emacs Lisp Sample
(message (concat quot;helloquot; quot;worldquot;))
concatという関数を
引数quot;helloquot;とquot;worldquot;で
評価する。 (文字列を連結)
返り値はquot;hello worldquot;。
その返り値をmessageという関数に引数として渡して
評価する。(メッセージバッファにquot;hello worldquot;を表示)
返り値はquot;hello worldquot;。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 47
- 48. Emacs Lisp Sample
(defvar hoge quot;helloquot;)
hogeという変数を定義。
初期値は文字列quot;helloquot;。
(setq hoge quot;worldquot;)
hogeという変数に文字列quot;worldquot;を設定。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 48
- 49. Emacs Lisp Sample
(defun myfunc()
(interactive)
(...))
myfuncという関数を定義。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 49
- 50. Emacs Lisp
• 関数を評価してその返り値をその
まま他の関数の引き数として使っ
て・・・と書ける言語
–少なくともPHPとはまったく違う
言語仕様
–むしろJavaScript的(jQueryのメ
ソッドチェーンなど)
• 本当はもっと似ている言語があるのだけれども、
他はあまり触ったことがないので・・・
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 50
- 51. Emacs Lisp
• 覚えると直接開発環境の拡張につな
がる。
• 再帰、無名関数などに強くなる。
–clパッケージを使えばクロージャもわか
る。
• 残念ながらEmacsの設定を書く上で
Emacs Lispはなかなか縁が切れない
• custamize-*系があるけどもdefcustomしていないEmacs Lispも多
くある
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 51
- 52. for Emacs Lisp Beginner
• Emacs Lisp(Lisp)に触れたことのない人
が感覚としてつかむことはquot;括弧は空気quot;の
み
–quot;S式quot;とかquot;シンボルquot;とかquot;リストquot;とか難しい
ことの理解はあとからついてくる
• Emacs LispはWeb上の日本語ドキュメン
トも充実している
–Emacs Lisp プログラミング
–GNU Emacs Lisp リファレンスマニュアル
–上記2つを学ぶことで大抵のことはできるよ
うになる。
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 52
- 53. for Emacs Lisp Beginner
• 大抵のやりたいことを実現するた
めのライブラリはある。
–主にEmacsWiki (CPAN並み?)
–install-elisp.elとかauto-install.el
で一発インストール
–anything.elやauto-complete.elの
sourceをつくるのも面白い
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 53
- 55. #emacs-lisp-ja@irc.freenode.net
• id:IMAKADOの声かけでつい今週
はじまったIRCチャンネル
• Emacs Lispの話ができたらおも
しろい
• 既に猛者が参加中
• 主に自分の質問先にしたい
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 55
- 56. Let's enjoy Emacs
& Emacs Lisp!!
-uuu:---F1 fukuoka-emacs #x02 2009.2.21 All(1,0) (Emacs-Lisp ppt)--------- 56