[英]Change the default directory of emacs with 'cocoa emacs'
As explained in here , putting (setq default-directory "~/Desktop/mag" ) in .emacs is supposed to change the default directory. 正如上文这里 ,把(setq默认目录“〜/桌面/ MAG”)中的.emacs应该更改默认目录。
When I do that with the emacs on my mac, it doesn't work. 当我使用我的mac上的emacs执行此操作时,它不起作用。 Cx Cf still shows ~/ not ~/Desktop/mag.
Cx Cf仍显示〜/ not~ / Desktop / mag。
(cd "Users/smcho/Desktop/mag") also gives me this error - Error: No such directory found via CDPATH environment variable (cd“Users / smcho / Desktop / mag”)也给我这个错误 - 错误:没有通过CDPATH环境变量找到这样的目录
What's wrong with them? 他们怎么了?
The directory that appears in the prompt for Cx Cf ('find-file') comes from the value of default-directory, which is a buffer-local variable. 出现在Cx Cf('find-file')提示符中的目录来自default-directory的值,该目录是一个缓冲区局部变量。 When you first start Emacs, the initial buffer displayed is the GNU Emacs buffer.
首次启动Emacs时,显示的初始缓冲区是GNU Emacs缓冲区。 That buffer's default-directory is set from the variable command-line-default-directory.
该缓冲区的default-directory是从变量command-line-default-directory设置的。
So, try this: 所以,试试这个:
(setq command-line-default-directory "~/Desktop/mag")
The straight-forward answer to your question is: 您问题的直接答案是:
(setq-default default-directory "~/Desktop/mag")
Reading the documentation for the variable ( Ch v default-directory RET ) you'll see: 阅读变量的文档( Ch v default-directory RET ),您将看到:
Automatically becomes buffer-local when set in any fashion.
以任何方式设置时自动变为缓冲本地。 This variable is safe as a file local variable if its value satisfies the predicate `stringp'.
如果该变量的值满足谓词“stringp”,则该变量作为文件局部变量是安全的。
That said, opening a file automatically sets the default-directory
to the path of the file... 也就是说,打开文件会自动将
default-directory
设置为文件的路径...
So, if you always want find-file
to start at that directory, you can use this: 因此,如果您始终希望
find-file
从该目录开始,您可以使用:
(global-set-key (kbd "C-x C-f") 'my-find-file)
(defun my-find-file ()
"force a starting path"
(interactive)
(let ((default-directory "~/scratch/"))
(call-interactively 'find-file)))
This question may be a duplicate of Preventing automatic change of default-directory . 此问题可能与防止默认目录的自动更改重复。 Though it's difficult to tell.
虽然很难分辨。
除了上面关于default-directory
的注释之外,我还必须阻止emacs启动屏幕启动,以便在启动时从.emacs
调用后,像dired
这样的后续命令实际显示其缓冲区:
(setq inhibit-splash-screen t)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.