Fork me on GitHub
#emacs
<
2021-06-09
>
Burin14:06:09

Hi, Does anyone know how can I get the backspace to skip pass just one char when using it with dired from top level directory to base directory? e.g.

Find file: ~/projects/some-project/sub-dir

# When I press Backspace at the sub-dir level I want it to go directly to 
~/projects/some-project/ not by one char e.g.
~/projects/some-projec 

Burin14:06:38

In Spacemacs, it seems I can get the effect by pressing Ctl-h, but what I want is this to be the default behavior when pressing backspace.

Burin14:06:26

Probably dired-up-directory?

lukasz14:06:30

You can use ^ to jump up. That said, one of the packages I have installed (ivy?) enables the mode you're asking about - pressing delete/backspace removes a single path segment not a single character

👍 2
tvaughan14:06:58

(defun tvaughan/parent-directory (path)
  "Return the parent directory of PATH."
  (or (file-name-directory (directory-file-name path)) ""))

(defun tvaughan/backward-delete-directory (arg)
  "Delete characters backward until encountering the end of a word.
With ARG, do this that many times."
  (interactive "p")
  (let ((contents (minibuffer-contents)))
    (delete-minibuffer-contents)
    (insert (tvaughan/parent-directory contents))))

(use-package selectrum
  :config
  (selectrum-mode +1))

(define-key selectrum-minibuffer-map (kbd "DEL") #'tvaughan/backward-delete-directory)

👍 2
tvaughan14:06:27

ido does this much better. This still doesn't replicate it as well. Granted, this is used with selectrum, but should be adaptable

grazfather15:06:52

Is Ido basically a competitor for help or ivy?

Burin16:06:03

Thanks @U01KUQRDMLG after adding ivy, and now I get the desired effect that I want. I am trying a new config and can’t remember how this work with my old config. And ivy package seems to be the one that I really need.

👍 5