From 82de3a588a64214c9f97ef6d3c186b354e6a5e1d Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Mon, 14 Apr 2025 17:43:04 +0200 Subject: [PATCH] dabbrev: also filter visible buffers. --- lisp/dabbrev.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index 9d75150b084..a0f8134f8cb 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el @@ -40,7 +40,7 @@ addition to the current buffer and the visible buffers.") (let* ((abbrev (or abbrev (thing-at-point 'symbol))) (anchor (or anchor (car (bounds-of-thing-at-point 'symbol)))) (scanned 0) pos expansions more - (search + (srch (lambda (buffer) (when (< scanned dabbrev-maximum-characters) (with-current-buffer buffer @@ -79,11 +79,16 @@ addition to the current buffer and the visible buffers.") scanned (- (point-max) (point-min))) ;; Then all visible buffers. (when (< scanned dabbrev-maximum-characters) - (walk-windows (compf [search] window-buffer) nil 'visible) + (walk-windows + (lambda (win) + (let ((buf (window-buffer win))) + (when (buffer-match-p dabbrev-buffer-search-condition buf) + (funcall srch buf)))) + nil 'visible) (setq expansions (nconc expansions more) more nil)) ;; Then try other buffers. (when (< scanned dabbrev-maximum-characters) - (mapc search (match-buffers dabbrev-buffer-search-condition)) + (mapc srch (match-buffers dabbrev-buffer-search-condition)) (setq expansions (nconc expansions more))) expansions))) -- 2.39.5