为什么我不能在Emacs 24.1下使用旧的主题样式文件?

5

我可以在23.1、23.4版本下使用我的样式文件,但是在我将Emacs更新到24.1后,我不能再使用旧的样式文件。例如,我的其中一个样式文件是color-theme-arjen.el。这是链接:

https://github.com/credmp/color-theme-arjen/blob/master/color-theme-arjen.el

在我的elisp文件中,我使用以下代码加载颜色主题:
我不知道为什么颜色主题在Emacs 23.1和23.4下工作,但在Emacs 24.1下却无法正常工作。
当Emacs加载文件时,它会给出以下错误:
如果我取消上面的代码的注释并不加载样式文件,则该错误被解除。
有人知道为什么会发生这种情况吗?或者我该如何进行调试?
4个回答

21

是的,我也发现了这个bug。看起来Emacs 24没有 ' plist-to-alist ' 函数。因此你可能需要自己编写它。这是我的版本。 将此函数放入你的dot-emacs文件中,然后就可以了。

(defun plist-to-alist (the-plist)
  (defun get-tuple-from-plist (the-plist)
    (when the-plist
      (cons (car the-plist) (cadr the-plist))))

  (let ((alist '()))
    (while the-plist
      (add-to-list 'alist (get-tuple-from-plist the-plist))
      (setq the-plist (cddr the-plist)))
  alist))

希望能有所帮助 : )


非常感谢!作为一个vim用户,我惊讶地发现在emacs领域需要进行如此多的调整才能使其运行起来。(我的vim已经被大量修改过了,我尝试使用emacs是因为据说它存在更多的调整可能性,并且我懂一点lisp。) - sjas
太棒了,现在我的.emacs文件又可以在emacs 24.3.1上工作了,非常感谢! - Bogatyr

3
24版中对颜色主题进行了大幅更新, 包含了一个颜色主题包(见 M-x customize-themes),老版本主题的损坏是可以预期的。
来自marmalade 的颜色主题包也能正常工作。
您可能需要为color-theme-arjen打开一个错误报告。

0

我不太清楚为什么,但是在MacOS X上安装solarized主题时,在emacs 24.3.1中,我发现如果我把我的init行放在:

(load-file "~/lisp/color-theme/color-theme.el")
(load-file "~/lisp/emacs-colors-solarized/color-theme-solarized.el")
(color-theme-solarized 'dark)

在我关闭滚动条之后:

(if (featurep 'scroll-bar)
    (scroll-bar-mode -1))

它正常工作。反过来,我会得到上面的错误。我不知道为什么color-theme-alist函数受到滚动条缺失的影响(plist-to-alist函数调用似乎只适用于XEmacs)


0

我非常感谢wenjun.yan的帮助,但我希望在定义函数之前先检查它是否存在:

(unless (fboundp 'plist-to-alist) 
(defun plist-to-alist (the-plist)
  (defun get-tuple-from-plist (the-plist)
    (when the-plist
      (cons (car the-plist) (cadr the-plist))))
  (let ((alist '()))
    (while the-plist
      (add-to-list 'alist (get-tuple-from-plist the-plist))
      (setq the-plist (cddr the-plist)))
  alist)))

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接