mu4e-draft/helpers: use newer message-hide-headers

It seems the older (<= emacs 28 at least) message-hide-headers caused
trouble when editing drafts with mu4e in some cases.

So use the _newer_ version of this function, imported as
mu4e--message-hide-headers.

Fixes #2661.
This commit is contained in:
Dirk-Jan C. Binnema
2024-09-03 20:40:24 +03:00
parent b9cf667be9
commit 89f2162729
2 changed files with 30 additions and 2 deletions

View File

@ -605,9 +605,11 @@ COMPOSE-TYPE and PARENT are as in `mu4e--draft'."
;; now, switch to compose mode ;; now, switch to compose mode
(mu4e-compose-mode) (mu4e-compose-mode)
;; hide some internal headers ;; hide some internal headers; we use the special mu4e-- version of
;; message-hide-headers, since older versions of the latter trigger some bug,
;; #2661.
(let ((message-hidden-headers mu4e-draft-hidden-headers)) (let ((message-hidden-headers mu4e-draft-hidden-headers))
(message-hide-headers)) (mu4e--message-hide-headers))
;; hooks ;; hooks
(add-hook 'before-save-hook #'mu4e--compose-before-save nil t) (add-hook 'before-save-hook #'mu4e--compose-before-save nil t)

View File

@ -31,6 +31,7 @@
(require 'ido) (require 'ido)
(require 'cl-lib) (require 'cl-lib)
(require 'bookmark) (require 'bookmark)
(require 'message)
(require 'mu4e-window) (require 'mu4e-window)
(require 'mu4e-config) (require 'mu4e-config)
@ -576,6 +577,31 @@ This is mu4e's version of Emacs 29's `plistp'."
(let ((len (proper-list-p object))) (let ((len (proper-list-p object)))
(and len (zerop (% len 2))))) (and len (zerop (% len 2)))))
(defun mu4e--message-hide-headers ()
"Hide headers based on the `message-hidden-headers' variable.
This is mu4e's version of the post-emacs-28 `message-hide-headers',
which we need to avoid #2661."
(let ((regexps (if (stringp message-hidden-headers)
(list message-hidden-headers)
message-hidden-headers))
end-of-headers)
(when regexps
(save-excursion
(save-restriction
(message-narrow-to-headers)
(setq end-of-headers (point-min-marker))
(goto-char (point-min))
(while (not (eobp))
(if (not (message-hide-header-p regexps))
(message-next-header)
(let ((begin (point)))
(message-next-header)
(let ((header (delete-and-extract-region begin (point))))
(save-excursion
(goto-char end-of-headers)
(insert-before-markers header))))))))
(narrow-to-region end-of-headers (point-max)))))
(defun mu4e-key-description (cmd) (defun mu4e-key-description (cmd)
"Get the textual form of current binding to interactive function CMD. "Get the textual form of current binding to interactive function CMD.
If it is unbound, return nil. If there are multiple bindings, If it is unbound, return nil. If there are multiple bindings,