[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult ddc72467dd: EXPERIMENTAL CHANGE: buffer-preview
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult ddc72467dd: EXPERIMENTAL CHANGE: buffer-preview via window-configuration restoration |
Date: |
Sat, 7 Dec 2024 21:57:47 -0500 (EST) |
branch: externals/consult
commit ddc72467dd32dd46837684235a9ee4a2c8cb2d74
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
EXPERIMENTAL CHANGE: buffer-preview via window-configuration restoration
By using set-window-configuration buffer preview becomes compatible with
complex
display-buffer-alist configurations. Also restore the tab bar status.
---
consult.el | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/consult.el b/consult.el
index fdf208a72b..bb4facbec3 100644
--- a/consult.el
+++ b/consult.el
@@ -4422,29 +4422,27 @@ AS is a conversion function."
(defun consult--buffer-preview ()
"Buffer preview function."
- (let ((orig-buf (window-buffer (consult--original-window)))
- (orig-prev (copy-sequence (window-prev-buffers)))
- (orig-next (copy-sequence (window-next-buffers)))
- other-win)
+ (let* ((wc (current-window-configuration))
+ (tabs nil)
+ (tidx nil)
+ (restore (lambda ()
+ (set-window-configuration wc nil t)
+ (when tabs
+ (tab-bar-tabs-set tabs)
+ (tab-bar-select-tab (1+ tidx))))))
+ (when tab-bar-mode
+ (setq tabs (copy-tree (tab-bar-tabs))
+ tidx (tab-bar--current-tab-index tabs)))
(lambda (action cand)
(pcase action
- ('exit
- (set-window-prev-buffers other-win orig-prev)
- (set-window-next-buffers other-win orig-next))
+ ('return
+ (funcall restore))
('preview
- (when (and (eq consult--buffer-display
#'switch-to-buffer-other-window)
- (not other-win))
- (switch-to-buffer-other-window orig-buf 'norecord)
- (setq other-win (selected-window)))
- (let ((win (or other-win (selected-window)))
- (buf (or (and cand (get-buffer cand)) orig-buf)))
- (when (and (window-live-p win) (buffer-live-p buf)
- (not (buffer-match-p consult-preview-excluded-buffers
buf)))
- (with-selected-window win
- (unless (or orig-prev orig-next)
- (setq orig-prev (copy-sequence (window-prev-buffers))
- orig-next (copy-sequence (window-next-buffers))))
- (switch-to-buffer buf 'norecord)))))))))
+ (funcall restore)
+ (when-let ((buf (and cand (get-buffer cand)))
+ ((and (buffer-live-p buf)
+ (not (buffer-match-p
consult-preview-excluded-buffers buf)))))
+ (funcall consult--buffer-display buf 'norecord)))))))
(defun consult--buffer-action (buffer &optional norecord)
"Switch to BUFFER via `consult--buffer-display' function.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/consult ddc72467dd: EXPERIMENTAL CHANGE: buffer-preview via window-configuration restoration,
ELPA Syncer <=