emacs-31 99a9307235c: Avoid errors in 'dabbrev-expand'

Eli Zaretskii <[email protected]> Thu, 30 Jul 2026 07:33:21 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit 99a9307235ca7e833744adb19e58473b86fc76e8
Author: Eli Zaretskii <[email protected]>
Commit: Eli Zaretskii <[email protected]>

    Avoid errors in 'dabbrev-expand'
    
    * lisp/dabbrev.el (dabbrev-expand): Fix use of
    'dabbrev--last-buffer-found': it could be a killed buffer.
    (Bug#81452)
    
    (cherry picked from commit 0e8fbd63e96b9b775d386b19f2a64d89d91cc6e3)
---
 lisp/dabbrev.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 9fe2904c415..be4fbae9434 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -601,7 +601,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
 	(message nil))
       ;; To get correct further expansions we have to be sure to use the
       ;; buffer containing the already found expansions.
-      (when dabbrev--last-buffer-found
+      (when (buffer-live-p dabbrev--last-buffer-found)
         (setq buf dabbrev--last-buffer-found))
       ;; If the buffer where we called dabbrev-expand differs from the
       ;; buffer containing the expansion, make sure copy-marker is