From 9241a4d709fd39ae630a2fdaeca2d84b4bd842ac Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Sun, 22 Aug 2021 15:22:28 +0300 Subject: [PATCH] refactor(vertico): file completion backspace Switch from the homemade +vertico/backward-updir to the upstream vertico-directory-delete-char. The former has the nice feature of traversing up abbreviated paths, but this comes at the cost of not being able to fully erase the path (since the buck stops at /), and unintentional directory moving in commands such as +vertico/find-file-in which causes issues. Overall this minor convenience is not worth it, so the vertico-directory-delete-char behaviour of just deleting up to the previous / is preferred instead. --- modules/completion/vertico/autoload/vertico.el | 17 ----------------- modules/completion/vertico/config.el | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/modules/completion/vertico/autoload/vertico.el b/modules/completion/vertico/autoload/vertico.el index 44c255483..51b52c4af 100644 --- a/modules/completion/vertico/autoload/vertico.el +++ b/modules/completion/vertico/autoload/vertico.el @@ -95,23 +95,6 @@ If ARG (universal argument), include all files, even hidden or compressed ones." (interactive) (consult-line (thing-at-point 'symbol))) -;;;###autoload -(defun +vertico/backward-updir () - "Delete char before or go up directory for file cagetory vertico buffers." - (interactive) - (let ((metadata (completion-metadata (minibuffer-contents) - minibuffer-completion-table - minibuffer-completion-predicate))) - (if (and (eq (char-before) ?/) - (eq (completion-metadata-get metadata 'category) 'file)) - (let ((new-path (minibuffer-contents))) - (delete-region (minibuffer-prompt-end) (point-max)) - (insert (abbreviate-file-name - (file-name-directory - (directory-file-name - (expand-file-name new-path)))))) - (call-interactively 'backward-delete-char)))) - ;;;###autoload (defun +vertico-embark-target-package-fn () "Targets Doom's package! statements and returns the package name" diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index 9769b34ca..2c89c25fa 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -26,7 +26,7 @@ overrides `completion-styles' during company completion sessions.") ;; Cleans up path when moving directories with shadowed paths syntax, e.g. ;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/. (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy) - (map! :map vertico-map [backspace] #'+vertico/backward-updir)) + (map! :map vertico-map [backspace] #'vertico-directory-delete-char)) (use-package! orderless