更改 Emacs 中的默认文件夹 [英] Changing the default folder in Emacs

查看:18
本文介绍了更改 Emacs 中的默认文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Emacs 还很陌生,我一直在尝试弄清楚如何在启动时更改 C-x C-f 的默认文件夹.例如,当我第一次加载 Emacs 并点击 C-x C-f 时,它的默认文件夹是 C:emacsemacs-21.3in,但我宁愿它是桌面.我相信有一些方法可以自定义 .emacs 文件来做到这一点,但我仍然不确定那是什么.

更新:我发现该问题有三种解决方案,但我认为解决方案 3 仅适用于 Windows.

  • 方案一:在.emacs文件中添加(cd "C:/Users/Name/Desktop")

  • 方案二:在.emacs文件中添加(setq default-directory "C:/Documents and Settings/USER_NAME/Desktop/")p>

  • 解决方案 3:右键单击 Emacs 快捷方式,点击属性并将开始输入字段更改为所需目录.

解决方案

您没有这么说,但听起来您是从 Windows 快捷方式启动 Emacs.

您使用 c-x c-f 看到的目录是 cwd,在 Emacs 术语中,是 default-directory(一个变量).

当您使用 MS Windows 快捷方式启动 Emacs 时,default-directory 最初是在快捷方式属性的开始于"字段中指定的文件夹(目录).右键单击快捷方式,选择 Properties,然后在 Start In 字段中输入桌面路径.

如果您从命令行使用 Emacs,default-directory 将作为您启动 Emacs 的目录(cwd)开始.

这种方法比编辑您的 .emacs 文件更好,因为它允许您拥有多个带有多个起始目录的快捷方式,并且如果您需要,它可以让您拥有 Emacs 的正常命令行行为.

CWD = 当前工作目录 = PWD = 当前工作目录.它在命令行中比在 GUI 中更有意义.

I am fairly new to Emacs and I have been trying to figure out how to change the default folder for C-x C-f on start-up. For instance when I first load Emacs and hit C-x C-f its default folder is C:emacsemacs-21.3in, but I would rather it be the desktop. I believe there is some way to customize the .emacs file to do this, but I am still unsure what that is.

Update: There are three solutions to the problem that I found to work, however I believe solution 3 is Windows only.

  • Solution 1: Add (cd "C:/Users/Name/Desktop") to the .emacs file

  • Solution 2: Add (setq default-directory "C:/Documents and Settings/USER_NAME/Desktop/") to the .emacs file

  • Solution 3: Right click the Emacs short cut, hit properties and change the start in field to the desired directory.

解决方案

You didn't say so, but it sounds like you're starting Emacs from a Windows shortcut.

The directory that you see with c-x c-f is the cwd, in Emacs terms, the default-directory (a variable).

When you start Emacs using an MS Windows shortcut, the default-directory is initially the folder (directory) specified in the "Start In" field of the shortcut properties. Right click the shortcut, select Properties, and type the path to your desktop in the Start In field.

If you're using Emacs from the command line, default-directory starts as the directory where you started Emacs (the cwd).

This approach is better than editing your .emacs file, since it will allow you to have more than one shortcuts with more than one starting directory, and it lets you have the normal command line behavior of Emacs if you need it.

CWD = current working directory = PWD = present working directory. It makes a lot more sense at the command line than in a GUI.

这篇关于更改 Emacs 中的默认文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆