Tidy up +ivy-buffer-preview functionality
Let-binding `ivy-use-virtual-buffers` is neater and more robust than the previous solution using some copy-pasta. Calling the unwind routine will become important once counsel is patched to restore buffer-list.
This commit is contained in:
parent
4a1a359c21
commit
0f0b0d720b
1 changed files with 9 additions and 7 deletions
|
@ -35,10 +35,11 @@ temporary/special buffers in `font-lock-comment-face'."
|
|||
;; Library
|
||||
|
||||
(defun +ivy--switch-buffer-preview ()
|
||||
(if (get-buffer (ivy-state-current ivy-last))
|
||||
(ivy-call)
|
||||
(with-ivy-window
|
||||
(switch-to-buffer (ivy-state-buffer ivy-last)))))
|
||||
(let (ivy-use-virtual-buffers)
|
||||
(counsel--switch-buffer-update-fn)))
|
||||
|
||||
(defalias '+ivy--switch-buffer-preview-all #'counsel--switch-buffer-update-fn)
|
||||
(defalias '+ivy--switch-buffer-unwind #'counsel--switch-buffer-unwind)
|
||||
|
||||
(defun +ivy--switch-buffer (workspace other)
|
||||
(let ((current (not other))
|
||||
|
@ -60,10 +61,11 @@ temporary/special buffers in `font-lock-comment-face'."
|
|||
(when +ivy-buffer-preview
|
||||
(cond ((not (and ivy-use-virtual-buffers
|
||||
(eq +ivy-buffer-preview 'everything)))
|
||||
(setq update #'+ivy--switch-buffer-preview))
|
||||
(setq update #'+ivy--switch-buffer-preview
|
||||
unwind #'+ivy--switch-buffer-unwind))
|
||||
(t
|
||||
(setq update #'counsel--switch-buffer-update-fn
|
||||
unwind #'counsel--switch-buffer-unwind))))
|
||||
(setq update #'+ivy--switch-buffer-preview-all
|
||||
unwind #'+ivy--switch-buffer-unwind))))
|
||||
(ivy-read prompt 'internal-complete-buffer
|
||||
:action action
|
||||
:predicate filter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue