]> git.eshelyaron.com Git - emacs.git/commitdiff
* mh-tool-bar.el (image-load-path): Define to shush compiler.
authorBill Wohler <wohler@newt.com>
Fri, 21 Apr 2006 01:32:16 +0000 (01:32 +0000)
committerBill Wohler <wohler@newt.com>
Fri, 21 Apr 2006 01:32:16 +0000 (01:32 +0000)
(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.

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

index da5867d97b488d214a41e34ce907787f998c4436..89ca1dc04aacd2de4de6bc9f240a7bcd44bd8692 100644 (file)
@@ -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
index 8516856f14eb1bf5197fd1f0f9d8d376f1a45d05..282bc1184390ad31154f07574483a109305ee121 100644 (file)
@@ -524,11 +524,8 @@ font-lock is done highlighting.")
 ;; 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 @@ perform the operation on all messages in that region.
 
 \\{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))
index 2da824c34c23e529ec16956f7a7cf0f5c1b36cda..9445b5ea41ffe6fc0174aab72cacfac00fc4f9c3 100644 (file)
@@ -275,10 +275,7 @@ searching for `mh-mail-header-separator' in the buffer."
 
 ;;; 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 @@ order).
   (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))
index ae260692b74e84174099a1bfa8f7b36da6f8ba05..6d15739fe4de03ae2c4a627b6f1047592a6288f1 100644 (file)
@@ -238,8 +238,7 @@ When you want to widen the view to all your messages again, use
                (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 @@ remove all limits and sequence restrictions."
   (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)))))
 
 \f
index 3cd043d4a7ef7f9795b06c99561c3b3d8a02c7dc..9b18848bd12915032e5af66bf0c737735a8838cc 100644 (file)
@@ -83,6 +83,9 @@ When INCLUDE-FLAG is non-nil, include message body being replied to."
 
 ;;; 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 @@ where,
                                     (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 @@ where,
       (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