Merge pull request #1228 from flatwhatson/tidy-ivy-buffer-preview

Tidy up +ivy-buffer-preview functionality
This commit is contained in:
Henrik Lissner 2019-03-09 12:43:34 -05:00 committed by GitHub
commit 850ad3956d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,10 +35,11 @@ temporary/special buffers in `font-lock-comment-face'."
;; Library ;; Library
(defun +ivy--switch-buffer-preview () (defun +ivy--switch-buffer-preview ()
(if (get-buffer (ivy-state-current ivy-last)) (let (ivy-use-virtual-buffers)
(ivy-call) (counsel--switch-buffer-update-fn)))
(with-ivy-window
(switch-to-buffer (ivy-state-buffer ivy-last))))) (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) (defun +ivy--switch-buffer (workspace other)
(let ((current (not other)) (let ((current (not other))
@ -60,10 +61,11 @@ temporary/special buffers in `font-lock-comment-face'."
(when +ivy-buffer-preview (when +ivy-buffer-preview
(cond ((not (and ivy-use-virtual-buffers (cond ((not (and ivy-use-virtual-buffers
(eq +ivy-buffer-preview 'everything))) (eq +ivy-buffer-preview 'everything)))
(setq update #'+ivy--switch-buffer-preview)) (setq update #'+ivy--switch-buffer-preview
unwind #'+ivy--switch-buffer-unwind))
(t (t
(setq update #'counsel--switch-buffer-update-fn (setq update #'+ivy--switch-buffer-preview-all
unwind #'counsel--switch-buffer-unwind)))) unwind #'+ivy--switch-buffer-unwind))))
(ivy-read prompt 'internal-complete-buffer (ivy-read prompt 'internal-complete-buffer
:action action :action action
:predicate filter :predicate filter