2008/02/02
Emacs で lambda をかわいくする
元ネタは http://www.emacswiki.org/cgi-bin/wiki/PrettyLambda です。
Lisp の lambda という文字列は読むにはかなり冗長なので λ のようにかわいく表示して可読性を向上しようという試みです。
以下のコードを ~/.emacs に記述するだけです。
(defun set-pretty-patterns (patterns) (loop for (glyph . pairs) in patterns do (loop for (regexp . major-modes) in pairs do (loop for major-mode in major-modes do (let ((major-mode (intern (concat (symbol-name major-mode) "-mode"))) (n (if (string-match "\\\\([^?]" regexp) 1 0))) (font-lock-add-keywords major-mode `((,regexp (0 (prog1 () (compose-region (match-beginning ,n) (match-end ,n) ,glyph))))))))))) (set-pretty-patterns '((?λ ("\\<lambda\\>" lisp lisp-interaction emacs-lisp scheme))))
こんな感じになります。

最近入社した大先生 Sugawara さんによる Big lambda もなかなかイカス(*)。
(*) EmacsWiki の下のほうにソースがあります

- Category(s)
- emacs
- The URL to Trackback this entry is:
- http://dev.ariel-networks.com/Members/matsuyama/pretty-lambda-in-emacs/tbping
Re:Emacs で lambda をかわいくする
Posted by
elim
at
2008-02-02 17:50
loop 使うなら (require 'cl) しておかないと、ですね。