- 行頭に"*"か"**"を挿入するキーバインドを設定
- 行頭が"**"か"***"ならその行だけ色を変える
ということをしていた。
そのときは.xyzzyに直接記述するという仕方だったが、拡張Lispにしてrequireする方がすっきりしていいのではないかとおもい、書き直してみる。
hatena-kihou.l
; -*- Mode: Lisp -*-
;
;; はてな記法の見出しの実装(色づけとキーバインド)
;;
;; 行頭が"**"か"***"ならばその行に色をつける
;;
;; キーバインド
;; C-: 行頭に**を付ける
;; C-] 行頭に*を付ける
;;
;; Installation:
;;
;; ~/.xyzzy または $XYZZY/site-lisp/siteinit.l に以下のコードを追加
;;
;; (require "hatena-kihou")
(defun hateda-heading ()
(interactive "*")
(save-excursion
(goto-bol)
(insert "**")
(fix-selection-point)))
(global-set-key #\C-: 'hateda-heading)
(defun hateda-headingsec ()
(interactive "*")
(save-excursion
(goto-bol)
(insert "*")
(fix-selection-point)))
(global-set-key #\C-] 'hateda-headingsec)
(defvar *text-mode-formats*
(compile-regexp-keyword-list
'(
("^[=].*" t (:color 14 7 :line :bold ))
("^[*][*][^*].*" t (:color 7 4 :line ))
("^[*][*][*][^*].*" t (:color 7 14 :line ))
)
)
)
(defun my-color-text-mode ()
(make-local-variable 'regexp-keyword-list)
(setq regexp-keyword-list *text-mode-formats*)
)
(setq regexp-keyword-list *text-mode-formats*)
(add-hook 'text-mode-hook 'my-color-text-mode)
これをsite-lispフォルダに保存。
あとは.xyzzyかsite-lisp.lに
(require "hatena-kihou")
をコピペすればいいです。
前の記事から細かいところは多少変えたけれど、基本はだいたい同じ。
キーバインドは、
- C-: → 行頭に**を付ける
- C-] → 行頭に*を付ける
色はデフォルトだと次のようになる。

0 件のコメント:
コメントを投稿