Skip to content

Commit 9241a4d

Browse files
committed
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.
1 parent 161d48c commit 9241a4d

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

modules/completion/vertico/autoload/vertico.el

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,6 @@ If ARG (universal argument), include all files, even hidden or compressed ones."
9595
(interactive)
9696
(consult-line (thing-at-point 'symbol)))
9797

98-
;;;###autoload
99-
(defun +vertico/backward-updir ()
100-
"Delete char before or go up directory for file cagetory vertico buffers."
101-
(interactive)
102-
(let ((metadata (completion-metadata (minibuffer-contents)
103-
minibuffer-completion-table
104-
minibuffer-completion-predicate)))
105-
(if (and (eq (char-before) ?/)
106-
(eq (completion-metadata-get metadata 'category) 'file))
107-
(let ((new-path (minibuffer-contents)))
108-
(delete-region (minibuffer-prompt-end) (point-max))
109-
(insert (abbreviate-file-name
110-
(file-name-directory
111-
(directory-file-name
112-
(expand-file-name new-path))))))
113-
(call-interactively 'backward-delete-char))))
114-
11598
;;;###autoload
11699
(defun +vertico-embark-target-package-fn ()
117100
"Targets Doom's package! statements and returns the package name"

modules/completion/vertico/config.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ overrides `completion-styles' during company completion sessions.")
2626
;; Cleans up path when moving directories with shadowed paths syntax, e.g.
2727
;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/.
2828
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
29-
(map! :map vertico-map [backspace] #'+vertico/backward-updir))
29+
(map! :map vertico-map [backspace] #'vertico-directory-delete-char))
3030

3131

3232
(use-package! orderless

0 commit comments

Comments
 (0)