EXWM/Miniframe: Windows not restored after preview · Issue #178 · minad/consult (original) (raw)
From what I can tell, consult--preview-position
isn't used for consult--buffer
, consult--buffer
is (which doesn't do anything on restore.
I've been able to get this to work with:
diff --git a/consult.el b/consult.el index 9920f68..9dd1892 100644 --- a/consult.el +++ b/consult.el @@ -2674,6 +2674,7 @@ FACE is the face for the candidate."
Depending on the selected item OPEN-BUFFER, OPEN-FILE or OPEN-BOOKMARK will be used to display the item." (let* ((curr-buf (current-buffer)) + (curr-win (get-buffer-window curr-buf)) (all-bufs (append (delq curr-buf (buffer-list)) (list curr-buf))) (buf-file-hash (let ((ht (make-hash-table :test #'equal :size (length all-bufs)))) (dolist (buf all-bufs ht) @@ -2756,8 +2757,11 @@ Depending on the selected item OPEN-BUFFER, OPEN-FILE or OPEN-BOOKMARK will be u :preview (lambda (cand restore) (cond
(restore)
;; In order to avoid slowness and unnecessary complexity, we
(restore
(if (not (buffer-live-p curr-buf))
(message "Buffer is dead")
(set-window-buffer curr-win curr-buf)))
;; In order to avoid slowness and unnecessary complexity, we ;; only preview buffers. Loading recent files, bookmarks or ;; views can result in expensive operations. ((and (or (eq (car cand) #'switch-to-buffer)
However, that's still suboptimal because it only restores the current window. I use EXWM so previewing buffers ends up "stealing" X windows from other windows and they don't get restored after exiting.
What's the motivation for handling this manually? Generally, I'd expect completions to have no side effects other than to return the completion result (and act on it). This just seems like a lot of work to make sure nothing goes wrong when there's a nice big hammer (save-window-excursion
) just sitting there.