M-x shell-resync-dirs
RET
或者简单地使用默认快捷键:M-RET
Resync the buffer's idea of the current directory stack.
This command queries the shell with the command bound to
`shell-dirstack-query' (default "dirs"), reads the next
line output and parses it to form the new directory stack.
DON'T issue this command unless the buffer is at a shell prompt.
Also, note that if some other subprocess decides to do output
immediately after the query, its output will be taken as the
new directory stack -- you lose. If this happens, just do the
command again.
在dos中可能会有所不同。
我认为您需要执行
(setq shell-dirstack-query "cd")
,因为dos中默认的
dirs
命令不存在。没有参数的
cd
似乎是所需的内容。
在我的win32计算机上,我看到所有命令都被回显,这会干扰
shell-resync-dirs
尝试读取正确目录的操作,因此您可能需要参考
http://www.gnu.org/software/emacs/manual/html_node/efaq-w32/Shell-echo.html
然而,即使已经做了所有的事情,它仍然不可靠。我相信路径中的空格会导致错误。如果您的路径中没有空格,则可能没问题。
编辑: 是的,在那里有一个不太理想的正则表达式尝试解析目录:
;; regexp = optional whitespace, (non-whitespace), optional whitespace
(string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
我不确定这里有什么可能的可移植性问题,但您可以将其更改为以下内容以适应您的目的:
(string-match "\\s *\\(.+\\S +\\)\\s *" dl i)
那段代码在M-x find-function
RET shell-resync-dirs
RET中。
我看到有几个相关的Emacs错误报告(11607和11608)。您可能想要跟进这些报告。