Emacs警告加载“... / .emacs.el”时发生错误:
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Emacs警告加载“... / .emacs.el”时发生错误:相关的知识,希望对你有一定的参考价值。
在emacs中编辑.emacs.el时,我运行了Alt + X eval-buffer命令。我的操作系统是Windows。当我重新启动emacs时,它会显示以下警告:
警告(初始化):加载`... /。emacs.el'时发生错误:
错误:用于Unicode转义的非十六进制数字
为确保正常运行,您应该调查并删除初始化文件中的错误原因。使用`--debug-init'选项启动Emacs以查看完整的错误回溯。
.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) ))
我怎么解决它?
问题是这些问题:
(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
UPDATE
但是,这似乎会导致另一个问题。一个更好的解决方案是做@Stefan建议的。使用“/”代替“”作为路径名分隔符。 (它应该在Windows上工作......)
始终在Emacs中使用正斜杠而不是反斜杠作为文件名。 Windows通常更喜欢反斜杠,但除了极少数例外,Windows实际上也接受正斜杠。
错误是由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 ... done清理recentf list ... done(0已移除)有关GNU Emacs和GNU系统的信息,请键入C-h C-a。 make-auto-save-file-name:替换文本中使用“”无效
最后我将路径改为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) ))
Windows中的Emacs将正斜杠(/)视为反斜杠()。指定任何类型的路径时,应始终使用正斜杠。 Emacs将正确解释它们。这允许您将转义序列使用控制到预期效果的时间。
C:/Users/username/AppData/Roaming/.emacs
是Emacs中完全有效的路径/文件名。
以上是关于Emacs警告加载“... / .emacs.el”时发生错误:的主要内容,如果未能解决你的问题,请参考以下文章
由于缺少 deps:pkg-info 和破折号,Emacs 软件包安装失败
EmacsMacPort (Emacs.app) 不加载我自己的,MacOS 中的 ~/.emacs