Closed bastidest closed 4 months ago
Hi. I tried to replicate this but can't. Are you sure you are calling dired-narrow-enter-directory
(bound to right arrow key or C-j
) and not the regular dired find file?
Thank you for your response. Your screencast shows my desired result. I tested it on a different system with the configuration shown above and was still able to reproduce my issue.
The screenshot shows a dired-narrow buffer filtering by the word auto
. I changed focus from the minibuffer to the dired buffer and confirmed that the C-j
binding does indeed call dired-narrow-enter-directory
(C-h c
). The issue still persists.
Have you tried to reproduce this with emacs -Q
? I will try to test it on emacs 27 when I get the chance.
I'm actually on E26, so that might be the variable which is different here.
I reproduced it on emacs 27.2 and emacs 26.
Docker commands:
docker run --rm -it silex/emacs:27.2-alpine
docker run --rm -it silex/emacs:26-alpine
Steps:
*scratch*
buffer
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package))
(use-package dired-narrow :ensure t :after (dired) :bind (:map dired-mode-map ("/" . dired-narrow)))
3. `M-x` `eval-buffer`
4. `C-x d` --> dired opens at `/`
5. `/` --> `dired-narrow` mode in minibuffer
6. `etc` --> filters etc directory
7. `C-j` --> Bug
You're not binding dired-narrow-enter-directory
in your repro case. However, I added the binding and can reproduce the bug. So there must be something on my system fixing it.
Binding it should not be necessary, right? At least the default keymap shows the bindings (describe-keymap
)
dired-narrow-map is a keymap variable defined in ‘dired-narrow.el’.
Documentation:
Keymap used while ‘dired-narrow’ is reading the pattern.
key binding
--- -------
C-g minibuffer-keyboard-quit
C-j dired-narrow-enter-directory
RET exit-minibuffer
C-n dired-narrow-next-file
C-p dired-narrow-previous-file
<down> dired-narrow-next-file
<return> exit-minibuffer
<right> dired-narrow-enter-directory
<up> dired-narrow-previous-file
I figured it out. By default, the dired-narrow-exit-action
is set to ignore
so it does nothing. I had it set to dired-narrow-find-file
, so when I exited the minibuffer with C-j
it called this function and remembered that I used the enter-directory command so it restarted the search.
For you, since your exit action is most likely just the default ignore, it executed that (= did nothing) and then restarted the narrowing in the same buffer.
Your fix was to call the dired-narrow-find-file
when acting on a directory, however, you call it after the default action runs. So for someone like me, it would actually call the exit action twice (once from the config and once from your patch).
I reordered the conditions so that in case of the enter directory action the exit-action is simply ignored because it doesn't actually make sense... our action is to enter the directory so we shouldn't run anything else.
Thank you for the contribution, your code helped me figure out the problem!
Information
emacs -q
?Emacs Configuration:
Bug Description
May be related to #147 . Please confirm that the described behavior is intended as such (I might not understand
dired-narrow-enter-directory
correctly).Expected Behavior
After entering
dired-narrow-mode
and selecting a directory (by filtering and moving the point), callingdired-narrow-enter-directory
should enter the directory at point and start another dired-narrow minibuffer.Actual Behavior
After entering
dired-narrow-mode
and selecting a directory, callingdired-narrow-enter-directory
does not enter the directory, but simply restarts narrowing in the current (already narrowed) directory.Change Description
Before this change, when
dired-narrow-enter-directory
was called, thedired-narrow--internal
function did call itself to start another instance of dired narrow in the subdirectory. However it did not visit the directory at point, which restarted dired-narrow in the current (already filtered) directory.With this change
dired-narrow-find-file
is called before restartingdired-narrow--internal
. This will visit the directory at point and start another dired-narrow instance. If the current file is not a directory, visit the file at point.Comment
Thank you for maintaining this package!