mu4e-window: add mu4e--buffer-local-boundp

buffer-local-boundp was introduced in emacs 28.

Fixes #2456.
This commit is contained in:
Dirk-Jan C. Binnema 2023-03-30 20:34:59 +03:00
parent d96a3c946c
commit eedc4d34e1
1 changed files with 14 additions and 2 deletions

View File

@ -172,6 +172,17 @@ Checks are performed using `derived-mode-p' and the current
buffer's major mode."
(eq (mu4e--get-current-buffer-type) type))
;; backward-compat; buffer-local-boundp was introduced in emacs 28.
(defun mu4e--buffer-local-boundp (symbol buffer)
"Return non-nil if SYMBOL is bound in BUFFER.
Also see `local-variable-p'."
(condition-case nil
(buffer-local-value symbol buffer)
(:success t)
(void-variable nil)))
(defun mu4e-get-view-buffer (&optional headers-buffer create)
"Return a view buffer belonging optionally to HEADERS-BUFFER.
@ -197,8 +208,9 @@ being created if CREATE is non-nil."
;; Search all view buffers and return those that are linked to
;; `headers-buffer'.
(linked-buffer (mu4e-get-view-buffers
(lambda (buf) (and (buffer-local-boundp 'mu4e-linked-headers-buffer buf)
(eq mu4e-linked-headers-buffer headers-buffer))))))
(lambda (buf)
(and (mu4e--buffer-local-boundp 'mu4e-linked-headers-buffer buf)
(eq mu4e-linked-headers-buffer headers-buffer))))))
;; If such a linked buffer exists and its buffer is live, we use that buffer.
(if (and linked-buffer (buffer-live-p (car linked-buffer)))
;; NOTE: It's possible for there to be more than one linked view buffer.