- 解决方案1:在
.emacs
文件中添加(cd "C:/Users/Name/Desktop")
- 解决方案2:在
.emacs
文件中添加(setq default-directory "C:/Documents and Settings/USER NAME/Desktop/")
- 解决方案3:右键单击emacs快捷方式,点击属性并将“启动位置”字段更改为所需目录。
我相信我的
.emacs
文件是正确的,因为当我从.emacs
文件中添加/删除(load-theme 'light-blue t)
时,我的主题会被正确地加载/卸载。以下是我最近的
.emacs
文件:(message "Default Dir: %S" default-directory)
(setq-default default-directory "C:/Users/Lucas/")
(message "Default Dir: %S" default-directory)
(setq-default indent-tabs-mode nil)
(add-hook 'ruby-mode-hook
(lambda ()
(define-key ruby-mode-map "\C-c#" 'comment-or-uncomment-region)
)
)
(defadvice comment-or-uncomment-region (before slick-comment activate compile)
"When called interactively with no active region, comment a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
(load-theme 'light-blue t)
;setq default-directory "~/")
(setq-default default-directory "C:/Users/Lucas/")
(defun xp-read-file-name (prompt &optional dir default-filename mustmatch initial predicate)
(setq last-nonmenu-event nil)
(funcall (or read-file-name-function #'read-file-name-default)
prompt dir default-filename mustmatch initial predicate))
(defun xp-save-as (filename &optional confirm)
(interactive
(list (if buffer-file-name
(xp-read-file-name "Write file: " nil nil nil nil)
(xp-read-file-name "Write file: " "C:/Users/Lucas/"
(expand-file-name
(file-name-nondirectory (buffer-name))
"C:/Users/Lucas/")
nil nil))
(not current-prefix-arg)))
(or (null filename) (string-equal filename "")
(progn
(if (file-directory-p filename)
(setq filename (concat (file-name-as-directory filename)
(file-name-nondirectory
(or buffer-file-name (buffer-name))))))
(and confirm
(file-exists-p filename)
(not (and (eq (framep-on-display) 'ns)
(listp last-nonmenu-event)
use-dialog-box))
(or (y-or-n-p (format "File `%s' exists; overwrite? " filename))
(error "Canceled")))
(set-visited-file-name filename (not confirm))))
(set-buffer-modified-p t)
(and buffer-file-name
(file-writable-p buffer-file-name)
(setq buffer-read-only nil))
(save-buffer)
(vc-find-file-hook))
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)
(next-line)))
(global-set-key (kbd "C-x C-;") 'comment-region)
(setq lazy-highlight-cleanup nil)
(message "Default Dir: %S" default-directory)
我的
emacs.exe
保存在C:\emacs\emacs-24.3\bin
下(这也是我的默认目录,但我想将其更改为C:/Users/Lucas/
),我的.emacs
位于我的主目录下 - C:\Users\Lucas
。更新
最近我发现我的命令
(setq-default default-directory "C:/Users/Lucas/")
,它应该设置我的default-directory
,但没有生效。在启动后立即查看我的*Messages*
缓冲区:Default Dir: "C:\\emacs\\emacs-24.3\\bin/" [3 times]
For information about GNU Emacs and the GNU system, type C-h C-a.
它的行为就像我在覆盖.emacs
文件一样。我进行了双倍/三倍检查,并且在我的路径中找不到另一个.emacs
。此外,我没有从快捷方式运行Emacs。如果有任何建议,将不胜感激。感谢所有支持。
default-directory
的值是一个问题?) - philsC:/Users/Lucas/
。我的当前设置似乎忽略了我在.emacs
文件中的(setq default-directory "C:/Users/Lucas/")
这一行。 - modulitosHOME
环境变量设置了冲突的值吗? - SlowLearnerload-path
、default-directory
或者说invocation-directory
之间没有任何联系。 - Drew