selectrum: autoload +selectrum/backward-updir...
and make it independent of selectrum
This commit is contained in:
parent
336ad46c47
commit
7c313fbac2
2 changed files with 18 additions and 12 deletions
|
@ -74,6 +74,24 @@ If ARG (universal argument), include all files, even hidden or compressed ones."
|
||||||
(interactive)
|
(interactive)
|
||||||
(consult-line (thing-at-point 'symbol)))
|
(consult-line (thing-at-point 'symbol)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +selectrum/backward-updir ()
|
||||||
|
"Delete char before or go up directory for file cagetory selectrum 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
|
;;;###autoload
|
||||||
(defun +selectrum/embark-export-write ()
|
(defun +selectrum/embark-export-write ()
|
||||||
"Export the current selectrum results to a writable buffer if possible.
|
"Export the current selectrum results to a writable buffer if possible.
|
||||||
|
|
|
@ -9,18 +9,6 @@
|
||||||
(when (featurep! +prescient)
|
(when (featurep! +prescient)
|
||||||
(setq completion-styles '(substring partial-completion)))
|
(setq completion-styles '(substring partial-completion)))
|
||||||
:config
|
:config
|
||||||
(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
|
||||||
[backspace] #'+selectrum/backward-updir))
|
[backspace] #'+selectrum/backward-updir))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue