在emacs中编辑.emacs.el时,我运行了Alt + X eval-buffer命令。 我的操作系统是Windows。 当我重新启动emacs时,它会显示以下警告:
警告(初始化):加载时发生错误 `... / emacs.el':
错误:用于Unicode转义的非十六进制数字
为确保正常操作,您应该调查并删除 初始化文件中的错误原因。用。启动Emacs `--debug-INIT'用于查看完整错误回溯的选项。
.emacs.el是:
;;Open all fine in one running instance
;;Ref:http://www.johndcook.com/blog/2010/07/28/miscellaneous-emacs-adventures/
;;(server-start)
;;TEST
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
`(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
`(custom-enabled-themes (quote (wheatgrass))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;Set auto save backup location, failed with following warning
(setq backup-directory-alist
`((".*" . ,"D:\Unix-Tmp")))
(setq auto-save-file-name-transforms
`((".*" ,"D:\Unix-Tmp" t)))
(require 'recentf)
(recentf-mode 1)
(setq inhibit-startup-screen t)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;;Aspell install failed
;;(setq-default ispell-program-name "C:/bin/Aspell/bin/aspell.exe")
;;(setq text-mode-hook '(lambda() (flyspell-mode t) ))
我如何解决它?
答案 0 :(得分:5)
问题在于以下几点:
(setq backup-directory-alist
`((".*" . ,"D:\Unix-Tmp")))
(setq auto-save-file-name-transforms
`((".*" ,"D:\Unix-Tmp" t)))
\U
引入了unicode转义...并且必须跟随十六进制数字。
你实际上想要的是一个字面反斜杠字符,所以你需要逃避它;即
(setq backup-directory-alist
`((".*" . ,"D:\\Unix-Tmp")))
(setq auto-save-file-name-transforms
`((".*" ,"D:\\Unix-Tmp" t)))
参考:http://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Char-Syntax.html#Basic-Char-Syntax
<强>更新强>
但是,这似乎会导致另一个问题。一个更好的解决方案是做@Stefan建议的。使用&#34; /&#34;而不是&#34; \&#34;作为路径名分隔符。 ( 甚至可以在Windows上工作......)
答案 1 :(得分:1)
始终在Emacs中使用转发斜杠而不是向后斜杠作为文件名。 Windows通常更喜欢反斜杠,但除少数例外情况外,Windows实际上也接受正斜杠。
答案 2 :(得分:0)
错误是由D:\ Unix-Tmp引起的,\ U引入了unicode转义,如Stephen所说。
但是当我改为:
(setq backup-directory-alist
`((".*" . ,"D:\\Unix-Tmp")))
(setq auto-save-file-name-transforms
`((".*" ,"D:\\Unix-Tmp" t)))
它将引发另一个:
正在加载d:/git_root_tfs/WorkStation/Unix-Home/.recentf ...完成清洁 upf list ... done(0已删除)有关GNU Emacs的信息 和GNU系统,类型C-h C-a。 make-auto-save-file-name:无效 使用`\&#39;在替换文本
最后我将路径更改为D:\ Tmp-Unix,它可以正常工作。
(setq backup-directory-alist
`((".*" . ,"D:\Tmp-Unix")))
(setq auto-save-file-name-transforms
`((".*" ,"D:\Tmp-Unix" t)))
总计.eamcs.el
;;Open all fine in one running instance
;;Ref:http://www.johndcook.com/blog/2010/07/28/miscellaneous-emacs-adventures/
;;(server-start)
;;TEST
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
`(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
`(custom-enabled-themes (quote (wheatgrass))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;Set auto save backup location, failed with following warning
(setq backup-directory-alist
`((".*" . ,"D:\Tmp-Unix")))
(setq auto-save-file-name-transforms
`((".*" ,"D:\Tmp-Unix" t)))
(require 'recentf)
(recentf-mode 1)
(setq inhibit-startup-screen t)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;;Aspell install failed
;;(setq-default ispell-program-name "C:/bin/Aspell/bin/aspell.exe")
;;(setq text-mode-hook '(lambda() (flyspell-mode t) ))
答案 3 :(得分:0)
Windows中的Emacs将正斜杠(/)视为反斜杠(\)。指定任何类型的路径时,应始终使用正斜杠。 Emacs将正确解释它们。这允许您将转义序列使用控制到预期效果的时间。
C:/Users/username/AppData/Roaming/.emacs
是Emacs中完全有效的路径/文件名。