[PATCH v2 04/23] emacs: more cleanup since dropping support for Emacs 24

Subject: [PATCH v2 04/23] emacs: more cleanup since dropping support for Emacs 24

Date: Mon, 16 Nov 2020 22:28:24 +0100

To: notmuch@notmuchmail.org

Cc:

From: Jonas Bernoulli


Notmuch requires at least version 25 of Emacs now.

Adjust comments that previously referenced version 24 specifically,
even though they also apply to later releases. Remove documentation
and code that no longer applies.

- `mm-shr' no longer references `gnus-inhibit-images'.
---
 emacs/notmuch-compat.el |  9 +++++----
 emacs/notmuch-hello.el  | 16 +++++-----------
 emacs/notmuch-jump.el   |  5 -----
 emacs/notmuch-lib.el    | 12 ------------
 emacs/notmuch-mua.el    | 17 ++++++-----------
 emacs/notmuch-show.el   | 10 ++++------
 emacs/notmuch-tree.el   |  7 ++++---
 7 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 3ede6b36..2975f4c2 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -21,10 +21,11 @@
 
 ;;; Code:
 
-;; emacs master has a bugfix for folding long headers when sending
-;; messages. Include the fix for earlier versions of emacs. To avoid
-;; interfering with gnus we only run the hook when called from
-;; notmuch-message-mode.
+;; Before Emacs 26.1 lines that are longer than 998 octets were not.
+;; folded. Commit 77bbca8c82f6e553c42abbfafca28f55fc995d00 fixed
+;; that. Until we drop support for Emacs 25 we have to backport that
+;; fix. To avoid interfering with Gnus we only run the hook when
+;; called from notmuch-message-mode.
 
 (declare-function mail-header-fold-field "mail-parse" nil)
 
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index b67a5e19..af170dd4 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -645,6 +645,7 @@ (defun notmuch-hello-window-configuration-change ()
       ;; Refresh hello as soon as we get back to redisplay.  On Emacs
       ;; 24, we can't do it right here because something in this
       ;; hook's call stack overrides hello's point placement.
+      ;; FIXME And on Emacs releases that we still support?
       (run-at-time nil nil #'notmuch-hello t))
     (unless hello-buf
       ;; Clean up hook
@@ -665,17 +666,10 @@ (defun notmuch-hello-versions ()
 		       " (emacs mua version " notmuch-emacs-version ")")))))
 
 (defvar notmuch-hello-mode-map
-  (let ((map (if (fboundp 'make-composed-keymap)
-		 ;; Inherit both widget-keymap and
-		 ;; notmuch-common-keymap. We have to use
-		 ;; make-sparse-keymap to force this to be a new
-		 ;; keymap (so that when we modify map it does not
-		 ;; modify widget-keymap).
-		 (make-composed-keymap (list (make-sparse-keymap) widget-keymap))
-	       ;; Before Emacs 24, keymaps didn't support multiple
-	       ;; inheritance,, so just copy the widget keymap since
-	       ;; it's unlikely to change.
-	       (copy-keymap widget-keymap))))
+  ;; Inherit both widget-keymap and notmuch-common-keymap.  We have
+  ;; to use make-sparse-keymap to force this to be a new keymap (so
+  ;; that when we modify map it does not modify widget-keymap).
+  (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap))))
     (set-keymap-parent map notmuch-common-keymap)
     (define-key map "v" 'notmuch-hello-versions)
     (define-key map (kbd "<C-tab>") 'widget-backward)
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 1e2d0497..ff622055 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -29,11 +29,6 @@ (eval-when-compile
 (require 'notmuch-lib)
 (require 'notmuch-hello)
 
-(eval-and-compile
-  (unless (fboundp 'window-body-width)
-    ;; Compatibility for Emacs pre-24
-    (defalias 'window-body-width 'window-width)))
-
 ;;;###autoload
 (defun notmuch-jump-search ()
   "Jump to a saved search by shortcut key.
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 118faf1e..edb40533 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -653,18 +653,6 @@ (defun notmuch-get-bodypart-text (msg part process-crypto &optional cache)
 MSG (if it isn't already)."
   (notmuch--get-bodypart-raw msg part process-crypto nil cache))
 
-;; Workaround: The call to `mm-display-part' below triggers a bug in
-;; Emacs 24 if it attempts to use the shr renderer to display an HTML
-;; part with images in it (demonstrated in 24.1 and 24.2 on Debian and
-;; Fedora 17, though unreproducible in other configurations).
-;; `mm-shr' references the variable `gnus-inhibit-images' without
-;; first loading gnus-art, which defines it, resulting in a
-;; void-variable error.  Hence, we advise `mm-shr' to ensure gnus-art
-;; is loaded.
-(define-advice mm-shr (:before (_handle) notmuch--load-gnus-args)
-  "Require `gnus-art' since we use its variables."
-  (require 'gnus-art nil t))
-
 (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
   "Use the mm-decode/mm-view functions to display a part in the
 current buffer, if possible."
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 869ec51a..49bad00d 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -47,8 +47,7 @@ (defcustom notmuch-mua-send-hook nil
   :group 'notmuch-hooks)
 
 (defcustom notmuch-mua-compose-in 'current-window
-  (concat
-   "Where to create the mail buffer used to compose a new message.
+  "Where to create the mail buffer used to compose a new message.
 Possible values are `current-window' (default), `new-window' and
 `new-frame'. If set to `current-window', the mail buffer will be
 displayed in the current window, so the old buffer will be
@@ -57,10 +56,6 @@ (defcustom notmuch-mua-compose-in 'current-window
 window/frame that will be destroyed when the buffer is killed.
 You may want to customize `message-kill-buffer-on-exit'
 accordingly."
-   (when (< emacs-major-version 24)
-     " Due to a known bug in Emacs 23, you should not set
-this to `new-window' if `message-kill-buffer-on-exit' is
-disabled: this would result in an incorrect behavior."))
   :group 'notmuch-send
   :type '(choice (const :tag "Compose in the current window" current-window)
 		 (const :tag "Compose mail in a new window"  new-window)
@@ -212,7 +207,7 @@ (defun notmuch-mua-reply-crypto (parts)
 					       "multipart/*")
 	   do (notmuch-mua-reply-crypto (plist-get part :content))))
 
-;; There is a bug in emacs 23's message.el that results in a newline
+;; There is a bug in Emacs' message.el that results in a newline
 ;; not being inserted after the References header, so the next header
 ;; is concatenated to the end of it. This function fixes the problem,
 ;; while guarding against the possibility that some current or future
@@ -517,10 +512,10 @@ (defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all
 If PROMPT-FOR-SENDER is non-nil, the user will be prompted for
 the From: address first.  If REPLY-ALL is non-nil, the message
 will be addressed to all recipients of the source message."
-  ;; In current emacs (24.3) select-active-regions is set to t by
-  ;; default. The reply insertion code sets the region to the quoted
-  ;; message to make it easy to delete (kill-region or C-w). These two
-  ;; things combine to put the quoted message in the primary selection.
+  ;; `select-active-regions' is t by default. The reply insertion code
+  ;; sets the region to the quoted message to make it easy to delete
+  ;; (kill-region or C-w). These two things combine to put the quoted
+  ;; message in the primary selection.
   ;;
   ;; This is not what the user wanted and is a privacy risk (accidental
   ;; pasting of the quoted message). We can avoid some of the problems
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ec22fd94..6a757687 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -186,8 +186,7 @@ (defvar notmuch-show-attachment-debug nil
 When set to nil (the default) stdout and stderr from attachment
 handlers is discarded. When set to t the stdout and stderr from
 each attachment handler is logged in buffers with names beginning
-\" *notmuch-part*\". This option requires emacs version at least
-24.3 to work.")
+\" *notmuch-part*\".")
 
 (defcustom notmuch-show-stash-mlarchive-link-alist
   '(("Gmane" . "https://mid.gmane.org/")
@@ -2417,10 +2416,9 @@ (defun notmuch-show-apply-to-current-part-handle (fn &optional mime-type)
 is destroyed when FN returns. If MIME-TYPE is given then force
 part to be treated as if it had that mime-type."
   (let ((handle (notmuch-show-current-part-handle mime-type)))
-    ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we
-    ;; call it from a temp-buffer, unless
-    ;; notmuch-show-attachment-debug is non-nil in which case we put
-    ;; it in " *notmuch-part*".
+    ;; Emacs puts stdout/stderr into the calling buffer so we call
+    ;; it from a temp-buffer, unless notmuch-show-attachment-debug
+    ;; is non-nil, in which case we put it in " *notmuch-part*".
     (unwind-protect
 	(if notmuch-show-attachment-debug
 	    (with-current-buffer (generate-new-buffer " *notmuch-part*")
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index ad08f7c6..28c9372e 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -531,9 +531,10 @@ (defun notmuch-tree-message-window-kill-hook ()
   (let ((buffer (current-buffer)))
     (when (and (window-live-p notmuch-tree-message-window)
 	       (eq (window-buffer notmuch-tree-message-window) buffer))
-      ;; We do not want an error if this is the sole window in the
-      ;; frame and I do not know how to test for that in emacs pre
-      ;; 24. Hence we just ignore-errors.
+      ;; We could check whether this is the only window in its frame,
+      ;; but simply ignoring the error that is thrown otherwise is
+      ;; what we had to do for Emacs 24 and we stick to that because
+      ;; it is still the simplest approach.
       (ignore-errors
 	(delete-window notmuch-tree-message-window)))))
 
-- 
2.29.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: