0

In emacs, I press M-x shell to create a shell in a buffer.

In the shell, I can use autocomplete file names with respect to the current working directory.

If outside the shell e.g. in Nautilus, I move the current directory somewhere else, then back in the shell, the autocompletion of file names will not be working correctly, still with respect to the old pathname of the current working directory.

I tried to refresh the buffer of the shell by M-x revert-buffer, but it didn't work because the buffer didn't open a file but a shell.

How can I solve the problem?

Thanks.

1

M-enter will re-sync the directory. It is bound to shell-resync-dirs.

Basic functionality of the function is to call command dirs This can be altered by changing variable shell-dirstack-query. Because output is read directly from the buffer code can get confused, if it reads wrong line.

Sometimes Emacs says "Couldn’t cd: (error No such directory found via CDPATH environment variable)". One of the reason is that the resync command does not read the right path from the output. It does not expect command to be echoed by the shell process. In this case change comint-process-echoes to true.

If all else fails directory can be set manually using invoking cd-function (M-x cd).

  • Thanks, but M-enter doesn't work. – Tim Jan 14 '17 at 5:39
  • Does the shell-resync-dirs? – Panu Jan 14 '17 at 6:12
  • When running M-x shell-resync-dirs, it says Couldn't cd. it doesn't work. – Tim Jan 14 '17 at 6:20
  • Try changing comint-process-echoesto non-nil value. M-x eval-expression and (setq comint-process-echoes t). – Panu Jan 14 '17 at 9:38
  • Still not works. – Tim Jan 14 '17 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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