Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

See How can I get emacs under windows to autocomplete paths in shell buffers using "\" instead of "/"?

I use emacs on windows 7, when calling M-x shell, emacs opens a DOS-Shell. The prompt displays current directory using backslashes "\".

Wenn I type a path, say "C:\Te" and press [TAB] for completion, emacs completes the path to "C:/Temp/". This is ok for wirking inside emacs, but not for calling DOS-Commands or executing binaries or batch files in DOS.

Example: Command C:/Temp/a.bat fails. C:\Temp\a.bat executes fine.

The situation in emacs 24.* seems to be even worse. I thought I'd be an experienced emacs user but couldn't find a way to apply the patch named above to emacs 24.*. comint mode seems to have changed a lot.

share|improve this question
    
1. Perhaps give an example of the behavior you expect vs what you see. 2. Just why do you want to use \ as a directory separator in this context? Is it, e.g., because you have yanked a Windows-style "path" that has such separators? If not, why not just use / as the separator, as in the rest of Emacs? – Drew Oct 2 '13 at 2:16
    
@Drew The Windows command shell uses forward slash to introduce options, so paths containing it aren't properly interpreted. – Aaron Miller Oct 3 '13 at 20:30
    
@AaronMiller -- Oh, right; silly me. – Drew Oct 3 '13 at 21:07

Try this hack. It seems to work in emacs 24.5:

(defun win-file-name-completion-advice (res)
  (if (stringp res) (replace-regexp-in-string "/" "\\\\" res) res))
(advice-add 'comint-completion-file-name-table
            :filter-return #'win-file-name-completion-advice)

(defun win-command-completion-advice ()
  (let ((filename (comint-match-partial-filename)))
    (and filename (not (string-match "\\\\" filename)))))
(advice-add 'shell-command-completion
            :before-while #'win-command-completion-advice)
share|improve this answer

Topic 258683 descripes an appropriate solution:

  • in file ~\.emacs
  • add line (setq comint-completion-addsuffix (quote ("\\" . " ")))
share|improve this answer
    
Actually, no. It explicitly says its working well only for emacs 22. This question was for emacs 24. – sandos Nov 19 '15 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .