When I run shell-resync-dirs 1, the function hangs, until I press C-g, at which this point, what looks suspiciously like the output of my shell's dirs -l command 2 gets inserted into my buffer at point, and my shell prints a newline and a new prompt. (Point remains unchanged throughout all this.) As far as I can tell, the shell-resync-dirs never gets to do what it is supposed to do, since shell-dirstack remains unchanged (and as out-of-sync as it was when I invoked the function).

I would like to find out why shell-resync-dirs hangs when I invoke it.

In particular, I would like to trace the execution of shell-resync-dirs.

Naively, I tried using trace-function, but this did not have the desired effect. All I get from this is that Emacs will notify me when shell-resync-dirs starts execution and when it terminates, which tells me nothing that I don't already know.

Is there a simple way to trace the evaluation of the various expressions within the definition of shell-resync-dirs?

1 For this post, please assume that the current buffer is an inferior shell started with M-x shell. Also, my shell is /bin/zsh.

2 For what it's worth, "dirs -l" is the value I have assigned to the variable shell-dirstack-query.

  • 2
    That happens to me occasionally as well, but I've never figured out the root cause. Thanks for asking the question!
    – NickD
    Sep 18, 2021 at 23:30

1 Answer 1


I was having a similar problem and discovered that I had comint-process-echoes set to t in comint-mode-hook, I think as part of some experiment with using zsh instead of bash. Setting it back to the default of nil fixed the M-x dirs hanging issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.