2011年1月31日

[mew-dist 29317]mew の major-mode の無作法?

林と申します。

mew の summary で define-global-minor-mode で定義した minor-mode が
うまく動かないので調べてみると、mew では major-mode を設定する際に
kill-all-local-variables を呼んでいないためのようです。

kill-all-local-variables の help には

> Every function to select a new major mode starts by
> calling this function.

と書いてあるのですが、とりあえず summary バッファを作成したときは必ず
呼んだ方がいいのかもしれません。

また、これを調べている途中で気付いたのですが run-hooks の help によると

> Major modes should not use this function directly to run their mode
> hook; they should use `run-mode-hooks' instead.

run-mode-hooks が定義してあるときはそちらを呼び出すようにした方がいい
かもしれません。なお、この run-mode-hooks は GNU Emacs 22 で導入された
ようです。

上記二点について考慮したパッチを添付しますので、よければご検討ください。

--
Hayashi Masahiro

Content-Disposition: inline; filename="mew.patch"

diff --git a/mew-addrbook.el b/mew-addrbook.el
index c654094..65024db 100644
--- a/mew-addrbook.el
+++ b/mew-addrbook.el
@@ -422,7 +422,7 @@ it will add an alias."
(setq mode-name mname)
(setq mode-line-buffer-identification (mew-mode-line-id))
(use-local-map mew-addrbook-mode-map)
- (run-hooks 'mew-addrbook-mode-hook)
+ (mew-run-mode-hooks 'mew-addrbook-mode-hook)
(setq buffer-undo-list nil))

(defun mew-addrbook-nconc (ent)
diff --git a/mew-draft.el b/mew-draft.el
index c5e8657..6cee36e 100644
--- a/mew-draft.el
+++ b/mew-draft.el
@@ -79,7 +79,7 @@
(mew-tinfo-set-privacy-type nil)
(mew-tinfo-set-use-flowed (mew-use-format-flowed (mew-tinfo-get-case)))
(mew-draft-mode-name) ;; must be after (mew-tinfo-set-encrypted-p encrypted)
- (run-hooks 'text-mode-hook 'mew-draft-mode-hook)
+ (mew-run-mode-hooks 'text-mode-hook 'mew-draft-mode-hook)
;; auto-fill-function is set by mew-draft-mode-hook
(when auto-fill-function
(make-local-variable 'auto-fill-function)
diff --git a/mew-edit.el b/mew-edit.el
index 88926a3..2730429 100644
--- a/mew-edit.el
+++ b/mew-edit.el
@@ -43,7 +43,7 @@ Execute mew-dinfo-set before calling this."
(mew-header-setup-decoration)
(mew-draft-mode-name 'header)
(force-mode-line-update)
- (run-hooks 'mew-header-mode-hook)
+ (mew-run-mode-hooks 'mew-header-mode-hook)
;; auto-fill-function is set by mew-header-mode-hook
(when auto-fill-function
(make-local-variable 'auto-fill-function)
diff --git a/mew-env.el b/mew-env.el
index 78d2af7..d639bb8 100644
--- a/mew-env.el
+++ b/mew-env.el
@@ -276,6 +276,12 @@ requires PTY.")
(defalias 'mew-create-image 'create-animated-image)
(defalias 'mew-create-image 'create-image))

+(if (fboundp 'run-mode-hooks)
+ (defun mew-run-mode-hooks (&rest funcs)
+ (apply 'run-mode-hooks funcs))
+ (defun mew-run-mode-hooks (&rest funcs)
+ (apply 'run-hooks funcs)))
+
(provide 'mew-env)

;;; Copyright Notice:
diff --git a/mew-message.el b/mew-message.el
index 0b0a229..ed00464 100644
--- a/mew-message.el
+++ b/mew-message.el
@@ -35,7 +35,7 @@
(setq page-delimiter mew-page-delimiter)
(mew-message-setup-decoration)
(mew-message-toolbar-update)
- (run-hooks 'mew-message-mode-hook))
+ (mew-run-mode-hooks 'mew-message-mode-hook))

(defun mew-message-mode-line (fld message)
(let* ((msg (or message
diff --git a/mew-summary.el b/mew-summary.el
index 221fda7..7d8b4d6 100644
--- a/mew-summary.el
+++ b/mew-summary.el
@@ -360,7 +360,7 @@ and return (beg . end)."
(mew-summary-setup-mode-line)
(mew-summary-setup-decoration)
(mew-highlight-cursor-line)
- (run-hooks 'mew-summary-mode-hook))
+ (mew-run-mode-hooks 'mew-summary-mode-hook))

(defun mew-summary-kill ()
"Kill this Summary mode."
diff --git a/mew-summary4.el b/mew-summary4.el
index b8361b3..3925f1d 100644
--- a/mew-summary4.el
+++ b/mew-summary4.el
@@ -30,6 +30,7 @@
nil) ;; existing folder
(t
(funcall (or func 'switch-to-buffer) (get-buffer-create case:folder))
+ (kill-all-local-variables)
(mew-set-buffer-cs mew-cs-m17n)
(mew-buffers-setup case:folder)
(let* ((case (mew-case:folder-case case:folder))
diff --git a/mew-virtual.el b/mew-virtual.el
index afdc406..ac5b942 100644
--- a/mew-virtual.el
+++ b/mew-virtual.el
@@ -47,7 +47,7 @@
(mew-summary-setup-mode-line)
(mew-summary-setup-decoration)
(mew-highlight-cursor-line)
- (run-hooks 'mew-virtual-mode-hook))
+ (mew-run-mode-hooks 'mew-virtual-mode-hook))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
diff --git a/mew.el b/mew.el
index 19cae92..888dcde 100644
--- a/mew.el
+++ b/mew.el
@@ -390,6 +390,7 @@ the lower window is not zero, switch to the buffer."
(if (get-buffer msgbuf)
(delete-windows-on msgbuf)
(with-current-buffer (get-buffer-create msgbuf)
+ (kill-all-local-variables)
;; "truncate?" is asked in Message mode.
;; so set the same toolbar as Summary mode
(mew-summary-toolbar-update)

投稿者 xml-rpc : 2011年1月31日 22:27
役に立ちました?:
過去のフィードバック 平均:(0) 総合:(0) 投票回数:(0)
本記事へのTrackback: http://hoop.euqset.org/blog/mt-tb2006.cgi/101660
トラックバック
コメント
コメントする




画像の中に見える文字を入力してください。