selectrum: improve SPC b b
- Now uses a consult backend - has buffer preview, per workspace narrowing with `$n SPC`
This commit is contained in:
parent
23a63ba5c4
commit
188fc09d72
4 changed files with 59 additions and 10 deletions
|
@ -133,7 +133,12 @@ An ~occur-edit~ buffer can be opened from ~consult-line~ with =C-c C-e=.
|
|||
| =SPC b b=, =SPC ,= | Switch to buffer in current workspace |
|
||||
| =SPC b B=, =SPC <= | Switch to buffer |
|
||||
|
||||
~find-file~ commands support exported to a =wdired= buffer using =C-c C-e=.
|
||||
=SPC b b= and =SPC ,= support changing the workspace you're selecting a buffer from
|
||||
via [[https://github.com/minad/consult#narrowing-and-grouping][Consult narrowing]], e.g. if you're on the first workspace, you can switch to
|
||||
selecting a buffer from the third workspace by typing =3 SPC= into the prompt,
|
||||
or the last workspace by typing =0 SPC=.
|
||||
|
||||
=SPC f f= and =SPC .= support exporting to a =wdired= buffer using =C-c C-e=.
|
||||
|
||||
*** Search
|
||||
| Keybind | Description |
|
||||
|
|
|
@ -70,16 +70,12 @@ currently =SPC n b= is bound to a function, but =bibtex-actions= doesn't have a
|
|||
main dispatch function like =ivy-bibtex=, rather it has a bunch of different
|
||||
ones. Binding the ~bibtex-actions-map~ there would probably be better, but there
|
||||
are nontrivial loading order shenanigans happening that make that not straightforward.
|
||||
** TODO buffer switching
|
||||
- =SPC b b= should switch workspace after choosing a buffer from a different one
|
||||
- universal argument for opening buffer in another window?
|
||||
** TODO Ivy Parity
|
||||
*** TODO pass module
|
||||
*** TODO remaps
|
||||
refactor these to use consult so previews can work, also maybe have narrowed number keys for workspaces?
|
||||
#+begin_src elisp
|
||||
[remap switch-to-buffer] #'+ivy/switch-buffer
|
||||
[remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window
|
||||
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer
|
||||
[remap evil-show-jumps] #'+ivy/jump-list
|
||||
#+end_src
|
||||
*** TODO ~+ivy/jump-list~ analogue
|
||||
*** TODO ~+irc/selectrum-jump-to-channel~
|
||||
rework to use ~consult~ buffer narrowing, for some reason the current attempt breaks marginalia annotating
|
||||
*** WAIT lookup module
|
||||
|
|
47
modules/completion/selectrum/autoload/workspaces.el
Normal file
47
modules/completion/selectrum/autoload/workspaces.el
Normal file
|
@ -0,0 +1,47 @@
|
|||
;;; completion/selectrum/autoload/workspaces.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! :ui workspaces)
|
||||
|
||||
;;;###autoload
|
||||
(defun +selectrum--workspace-nth-source (n)
|
||||
"Generate a consult buffer source for buffers in the NTH workspace"
|
||||
(cond ((numberp n)
|
||||
`(:name ,(nth (1- n) (+workspace-list-names))
|
||||
:hidden ,(not (string= (+workspace-current-name) (nth (1- n) (+workspace-list-names))))
|
||||
:narrow ,(string-to-char (number-to-string n))
|
||||
:category buffer
|
||||
:state ,#'consult--buffer-state
|
||||
:items ,(lambda () (mapcar #'buffer-name (+workspace-buffer-list (nth (1- 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))))))))
|
||||
(t
|
||||
(user-error "invalid workspace source %s" n))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +selectrum--workspace-generate-sources ()
|
||||
"Generate list of consult buffer sources for all workspaces"
|
||||
(mapcar #'+selectrum--workspace-nth-source '(1 2 3 4 5 6 7 8 9 final)))
|
||||
|
||||
(autoload 'consult--multi "consult")
|
||||
;;;###autoload
|
||||
(defun +selectrum/switch-workspace-buffer ()
|
||||
"Switch to another buffer in the same workspace.
|
||||
|
||||
Use consult narrowing with another workspace number to open a buffer from that workspace
|
||||
BUG but it opens it in the current workspace (ivy also does this, but who cares)"
|
||||
(interactive)
|
||||
(when-let (buffer (consult--multi (+selectrum--workspace-generate-sources)
|
||||
:require-match
|
||||
(confirm-nonexistent-file-or-buffer)
|
||||
:prompt (format "Switch to buffer (%s): "
|
||||
(+workspace-current-name)
|
||||
:history 'consult--buffer-history
|
||||
:sort nil)))
|
||||
;; When the buffer does not belong to a source,
|
||||
;; create a new buffer with the name.
|
||||
(unless (cdr buffer)
|
||||
(funcall consult--buffer-display (car buffer)))))
|
|
@ -91,7 +91,8 @@
|
|||
[remap switch-to-buffer-other-window] #'consult-buffer-other-window
|
||||
[remap switch-to-buffer-other-frame] #'consult-buffer-other-frame
|
||||
[remap yank-pop] #'consult-yank-pop
|
||||
[remap describe-bindings] #'embark-bindings)
|
||||
[remap describe-bindings] #'embark-bindings
|
||||
[remap persp-switch-to-buffer] #'+selectrum/switch-workspace-buffer)
|
||||
(setq completion-in-region-function #'consult-completion-in-region)
|
||||
:config
|
||||
(recentf-mode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue