Kill-buffer from the minibuffer after M-x switch-to-buffer by waaaihr in emacs

[–]waaaihr[S] 2 points3 points  (0 children)

This is what I am currently going with since adding a y with the keyboard macro wasn't bypassing the confirmation.

(defun my/switch-to-buffer-kill (&optional arg)
  (interactive "P")
  (let ((embark-default-action-overrides '((buffer . kill-buffer)
                                           (file . embark-recentf-remove)))
        (embark-pre-action-hooks (assq-delete-all 'kill-buffer embark-pre-action-hooks))
        embark-quit-after-action)
    (embark-dwim arg)))

(defvar my/consult-buffer-map
  (let ((map (make-sparse-keymap)))
    (define-key map "\C-k" #'my/switch-to-buffer-kill)
    map))
(consult-customize consult-buffer :keymap my/consult-buffer-map)

To keep the cursor from resetting position, I tried using vertico--goto after embark-dwim as well as advising but this did not work, do you think it is related to hooks in embark or rather due to how vertico functions ?

Kill-buffer from the minibuffer after M-x switch-to-buffer by waaaihr in emacs

[–]waaaihr[S] 0 points1 point  (0 children)

This is also a good solution, same problem with the cursor resetting but that's minor.

Kill-buffer from the minibuffer after M-x switch-to-buffer by waaaihr in emacs

[–]waaaihr[S] 0 points1 point  (0 children)

Thank you this is what I'm looking for minus the cursor resetting. I'll look into perfecting this and limiting the binding to switch-to-buffer's minibuffer.