Stabilize directory backspace in minibuffer, see link in comment

This commit is contained in:
MitchMarq42 2022-10-06 10:24:25 -08:00
parent be10bfa930
commit 789a91219f

View File

@ -198,13 +198,15 @@ This is taken from a website that I can't remember at the moment."
(add-hook 'minibuffer-setup-hook 'turn-off-line-numbers)
(defun backspace-in-minibuffer ()
"If previous character is `/', kill to the previous `/'.
Otherwise, kill back 1 letter."
Otherwise, kill back 1 letter.
see https://www.reddit.com/r/emacs/comments/xq6rpa/comment/iqynyu9/?utm_source=share&utm_medium=web2x&context=3"
(interactive)
(if (= (string-to-char "/") (preceding-char))
(progn
(delete-region (- (point) 1)
(search-backward "/" nil nil 2))
(goto-char (1+ (point))))
(if (string-match-p "/." (minibuffer-contents))
(let ((end (point)))
(re-search-backward "/.")
(forward-char)
(delete-region (point) end))
(backward-delete-char 1)))
:general
(general-define-key