I want to add keybinding to Dired mode for entering directory, and ONLY directory. By default enter key is bound to function dired-find-file
. The problem with it is that its or opening new dired buffer if it is directory under cursor, or open file for editing if its file.
So I added two shortcuts for going to parent directory and stepping in directory under cursor this way:
(define-key dired-mode-map (kbd "<left>") 'dired-jump)
(define-key dired-mode-map (kbd "<right>") 'dired-find-file)
As you may guess the problem is in last - dired-find-file
will work on non-directories too, and I want it not to do anything. So my question - is there a specific function for stepping in directory under cursor or, if not - is there a way to check if there is directory under cursor in dired mode to construct my own function? Thx.
dired
i
command, which gives an error if it's not a directory and expands it in the current buffer if it is. If that's not what you wanted, looking at the source for it might be a good start.