编辑。在emacs中,我运行了Alt + X eval-buffer命令。我的操作系统是windows。当我重新启动emacs时,它显示以下警告:
警告(初始化):加载时发生错误"…/.emacs.el":
错误:Unicode转义使用非十六进制数字
为确保正常操作,应检查并移除初始化文件错误的原因。启动Emacs'——debug-init'选项查看完整的错误回溯。
. emacs。厄尔是:
;;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
然而,这似乎导致另一个问题。更好的解决办法是按照@Stefan的建议去做。使用"/"而不是""作为路径名分隔符。(它应该在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/工作站/unix主/.recentf……做清洁在最近的名单上…关于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 。
;;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) ))
始终使用正向斜杠而不是反向斜杠作为Emacs中的文件名。Windows通常更喜欢反斜杠,但除了少数例外,Windows实际上也接受正斜杠。
Windows中的Emacs将正斜杠(/)视为反斜杠()。当指定任何类型的路径时,应该始终使用正斜杠。Emacs将正确地解释它们。这允许您控制转义序列的使用次数,以达到预期的效果。
C:/Users/username/AppData/Roaming/.emacs
是Emacs中完全有效的路径/文件名。