Emacs part3

このエントリーをはてなブックマークに追加
365名無しさん@お腹いっぱい。
>>364
hilit を font-lock で書き換える。

(require 'font-lock)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(tdf-font-lock-keywords t))
(font-lock-mode 1)

なんてのを適当な hook にひっかけつつこんなカンジで。

(defgroup tdf-faces nil
"TomSoft Diary File, Faces."
:prefix "tdf-"
:group 'tdf)

(defface tdf-cat-face '((t (:foreground "purple" :bold t)))
"Faces used for CAT."
:group 'tdf-faces)

(defface tdf-new-face '((t (:foreground "purple" :bold t)))
"Faces used for NEW, SNEW, NEW*."
:group 'tdf-faces)

(defface tdf-sub-face '((t (:foreground "purple")))
"Faces used for SUB, SSUB, SUB*."
:group 'tdf-faces)

(defface tdf-link-face '((t (:foreground "blue")))
"Faces used for link command."
:group 'tdf-faces)

(defface tdf-comment-face '((t (:foreground "firebrick")))
"Faces used for comment."
:group 'tdf-faces)

(defface tdf-strong-face '((t (:bold t)))
"Faces used for STRONG, EM."
:group 'tdf-faces)


(defvar tdf-font-lock-keywords
'(("^S?NEW .*" . tdf-new-face)
("^S?NEW\\*" . tdf-new-face)
("^S?SUB\\*? .*" . tdf-sub-face)
("^S?SUB\\*" . tdf-sub-face)
("^CAT .*" . tdf-cat-face)
("^\\(!\\|!#\\).*" . tdf-comment-face)
("^\\(LINK\\|URL\\)[ \t]+\\([^ \t]+[ \t]+[^ \t]+\\)"
1 tdf-link-face)
("^\\(URL\\|LINK\\|NEW\\*\\|SUB\\*\\)[ \t]+\\([^ \t\n]+\\)"
2 tdf-link-face))
"font-lock keyword of tdf-mode.")

パターンや色は適当にいじってくれ。要ハサミだ。61!