changeset 70145:00cb3fe5fed5

* mh-tool-bar.el (image-load-path): Define to shush compiler. (mh-buffer-exists-p): Move inside mh-do-in-gnu-emacs since it isn't used outside of it. (mh-tool-bar-folder-buttons-init, mh-tool-bar-letter-buttons-init): Update load-path/image-load-path before setting buttons. This code used to be in mh-folder-mode/mh-letter-mode but this was the wrong place since mh-tool-bar-*-buttons-init can also be called when customizing the buttons. (mh-tool-bar-update): New function which updates tool-bar-map in all of the MH-E buffers after customizing the buttons (closes SF #1452718). (mh-tool-bar-folder-buttons-set, mh-tool-bar-letter-buttons-set): Call it (closes SF #1452718). * mh-folder.el (mh-folder-buttons-init-flag): Delete. Use mh-folder-tool-bar-map instead. (image-load-path): Delete. No longer used. (mh-folder-mode): Moved setting of image-load-path into mh-tool-bar-folder-buttons-init. * mh-letter.el (mh-letter-buttons-init-flag): Delete. Use mh-letter-tool-bar-map instead. (image-load-path): Delete. No longer used. (mh-letter-mode): Moved setting of image-load-path into mh-tool-bar-letter-buttons-init. * mh-seq.el (mh-narrow-to-seq, mh-widen): Use with-current-buffer instead of set-buffer.
author Bill Wohler <wohler@newt.com>
date Fri, 21 Apr 2006 01:32:16 +0000
parents 60a94b1ec37e
children 2cd7cafcba54
files lisp/mh-e/ChangeLog lisp/mh-e/mh-folder.el lisp/mh-e/mh-letter.el lisp/mh-e/mh-seq.el lisp/mh-e/mh-tool-bar.el
diffstat 5 files changed, 101 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mh-e/ChangeLog	Thu Apr 20 23:35:08 2006 +0000
+++ b/lisp/mh-e/ChangeLog	Fri Apr 21 01:32:16 2006 +0000
@@ -1,3 +1,35 @@
+2006-04-20  Bill Wohler  <wohler@newt.com>
+
+	* mh-tool-bar.el (image-load-path): Define to shush compiler.
+	(mh-buffer-exists-p): Move inside mh-do-in-gnu-emacs since it
+	isn't used outside of it.
+	(mh-tool-bar-folder-buttons-init,
+	mh-tool-bar-letter-buttons-init): Update load-path/image-load-path
+	before setting buttons. This code used to be in
+	mh-folder-mode/mh-letter-mode but this was the wrong place since
+	mh-tool-bar-*-buttons-init can also be called when customizing the
+	buttons.
+	(mh-tool-bar-update): New function which updates tool-bar-map in
+	all of the MH-E buffers after customizing the buttons (closes SF
+	#1452718).
+	(mh-tool-bar-folder-buttons-set, mh-tool-bar-letter-buttons-set):
+	Call it (closes SF #1452718).
+
+	* mh-folder.el (mh-folder-buttons-init-flag): Delete. Use
+	mh-folder-tool-bar-map instead.
+	(image-load-path): Delete. No longer used.
+	(mh-folder-mode): Moved setting of image-load-path into
+	mh-tool-bar-folder-buttons-init.
+
+	* mh-letter.el (mh-letter-buttons-init-flag): Delete. Use
+	mh-letter-tool-bar-map instead.
+	(image-load-path): Delete. No longer used.
+	(mh-letter-mode): Moved setting of image-load-path into
+	mh-tool-bar-letter-buttons-init.
+
+	* mh-seq.el (mh-narrow-to-seq, mh-widen): Use with-current-buffer
+	instead of set-buffer.
+
 2006-04-19  Bill Wohler  <wohler@newt.com>
 
 	* mh-tool-bar.el (mh-tool-bar-define): Fix enable-expr so that one
--- a/lisp/mh-e/mh-folder.el	Thu Apr 20 23:35:08 2006 +0000
+++ b/lisp/mh-e/mh-folder.el	Fri Apr 21 01:32:16 2006 +0000
@@ -524,11 +524,8 @@
 ;; Shush compiler.
 (defvar desktop-save-buffer)
 (defvar font-lock-auto-fontify)
-(defvar image-load-path)
 (defvar font-lock-defaults)             ; XEmacs
 
-(defvar mh-folder-buttons-init-flag nil)
-
 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
 (put 'mh-folder-mode 'mode-class 'special)
 
@@ -590,13 +587,8 @@
 
 \\{mh-folder-mode-map}"
   (mh-do-in-gnu-emacs
-    (unless mh-folder-buttons-init-flag
-      (let* ((load-path (mh-image-load-path-for-library "mh-e" "mh-logo.xpm"))
-             (image-load-path (cons (car load-path)
-                                    (when (boundp 'image-load-path)
-                                      image-load-path))))
-        (mh-tool-bar-folder-buttons-init)
-        (setq mh-folder-buttons-init-flag t)))
+    (unless mh-folder-tool-bar-map
+        (mh-tool-bar-folder-buttons-init))
     (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map))
   (mh-do-in-xemacs
     (mh-tool-bar-init :folder))
--- a/lisp/mh-e/mh-letter.el	Thu Apr 20 23:35:08 2006 +0000
+++ b/lisp/mh-e/mh-letter.el	Fri Apr 21 01:32:16 2006 +0000
@@ -275,10 +275,7 @@
 
 ;;; MH-Letter Mode
 
-(defvar mh-letter-buttons-init-flag nil)
-
 ;; Shush compiler.
-(defvar image-load-path)
 (defvar font-lock-defaults)             ; XEmacs
 
 ;; Ensure new buffers won't get this mode if default-major-mode is nil.
@@ -313,13 +310,8 @@
   (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
-      (let* ((load-path (mh-image-load-path-for-library "mh-e" "mh-logo.xpm"))
-             (image-load-path (cons (car load-path)
-                                    (when (boundp 'image-load-path)
-                                      image-load-path))))
-        (mh-tool-bar-letter-buttons-init)
-        (setq mh-letter-buttons-init-flag t)))
+    (unless mh-letter-tool-bar-map
+      (mh-tool-bar-letter-buttons-init))
     (set (make-local-variable 'tool-bar-map) mh-letter-tool-bar-map))
   (mh-do-in-xemacs
     (mh-tool-bar-init :letter))
--- a/lisp/mh-e/mh-seq.el	Thu Apr 20 23:35:08 2006 +0000
+++ b/lisp/mh-e/mh-seq.el	Fri Apr 21 01:32:16 2006 +0000
@@ -238,8 +238,7 @@
                (set (make-local-variable 'tool-bar-map)
                     mh-folder-seq-tool-bar-map)
                (when (buffer-live-p (get-buffer mh-show-buffer))
-                 (save-excursion
-                   (set-buffer (get-buffer mh-show-buffer))
+                 (with-current-buffer mh-show-buffer
                    (set (make-local-variable 'tool-bar-map)
                         mh-show-seq-tool-bar-map))))
              (push 'widen mh-view-ops)))
@@ -371,8 +370,7 @@
   (when (and (null mh-folder-view-stack) (boundp 'tool-bar-mode) tool-bar-mode)
     (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)
     (when (buffer-live-p (get-buffer mh-show-buffer))
-      (save-excursion
-        (set-buffer (get-buffer mh-show-buffer))
+      (with-current-buffer mh-show-buffer
         (set (make-local-variable 'tool-bar-map) mh-show-tool-bar-map)))))
 
 
--- a/lisp/mh-e/mh-tool-bar.el	Thu Apr 20 23:35:08 2006 +0000
+++ b/lisp/mh-e/mh-tool-bar.el	Fri Apr 21 01:32:16 2006 +0000
@@ -83,6 +83,9 @@
 
 ;;; Tool Bar Creation
 
+;; Shush compiler.
+(defvar image-load-path)
+
 (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
@@ -178,7 +181,7 @@
                                     (t 'folder-vectors)))
                  (list (cond ((eq type :letter) 'mh-tool-bar-letter-buttons)
                              (t 'mh-tool-bar-folder-buttons)))
-                 (key (intern (concat "mh-" type1 "tool-bar-" name-str)))
+                 (key (intern (concat "mh-" type1 "-tool-bar-" name-str)))
                  (setter (intern (concat type1 "-button-setter")))
                  (mbuttons (cond ((eq type :letter) 'letter-buttons)
                                  ((eq type :show) 'show-buttons)
@@ -209,50 +212,79 @@
       (unless (memq x letter-buttons)
         (error "Letter defaults contains unknown button %s" x)))
     `(eval-when (compile load eval)
-       (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))
-
        ;; GNU Emacs tool bar specific code
        (mh-do-in-gnu-emacs
+         (defun mh-buffer-exists-p (mode)
+           "Test whether a buffer with major mode MODE is present."
+           (loop for buf in (buffer-list)
+                 when (with-current-buffer buf
+                        (eq major-mode mode))
+                 return t))
          ;; Tool bar initialization functions
          (defun mh-tool-bar-folder-buttons-init ()
            (when (mh-buffer-exists-p 'mh-folder-mode)
-             (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))))
+             (let* ((load-path (mh-image-load-path-for-library "mh-e"
+                                                               "mh-logo.xpm"))
+                    (image-load-path (cons (car load-path)
+                                           (when (boundp 'image-load-path)
+                                             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-folder-seq-tool-bar-map
+                     (let ((tool-bar-map (copy-keymap mh-folder-tool-bar-map)))
+                       ,@(nreverse sequence-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)))))
          (defun mh-tool-bar-letter-buttons-init ()
            (when (mh-buffer-exists-p 'mh-letter-mode)
-             (setq mh-letter-tool-bar-map
-                   (let ((tool-bar-map (make-sparse-keymap)))
-                     ,@(nreverse letter-button-setter)
-                     tool-bar-map))))
+             (let* ((load-path (mh-image-load-path-for-library "mh-e"
+                                                               "mh-logo.xpm"))
+                    (image-load-path (cons (car load-path)
+                                           (when (boundp 'image-load-path)
+                                             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-update (mode default-map sequence-map)
+           "Update `tool-bar-map' in all buffers of MODE.
+Use SEQUENCE-MAP if display is limited; DEFAULT-MAP otherwise."
+           (loop for buf in (buffer-list)
+                 do (with-current-buffer buf
+                      (if (eq mode major-mode)
+                          (let ((map (if mh-folder-view-stack
+                                         sequence-map
+                                       default-map)))
+                            ;; Yes, make-local-variable is necessary since we
+                            ;; get here during initialization when loading
+                            ;; mh-e.el, after the +inbox buffer has been
+                            ;; created, but before mh-folder-mode has run and
+                            ;; created the local map.
+                            (set (make-local-variable 'tool-bar-map) map))))))
          (defun mh-tool-bar-folder-buttons-set (symbol value)
            "Construct tool bar for `mh-folder-mode' and `mh-show-mode'."
            (set-default symbol value)
-           (mh-tool-bar-folder-buttons-init))
+           (mh-tool-bar-folder-buttons-init)
+           (mh-tool-bar-update 'mh-folder-mode mh-folder-tool-bar-map
+                               mh-folder-seq-tool-bar-map)
+           (mh-tool-bar-update 'mh-show-mode mh-show-tool-bar-map
+                               mh-show-seq-tool-bar-map))
          (defun mh-tool-bar-letter-buttons-set (symbol value)
            "Construct tool bar for `mh-letter-mode'."
            (set-default symbol value)
-           (mh-tool-bar-letter-buttons-init)))
+           (mh-tool-bar-letter-buttons-init)
+           (mh-tool-bar-update 'mh-letter-mode mh-letter-tool-bar-map
+                               mh-letter-tool-bar-map)))
        ;; XEmacs specific code
        (mh-do-in-xemacs
          (defvar mh-tool-bar-folder-vector-map