fix(vertico): +vertico/switch-workspace-buffer

- fix a paren error in the function that caused the buffers to be sorted
  alphabetically and not by recency
- refactor the workspace buffer sources to use consult--buffer-query,
  that way we get niceties like the current buffer being last

Fix #5366
This commit is contained in:
Itai Y. Efrat 2021-09-21 17:57:50 +03:00 committed by Henrik Lissner
parent dda5f558b2
commit 34f76c8a75

View file

@ -10,14 +10,28 @@
:narrow ,(string-to-char (number-to-string (1+ n)))
:category buffer
:state ,#'consult--buffer-state
:items ,(lambda () (mapcar #'buffer-name (+workspace-buffer-list (nth n (+workspace-list)))))))
:items ,(lambda ()
(consult--buffer-query
:sort 'visibility
:as #'buffer-name
:predicate (lambda (buf)
(+workspace-contains-buffer-p
buf
(nth n (+workspace-list))))))))
((eq n 'final)
`(:name ,(car (last (+workspace-list-names)))
:hidden t
:narrow ?0
:category buffer
:state ,#'consult--buffer-state
:items ,(lambda () (mapcar #'buffer-name (+workspace-buffer-list (car (last (+workspace-list))))))))
:items ,(lambda ()
(consult--buffer-query
:sort 'visibility
:as #'buffer-name
:predicate (lambda (buf)
(+workspace-contains-buffer-p
buf
(car (last (+workspace-list)))))))))
(t
(user-error "invalid workspace source %s" n))))
@ -38,9 +52,9 @@ Use consult narrowing with another workspace number to open a buffer from that w
:require-match
(confirm-nonexistent-file-or-buffer)
:prompt (format "Switch to buffer (%s): "
(+workspace-current-name)
(+workspace-current-name))
:history 'consult--buffer-history
:sort nil)))
:sort nil))
;; When the buffer does not belong to a source,
;; create a new buffer with the name.
(unless (cdr buffer)