-
|
I recently moved from I've implemented something similar and it's working okay. The main problem is that the whole vertico session gets restarted after killing, so it's not very smooth... Is there anything built-in to vertico for this that I'm missing? If not, any suggestions for improving the below code to avoid losing the vertico session? (use-package vertico
:ensure t
:custom
(vertico-cycle t)
:init
(vertico-mode)
:config
(defun m/kill-current-consult-buffer ()
"Kill the currently selected buffer in `consult-buffer'."
(interactive)
(let* ((candidate (vertico--candidate))
(multi-cat (get-text-property 0 'multi-category candidate))
(buf-name (when (consp multi-cat) (cdr multi-cat)))
(buf (and buf-name (get-buffer buf-name))))
(if (and buf (buffer-live-p buf))
(progn
(kill-buffer buf)
(message "Killed buffer: %s" buf-name)
(call-interactively 'consult-buffer))
(message "No live buffer found to kill"))))
:bind
(:map
vertico-map
("C-l" . vertico-directory-up)
("C-k" . m/kill-current-consult-buffer)))Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
I know I can do this with |
Beta Was this translation helpful? Give feedback.
-
|
Here's what I've come up with: (use-package vertico
:ensure t
:custom
(vertico-cycle t)
:init
(vertico-mode)
:config
(defun m/kill-current-buffer-embark (&optional arg)
"Kill the current buffer candidate using Embark."
(interactive "P")
(let ((kill-buffer-query-functions (delq 'process-kill-buffer-query-function
kill-buffer-query-functions))
(embark-default-action-overrides '((buffer . kill-buffer)))
; These next two suppress confirmations from embark itself
embark-pre-action-hooks
embark-quit-after-action)
(embark-dwim arg)))
(defvar m/consult-buffer-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-k") #'m/kill-current-buffer-embark)
map))
(consult-customize consult-buffer :keymap m/consult-buffer-map)
:bind
(:map
vertico-map
("C-l" . vertico-directory-up)))This performs the buffer killing via embark, without confirmation, and also moves the keybinding to be |
Beta Was this translation helpful? Give feedback.
Here's what I've come up with: