selectrum: improve file category commands...

now when pressing backspace on `/`, the input will go up one directory.
This commit is contained in:
Itai Y. Efrat 2021-05-01 13:58:02 +03:00
parent e181318885
commit 6dfc32441d
2 changed files with 17 additions and 5 deletions

View file

@ -17,9 +17,6 @@ gets us close but moves the cursor to the new screen which is undesirable.
* PROJ List of things needed for Ivy parity * PROJ List of things needed for Ivy parity
** TODO Icons ** TODO Icons
https://github.com/minad/marginalia/issues/59 https://github.com/minad/marginalia/issues/59
** TODO make backspace work in filepath searching
In ivy, backspace on =/foo/bar/!= (where =!= is the cursor) leads to =/foo/!=
In selectrum, it leads to =/foo/bar!=
** TODO =SPC s B= ** TODO =SPC s B=
** TODO modules to look over ** TODO modules to look over
- lookup - lookup

View file

@ -14,9 +14,24 @@
(defadvice! +selectrum-refresh-on-cycle (&rest _) (defadvice! +selectrum-refresh-on-cycle (&rest _)
:after 'marginalia-cycle :after 'marginalia-cycle
(when (bound-and-true-p selectrum-mode) (selectrum-exhibit))) (when (bound-and-true-p selectrum-mode) (selectrum-exhibit)))
(defun +selectrum/backward-updir ()
"Delete char before or go up directory for file cagetory selectrum buffers."
(interactive)
(if (and (eq (char-before) ?/)
(eq (selectrum--get-meta '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)))
(map! :map selectrum-minibuffer-map (map! :map selectrum-minibuffer-map
"C-o" #'embark-act "C-o" #'embark-act
"C-c C-o" #'embark-export)) "C-c C-o" #'embark-export
[backspace] #'+selectrum/backward-updir))
(use-package! selectrum-prescient (use-package! selectrum-prescient
:when (featurep! +prescient) :when (featurep! +prescient)