うーむ、まだまだ続くな。。。
(0) mew-nmz とかで、検索したキーをメッセージ中でハイライト表示します。
(1) ある程度自動に引数を処理します。これ以上は勘弁。
(2) "kk" を押すと regexp を変更できます。
やめたいときは "kk" で "" を入力。"prefix kk" でも OK。
(3) mew-summary-find-keyword-down|up() と同じ local 変数を使って
いるので、M-n, M-p が変なときも同様に "kk" で修正します。
ちなみに、最初にキーを聞いてくれなくなります。
(4) defadvice で呼んでいる mew-message-highlight-keyword-get()
の引数はお使いのものに変えてください。
といった感じ。
(defface mew-message-highlight-keyword-face
'((((class color) (background light))
(:background "dark khaki" :bold t :underline t))
(((class color) (background dark))
(:background "blue" :bold t :underline t))
(t (:bold t :underline t)))
"*Face of mew-message-highlight-keyword."
:group 'mew-highlight)
(add-hook 'mew-summary-mode-hook
(lambda ()
(define-key mew-summary-mode-map "kk" 'mew-message-highlight-keyword-set)))
(defun mew-message-highlight-keyword-set (&optional args)
(interactive "P")
(when (mew-summary-or-virtual-p)
(if args
(progn
(mew-sinfo-set-find-key nil)
(message "Reset highlight keyword")
(and (mew-sinfo-get-disp-msg)
(mew-summary-display 'redisplay)))
(let* ((hist (copy-sequence mew-input-pick-pattern-hist))
(key (read-string "Keyword: "
(or (mew-sinfo-get-find-key)
(car mew-input-pick-pattern-hist))
'hist)))
(if (string= key "")
(mew-sinfo-set-find-key nil)
(mew-sinfo-set-find-key key))
(and (mew-sinfo-get-disp-msg)
(mew-summary-display 'redisplay))))))
(defadvice mew-nmz-search-mark (after keyword-get activate)
(mew-message-highlight-keyword-get 'namazu))
(defadvice mew-nmz-virtual (after keyword-get activate)
(when (mew-virtual-p)
(mew-message-highlight-keyword-get 'namazu)))
(defadvice mew-summary-pick-mark (after keyword-get activate)
(mew-message-highlight-keyword-get 'mew))
(defadvice mew-summary-grep-mark (after keyword-get activate)
(mew-message-highlight-keyword-get 'grep))
;; (mew-message-highlight-keyword-get 'mew))
(defadvice mew-summary-virtual-with-internal (after keyword-get activate)
(when (mew-virtual-p)
(mew-message-highlight-keyword-get 'mew)))
(defadvice mew-summary-virtual-with-external (after keyword-get activate)
(when (mew-virtual-p)
(mew-message-highlight-keyword-get 'grep)))
;; (mew-message-highlight-keyword-get 'mew)))
(defun mew-message-highlight-keyword-get (type)
(let* ((key (car mew-input-pick-pattern-hist))
(keys (mew-split key ? ))
regex)
(cond
((eq type 'namazu)
(let ((frags '("(" ")" "and" "or" "not")))
(while frags
(setq keys (delete (car frags) keys))
(setq frags (cdr frags)))
(setq regex (regexp-opt (mapcar
(lambda (x)
(if (string-match "^\\+[^:]+:\\(.+\\)$" x)
(setq x (match-string 1 x)))
(if (string-match "^[\"{]?\\(.+\\)[\"}]?$" x)
(setq x (match-string 1 x)))
(let (tmp)
(while (string-match "\\*" x)
(setq tmp (concat tmp (substring x 0 (match-beginning 0))))
(setq x (substring x (match-end 0))))
(setq tmp (concat tmp x))
(setq x tmp))
(regexp-quote x))
keys)))))
((eq type 'mew)
(let ((frags '("(" ")" "&" "|" "!")))
(while frags
(setq keys (delete (car frags) keys))
(setq frags (cdr frags)))
(setq regex (regexp-opt (mapcar
(lambda (x)
(cond
((string-match "!?==?\\(.+\\)$" x)
(regexp-quote (match-string 1 x)))
((string-match "^(?\\(.+\\))?$" x)
(regexp-quote (match-string 1 x)))
(t
(regexp-quote x))))
keys)))))
(t ;; 'grep
(setq regex key)))
(if (or (not regex) (string= regex ""))
(mew-sinfo-set-find-key nil)
(mew-sinfo-set-find-key regex))))
(defun mew-message-highlight-keyword ()
(let ((buf (mew-minfo-get-summary))
key)
(when (and buf (buffer-name (get-buffer buf)))
(save-excursion
(set-buffer buf)
(setq key (mew-sinfo-get-find-key)))
(when key
(save-excursion
(goto-char (or (mew-header-end) (point-min)))
(while (re-search-forward key
(min (point-max) mew-highlight-body-max-size)
t)
(put-text-property (match-beginning 0) (match-end 0)
'face 'mew-message-highlight-keyword-face)))))))
(add-hook 'mew-message-hook 'mew-message-highlight-keyword)
日曜日、今年最初の野球の練習。練習終了後、仲間の自宅で飲んだのだが、近来稀に見るレベルの大酔っぱらいになってしまった。
月曜日に行ってきた。有料だけあって、おしゃれだ。会員になるかどうかは不明。