emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 76d75df: Remove redundant calls to 'mh-do-in-gnu-emacs'


From: Stefan Kangas
Subject: master 76d75df: Remove redundant calls to 'mh-do-in-gnu-emacs'
Date: Mon, 11 Oct 2021 16:58:40 -0400 (EDT)

branch: master
commit 76d75df8e7ae19c8aca3ab9a7fbee25fc3cf1e9e
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Remove redundant calls to 'mh-do-in-gnu-emacs'
    
    * lisp/mh-e/mh-compat.el (mh-require):
    * lisp/mh-e/mh-folder.el (mh-folder-mode):
    * lisp/mh-e/mh-letter.el (mh-letter-mode):
    * lisp/mh-e/mh-mime.el (mh-mime-button-map)
    (mh-mime-security-button-map, mh-small-image-p)
    (mh-signature-highlight):
    * lisp/mh-e/mh-show.el (mh-show-mode):
    * lisp/mh-e/mh-tool-bar.el (mh-tool-bar-define):
    * lisp/mh-e/mh-utils.el (mh-logo-display)
    (mh-hidden-header-keymap):
    * lisp/mh-e/mh-xface.el (mh-face-display-function)
    (mh-picon-image-types, mh-x-image-display): Remove redundant calls
    to 'mh-do-in-gnu-emacs'.
    * lisp/mh-e/mh-acros.el (mh-do-in-gnu-emacs):
    * lisp/mh-e/mh-tool-bar.el: Add comment explaining an issue that
    stops us from making 'mh-do-in-gnu-emacs' obsolete.
---
 lisp/mh-e/mh-acros.el    |   5 +-
 lisp/mh-e/mh-compat.el   |   4 +-
 lisp/mh-e/mh-folder.el   |   9 ++-
 lisp/mh-e/mh-letter.el   |   9 ++-
 lisp/mh-e/mh-mime.el     |  26 ++++-----
 lisp/mh-e/mh-show.el     |   5 +-
 lisp/mh-e/mh-tool-bar.el | 144 +++++++++++++++++++++++------------------------
 lisp/mh-e/mh-utils.el    |  28 +++++----
 lisp/mh-e/mh-xface.el    |  29 +++++-----
 9 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/lisp/mh-e/mh-acros.el b/lisp/mh-e/mh-acros.el
index 6a03424..3674acc 100644
--- a/lisp/mh-e/mh-acros.el
+++ b/lisp/mh-e/mh-acros.el
@@ -47,7 +47,10 @@
 ;;;###mh-autoload
 (defmacro mh-do-in-gnu-emacs (&rest body)
   "Execute BODY if in GNU Emacs."
-  (declare (debug t) (indent defun))
+  ;; FIXME: This cannot yet be obsoleted, due to one remaining call in
+  ;; mh-tool-bar.el.  Once that is removed, this can be obsoleted.
+  (declare ;; (obsolete nil "29.1")
+   (debug t) (indent defun))
   (unless (featurep 'xemacs) `(progn ,@body)))
 
 ;;;###mh-autoload
diff --git a/lisp/mh-e/mh-compat.el b/lisp/mh-e/mh-compat.el
index 659c435..8393798 100644
--- a/lisp/mh-e/mh-compat.el
+++ b/lisp/mh-e/mh-compat.el
@@ -38,9 +38,7 @@
 
 (eval-when-compile (require 'mh-acros))
 
-(mh-do-in-gnu-emacs
-  (define-obsolete-function-alias 'mh-require #'require "29.1"))
-
+(define-obsolete-function-alias 'mh-require #'require "29.1")
 (define-obsolete-function-alias 'mh-assoc-string #'assoc-string "29.1")
 (define-obsolete-function-alias 'mh-cancel-timer #'cancel-timer "29.1")
 
diff --git a/lisp/mh-e/mh-folder.el b/lisp/mh-e/mh-folder.el
index ed65395..c59ed84 100644
--- a/lisp/mh-e/mh-folder.el
+++ b/lisp/mh-e/mh-folder.el
@@ -576,11 +576,10 @@ region in the MH-Folder buffer, then the MH-E command will
 perform the operation on all messages in that region.
 
 \\{mh-folder-mode-map}"
-  (mh-do-in-gnu-emacs
-    (unless mh-folder-tool-bar-map
-        (mh-tool-bar-folder-buttons-init))
-    (if (boundp 'tool-bar-map)
-        (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)))
+  (unless mh-folder-tool-bar-map
+    (mh-tool-bar-folder-buttons-init))
+  (if (boundp 'tool-bar-map)
+      (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map))
   (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-letter.el b/lisp/mh-e/mh-letter.el
index f147b7c..0271edb 100644
--- a/lisp/mh-e/mh-letter.el
+++ b/lisp/mh-e/mh-letter.el
@@ -291,11 +291,10 @@ order).
   (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-tool-bar-map
-      (mh-tool-bar-letter-buttons-init))
-    (if (boundp 'tool-bar-map)
-        (set (make-local-variable 'tool-bar-map) mh-letter-tool-bar-map)))
+  (unless mh-letter-tool-bar-map
+    (mh-tool-bar-letter-buttons-init))
+  (if (boundp 'tool-bar-map)
+      (set (make-local-variable 'tool-bar-map) mh-letter-tool-bar-map))
   ;; 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-mime.el b/lisp/mh-e/mh-mime.el
index 0dbf8f0..24410e6 100644
--- a/lisp/mh-e/mh-mime.el
+++ b/lisp/mh-e/mh-mime.el
@@ -187,8 +187,7 @@ Set from last use.")
     (unless (>= (string-to-number emacs-version) 21)
       ;; XEmacs doesn't care.
       (set-keymap-parent map mh-show-mode-map))
-    (mh-do-in-gnu-emacs
-     (define-key map [mouse-2] #'mh-push-button))
+    (define-key map [mouse-2] #'mh-push-button)
     (dolist (c mh-mime-button-commands)
       (define-key map (cadr c) (car c)))
     map))
@@ -211,8 +210,7 @@ Set from last use.")
     (unless (>= (string-to-number emacs-version) 21)
       (set-keymap-parent map mh-show-mode-map))
     (define-key map "\r" #'mh-press-button)
-    (mh-do-in-gnu-emacs
-     (define-key map [mouse-2] #'mh-push-button))
+    (define-key map [mouse-2] #'mh-push-button)
     map))
 
 
@@ -773,13 +771,12 @@ This is only useful if a Content-Disposition header is 
not present."
                                         ; this only tells us if the image is
                                         ; something that emacs can display
          (let ((image (mm-get-image handle)))
-           (mh-do-in-gnu-emacs
-             (let ((size (and (fboundp 'image-size) (image-size image))))
-               (and size
-                    (< (cdr size) (or mh-max-inline-image-height
-                                      (1- (window-height))))
-                    (< (car size) (or mh-max-inline-image-width
-                                      (window-width))))))))))
+           (let ((size (and (fboundp 'image-size) (image-size image))))
+             (and size
+                  (< (cdr size) (or mh-max-inline-image-height
+                                    (1- (window-height))))
+                  (< (car size) (or mh-max-inline-image-width
+                                    (window-width)))))))))
 
 (defun mh-inline-vcard-p (handle)
   "Decide if HANDLE is a vcard that must be displayed inline."
@@ -807,10 +804,9 @@ being used to highlight the signature in a MIME part."
     (save-excursion
       (goto-char (point-max))
       (when (re-search-backward regexp nil t)
-        (mh-do-in-gnu-emacs
-          (let ((ov (make-overlay (point) (point-max))))
-            (overlay-put ov 'face 'mh-show-signature)
-            (overlay-put ov 'evaporate t)))))))
+        (let ((ov (make-overlay (point) (point-max))))
+          (overlay-put ov 'face 'mh-show-signature)
+          (overlay-put ov 'evaporate t))))))
 
 
 
diff --git a/lisp/mh-e/mh-show.el b/lisp/mh-e/mh-show.el
index 25b83b2..489c134 100644
--- a/lisp/mh-e/mh-show.el
+++ b/lisp/mh-e/mh-show.el
@@ -833,9 +833,8 @@ The hook `mh-show-mode-hook' is called upon entry to this 
mode.
 See also `mh-folder-mode'.
 
 \\{mh-show-mode-map}"
-  (mh-do-in-gnu-emacs
-   (if (boundp 'tool-bar-map)
-       (set (make-local-variable 'tool-bar-map) mh-show-tool-bar-map)))
+  (if (boundp 'tool-bar-map)
+      (set (make-local-variable 'tool-bar-map) mh-show-tool-bar-map))
   (set (make-local-variable 'mail-header-separator) mh-mail-header-separator)
   (setq paragraph-start (default-value 'paragraph-start))
   (setq buffer-invisibility-spec '((vanish . t) t))
diff --git a/lisp/mh-e/mh-tool-bar.el b/lisp/mh-e/mh-tool-bar.el
index 805408c..06b94b6 100644
--- a/lisp/mh-e/mh-tool-bar.el
+++ b/lisp/mh-e/mh-tool-bar.el
@@ -27,6 +27,8 @@
 ;;; Code:
 
 (require 'mh-e)
+;; FIXME: Figure out why removing the call to the `mh-do-in-gnu-emacs'
+;;        macro here leads to errors.
 (mh-do-in-gnu-emacs
   (require 'tool-bar))
 
@@ -202,79 +204,77 @@ where,
       (unless (memq x letter-buttons)
         (error "Letter defaults contains unknown button %s" x)))
     `(eval-and-compile
-       ;; 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."
-           (cl-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)
-             (let* ((load-path (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)
-             (let* ((load-path (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.
+       (defun mh-buffer-exists-p (mode)
+         "Test whether a buffer with major mode MODE is present."
+         (cl-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)
+           (let* ((load-path (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)
+           (let* ((load-path (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."
-           (cl-loop for buf in (buffer-list)
-                    do (with-current-buffer buf
-                         (when (eq mode major-mode) ;FIXME: derived-mode-p?
-                           (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-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-update 'mh-letter-mode mh-letter-tool-bar-map
-                               mh-letter-tool-bar-map)))
+         (cl-loop for buf in (buffer-list)
+                  do (with-current-buffer buf
+                       (when (eq mode major-mode) ;FIXME: derived-mode-p?
+                         (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-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-update 'mh-letter-mode mh-letter-tool-bar-map
+                             mh-letter-tool-bar-map))
        ;; Declare customizable tool bars
        (custom-declare-variable
         'mh-tool-bar-folder-buttons
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el
index 93bc7f8..4f211c1 100644
--- a/lisp/mh-e/mh-utils.el
+++ b/lisp/mh-e/mh-utils.el
@@ -124,19 +124,18 @@ Ignores case when searching for OLD."
 ;;;###mh-autoload
 (defun mh-logo-display ()
   "Modify mode line to display MH-E logo."
-  (mh-do-in-gnu-emacs
-    (let* ((load-path (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))))
-      (add-text-properties
-       0 2
-       `(display ,(or mh-logo-cache
-                      (setq mh-logo-cache
-                            (mh-funcall-if-exists
-                             find-image '((:type xpm :ascent center
-                                                 :file "mh-logo.xpm"))))))
-       (car mode-line-buffer-identification)))))
+  (let* ((load-path (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))))
+    (add-text-properties
+     0 2
+     `(display ,(or mh-logo-cache
+                    (setq mh-logo-cache
+                          (mh-funcall-if-exists
+                           find-image '((:type xpm :ascent center
+                                               :file "mh-logo.xpm"))))))
+     (car mode-line-buffer-identification))))
 
 
 
@@ -910,8 +909,7 @@ Handle RFC 822 (or later) continuation lines."
 
 (defvar mh-hidden-header-keymap
   (let ((map (make-sparse-keymap)))
-    (mh-do-in-gnu-emacs
-      (define-key map [mouse-2] 
#'mh-letter-toggle-header-field-display-button))
+    (define-key map [mouse-2] #'mh-letter-toggle-header-field-display-button)
     map))
 
 ;;;###mh-autoload
diff --git a/lisp/mh-e/mh-xface.el b/lisp/mh-e/mh-xface.el
index 5983353..332f963 100644
--- a/lisp/mh-e/mh-xface.el
+++ b/lisp/mh-e/mh-xface.el
@@ -74,17 +74,16 @@ in this order is used."
       (when type
         (goto-char (point-min))
         (when (re-search-forward "^from:" (point-max) t)
-          (mh-do-in-gnu-emacs
-            (if (eq type 'url)
-                (mh-x-image-url-display url)
-              (mh-funcall-if-exists
-               insert-image (create-image
-                             raw type t
-                             :foreground
-                             (face-foreground 'mh-show-xface nil t)
-                             :background
-                             (face-background 'mh-show-xface nil t))
-               " "))))))))
+          (if (eq type 'url)
+              (mh-x-image-url-display url)
+            (mh-funcall-if-exists
+             insert-image (create-image
+                           raw type t
+                           :foreground
+                           (face-foreground 'mh-show-xface nil t)
+                           :background
+                           (face-background 'mh-show-xface nil t))
+             " ")))))))
 
 (defun mh-face-to-png (data)
   "Convert base64 encoded DATA to png image."
@@ -143,9 +142,8 @@ The directories are searched for in the order they appear 
in the list.")
 
 (defvar mh-picon-image-types
   (cl-loop for type in '(xpm xbm gif)
-           when (or (mh-do-in-gnu-emacs
-                     (ignore-errors
-                       (image-type-available-p type))))
+           when (ignore-errors
+                  (image-type-available-p type))
            collect type))
 
 (autoload 'message-tokenize-header "sendmail")
@@ -370,8 +368,7 @@ filenames.  In addition, replaces * with %2a. See URL
           (when (and (file-readable-p image) (not (file-symlink-p image))
                      (eq marker mh-x-image-marker))
             (goto-char marker)
-            (mh-do-in-gnu-emacs
-              (insert-image (create-image image 'png))))
+            (insert-image (create-image image 'png)))
         (set-buffer-modified-p buffer-modified-flag)))))
 
 (defun mh-x-image-url-fetch-image (url cache-file marker sentinel)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]