【发布时间】:2014-10-25 10:18:33
【问题描述】:
我的 emacs 版本:GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9) of 2014-05-21 on buildvm-07.phx2.fedoraproject.org
我希望 Emacs 的标题显示当前文件的绝对路径。我写了以下内容(来自互联网):
;;;Emacs title bar to reflect file name
(defun frame-title-string ()
"Return the file name of current buffer, using ~ if under home directory"
(let
((fname (or
(buffer-file-name (current-buffer))
(buffer-name))))
;;let body
(when (string-match (getenv "HOME") fname)
(setq fname (replace-match "~" t t fname)) )
fname))
;;; Title = 'system-name File: foo.bar'
(setq frame-title-format '("" system-name " File: "(:eval (frame-title-string))))
在重装FC20+Emacs之前,以上内容可以正常使用。现在除了我手动打开 .emacs 和 eval frame-title-format 之外它不起作用,我不知道为什么我必须手动评估它?
【问题讨论】:
-
如果代码在您手动评估时有效,则问题很可能出在其他地方。启动 Emacs 时是否出现错误?您的 init 文件中是否有其他代码可能导致这种情况?找到问题的一个好方法是将您的 init 文件减少到最低限度。如果可行,则将其延长直到问题再次出现,这样您就可以缩小问题的范围。
-
启动 Emacs 时没有任何错误。为了排除其他代码的影响,我的.emacs现在只有上面的代码,但我得到了相同的结果。
-
你确定初始化文件被读取了吗? (您可以将
(message "I'm here")添加到其中,然后检查*Messages*缓冲区。此外,系统上可能安装了一个系统初始化文件,它会覆盖您的设置? -
是的,我在 (setq frame-title-format ...) 之后添加了 (message "come here here"),它出现在
*Messages*中。现在我想在 .emacs 中强制 eval (setq frame-title-format ...),我该怎么办?谢谢 -
我还没有找到为什么它不起作用,但是这个answer 起作用了!
标签: emacs centos elisp fedora redhat