Preventing automatic change of default-directory

后端 未结 3 851
执笔经年
执笔经年 2021-01-01 19:55

As per the Emacs docs, every time you open a file, Emacs changes default-directory to the directory containing that file.

Then, if the cursor is in th

3条回答
  •  情书的邮戳
    2021-01-01 20:10

    This is the best I've come up with so far, sadly:

    (defun find-file-save-directory ()
        (interactive)
        (setq saved-default-directory default-directory)
        (ido-find-file)
        (setq default-directory saved-default-directory))
    (global-set-key "\C-x\C-f" 'find-file-save-directory)
    

    This works as long as default-directory is properly set before I C-x C-f. I'm going to Accept jurta's answer for pointing me in a useful direction.

提交回复
热议问题