From: Satyaki Das Date: Sun, 23 Oct 2005 22:34:34 +0000 (+0000) Subject: * mh-identity.el (mh-assoc-ignore-case): New macro that uses X-Git-Tag: emacs-pretest-22.0.90~6366 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1dd9796d2b9359b7a8138a3ff95d6afed63e15c1;p=emacs.git * mh-identity.el (mh-assoc-ignore-case): New macro that uses assoc-string (if the function is available) and falls back on assoc-ignore-case if assoc-string is not found. (mh-identity-field-handler): Use mh-assoc-ignore-case since assoc-ignore-case is a obsolete function in Emacs 22. * mh-e.el (mh-folder-buttons-init-flag): New variable that keeps track of whether the tool-bar in mh-folder-mode has been initialized yet. (mh-folder-mode): Initialize the tool-bar for folders the first time we get into mh-letter-mode. * mh-customize.el (mh-buffer-exists-p): New function which tests presence of buffers of a given mode. (mh-tool-bar-define): New functions mh-tool-bar-folder-buttons-init and mh-tool-bar-letter-buttons-init are defined. These functions are used to create the tool-bar from the corresponding customizable variables. * mh-comp.el (mh-letter-buttons-init-flag): New variable that keeps track of whether the tool-bar in mh-letter-mode has been initialized yet. (mh-letter-mode): Initialize the tool-bar for drafts the first time we get into mh-letter-mode. --- diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index b3434f6d001..bf8b6be9437 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog @@ -1,3 +1,31 @@ +2005-10-23 Satyaki Das + + * mh-identity.el (mh-assoc-ignore-case): New macro that uses + assoc-string (if the function is available) and falls back on + assoc-ignore-case if assoc-string is not found. + (mh-identity-field-handler): Use mh-assoc-ignore-case since + assoc-ignore-case is a obsolete function in Emacs 22. + + * mh-e.el (mh-folder-buttons-init-flag): New variable that keeps + track of whether the tool-bar in mh-folder-mode has been + initialized yet. + (mh-folder-mode): Initialize the tool-bar for folders the first + time we get into mh-letter-mode. + + * mh-customize.el (mh-buffer-exists-p): New function which tests + presence of buffers of a given mode. + (mh-tool-bar-define): New functions + mh-tool-bar-folder-buttons-init and + mh-tool-bar-letter-buttons-init are defined. These functions are + used to create the tool-bar from the corresponding customizable + variables. + + * mh-comp.el (mh-letter-buttons-init-flag): New variable that + keeps track of whether the tool-bar in mh-letter-mode has been + initialized yet. + (mh-letter-mode): Initialize the tool-bar for drafts the first + time we get into mh-letter-mode. + 2005-10-23 Bill Wohler * mh-comp.el (mh-letter-menu): Rename diff --git a/lisp/mh-e/mh-comp.el b/lisp/mh-e/mh-comp.el index 6d26fae36a5..be39bd4c528 100644 --- a/lisp/mh-e/mh-comp.el +++ b/lisp/mh-e/mh-comp.el @@ -871,6 +871,8 @@ work better in MH-Letter mode." (defvar tool-bar-mode) (defvar tool-bar-map)) +(defvar mh-letter-buttons-init-flag nil) + ;;;###autoload (define-derived-mode mh-letter-mode text-mode "MH-Letter" "Mode for composing letters in MH-E.\\ @@ -897,6 +899,10 @@ When a message is composed, the hooks `text-mode-hook' and (make-local-variable 'mh-previous-window-config) (make-local-variable 'mh-sent-from-folder) (make-local-variable 'mh-sent-from-msg) + (mh-do-in-gnu-emacs + (unless mh-letter-buttons-init-flag + (mh-tool-bar-letter-buttons-init) + (setq mh-letter-buttons-init-flag t))) ;; Set the local value of mh-mail-header-separator according to what is ;; present in the buffer... (set (make-local-variable 'mh-mail-header-separator) diff --git a/lisp/mh-e/mh-customize.el b/lisp/mh-e/mh-customize.el index 29a6c62e753..2255bdad2d6 100644 --- a/lisp/mh-e/mh-customize.el +++ b/lisp/mh-e/mh-customize.el @@ -1673,6 +1673,14 @@ and the default-toolbar." (const :tag "Don't use a toolbar" nil)) :group 'mh-toolbar)) +(defun mh-buffer-exists-p (mode) + "Test whether a buffer with major mode MODE is present." + (loop for buf in (buffer-list) + when (save-excursion + (set-buffer buf) + (eq major-mode mode)) + return t)) + (defmacro mh-tool-bar-define (defaults &rest buttons) "Define a tool bar for MH-E. DEFAULTS is the list of buttons that are present by default. It is a list of @@ -1804,33 +1812,42 @@ where, (defvar mh-letter-tool-bar-map nil) ;; GNU Emacs tool bar specific code (mh-do-in-gnu-emacs + ;; Tool bar initialization functions + (defun mh-tool-bar-folder-buttons-init () + (when (mh-buffer-exists-p 'mh-folder-mode) + (mh-image-load-path) + (setq mh-folder-tool-bar-map + (let ((tool-bar-map (make-sparse-keymap))) + ,@(nreverse folder-button-setter) + tool-bar-map)) + (setq mh-show-tool-bar-map + (let ((tool-bar-map (make-sparse-keymap))) + ,@(nreverse show-button-setter) + tool-bar-map)) + (setq mh-show-seq-tool-bar-map + (let ((tool-bar-map (copy-keymap mh-show-tool-bar-map))) + ,@(nreverse show-seq-button-setter) + tool-bar-map)) + (setq mh-folder-seq-tool-bar-map + (let ((tool-bar-map (copy-keymap mh-folder-tool-bar-map))) + ,@(nreverse sequence-button-setter) + tool-bar-map)))) + (defun mh-tool-bar-letter-buttons-init () + (when (mh-buffer-exists-p 'mh-letter-mode) + (mh-image-load-path) + (setq mh-letter-tool-bar-map + (let ((tool-bar-map (make-sparse-keymap))) + ,@(nreverse letter-button-setter) + tool-bar-map)))) ;; Custom setter functions (defun mh-tool-bar-folder-buttons-set (symbol value) "Construct toolbar for `mh-folder-mode' and `mh-show-mode'." (set-default symbol value) - (setq mh-folder-tool-bar-map - (let ((tool-bar-map (make-sparse-keymap))) - ,@(nreverse folder-button-setter) - tool-bar-map)) - (setq mh-show-tool-bar-map - (let ((tool-bar-map (make-sparse-keymap))) - ,@(nreverse show-button-setter) - tool-bar-map)) - (setq mh-show-seq-tool-bar-map - (let ((tool-bar-map (copy-keymap mh-show-tool-bar-map))) - ,@(nreverse show-seq-button-setter) - tool-bar-map)) - (setq mh-folder-seq-tool-bar-map - (let ((tool-bar-map (copy-keymap mh-folder-tool-bar-map))) - ,@(nreverse sequence-button-setter) - tool-bar-map))) + (mh-tool-bar-folder-buttons-init)) (defun mh-tool-bar-letter-buttons-set (symbol value) "Construct toolbar for `mh-letter-mode'." (set-default symbol value) - (setq mh-letter-tool-bar-map - (let ((tool-bar-map (make-sparse-keymap))) - ,@(nreverse letter-button-setter) - tool-bar-map)))) + (mh-tool-bar-letter-buttons-init))) ;; XEmacs specific code (mh-do-in-xemacs (defvar mh-toolbar-folder-vector-map diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el index c0b57ee56ca..283499b2c66 100644 --- a/lisp/mh-e/mh-e.el +++ b/lisp/mh-e/mh-e.el @@ -1507,6 +1507,8 @@ is used in previous versions and XEmacs." (not (member 'mh-folder-mode which-func-modes))) (push 'mh-folder-mode which-func-modes)) +(defvar mh-folder-buttons-init-flag nil) + ;; Autoload cookie needed by desktop.el ;;;###autoload (define-derived-mode mh-folder-mode fundamental-mode "MH-Folder" @@ -1560,8 +1562,10 @@ MH-Folder buffer, then the MH-E command will perform the operation on all messages in that region. \\{mh-folder-mode-map}" - - (mh-image-load-path) + (mh-do-in-gnu-emacs + (unless mh-folder-buttons-init-flag + (mh-tool-bar-folder-buttons-init) + (setq mh-folder-buttons-init-flag t))) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(mh-folder-font-lock-keywords t)) (make-local-variable 'desktop-save-buffer) diff --git a/lisp/mh-e/mh-identity.el b/lisp/mh-e/mh-identity.el index c3f34ae75b2..1e7c8035734 100644 --- a/lisp/mh-e/mh-identity.el +++ b/lisp/mh-e/mh-identity.el @@ -118,13 +118,20 @@ Return t if anything is deleted." (defvar mh-identity-signature-end nil "Marker for the end of a signature inserted by `mh-insert-identity'.") +(defmacro mh-assoc-ignore-case (key alist) + "Compatibility macro for emacs versions that lack `assoc-string'. +Check if KEY is present in ALIST while ignoring case to do the comparison." + (if (fboundp 'assoc-string) + `(assoc-string ,key ,alist t) + `(assoc-ignore-case ,key ,alist))) + (defun mh-identity-field-handler (field) "Return the handler for header FIELD or nil if none set. The field name is downcased. If the FIELD begins with the character `:', then it must have a special handler defined in `mh-identity-handlers', else return an error since it is not a valid header field." - (or (cdr (assoc-ignore-case field mh-identity-handlers)) + (or (cdr (mh-assoc-ignore-case field mh-identity-handlers)) (and (eq (aref field 0) ?:) (error "Field %s - unknown mh-identity-handler" field)) (cdr (assoc ":default" mh-identity-handlers))