循环自定义主题w / emacs 24

时间:2014-05-21 20:36:45

标签: emacs

我目前正在为emacs 24使用新的customtheme工具,我希望能够通过按键(例如f12)来循环自定义主题。

下面的代码听起来就像我想要它做的那样,但它使用了颜色主题,我不想这样做。我不熟悉Lisp还没有自己编写或者从旧版本转换为新版本。是否有人可以使用新的内置load-theme命令帮助我将相同的功能添加到emacs 24中?

此外,基于this discussion,我可能需要在每次调用函数时调用disable-theme。

非常感谢任何帮助。

这是使用color-theme

的旧解决方案
(defun my-theme-set-default () ; Set the first row
  (interactive)
  (setq theme-current my-color-themes)
  (funcall (car theme-current)))

(defun my-describe-theme () ; Show the current theme
  (interactive)
  (message "%s" (car theme-current)))

; Set the next theme (fixed by Chris Webber - tanks)
(defun my-theme-cycle ()        
  (interactive)
  (setq theme-current (cdr theme-current))
  (if (null theme-current)
  (setq theme-current my-color-themes))
  (funcall (car theme-current))
  (message "%S" (car theme-current)))

(setq theme-current my-color-themes)
(setq color-theme-is-global nil) ; Initialization
(my-theme-set-default)
(global-set-key [f12] 'my-theme-cycle)

2 个答案:

答案 0 :(得分:3)

FWIW,这里有两个现成的方式(使用冰柱 Do Re Mi )到cycle Emacs custom themes(你是什么人)为Emacs 24调用颜色主题,但它们是自定义主题,而不是颜色主题)。同一页面解释了颜色主题和自定义主题之间的差异。

答案 1 :(得分:1)

这里有一些类似于JakubHozak代码的代码,但切换速度不如颜色主题快。我完全不明白为什么,但它似乎是由自定义主题和颜色主题之间的差异引起的。虽然如果你将自行车限制在emacs附带的主题上,它似乎更可忍受。

(setq my-themes (list 'tango 'solarized-dark 'solarized-light 'alect-dark)) ;;the themes I cycle among
(setq curr-theme my-themes)

(defun my-theme-cycle ()
    (interactive)
    (disable-theme (car curr-theme)) ;;Nee flickeringded to stop even worse
    (setq curr-theme (cdr curr-theme))
    (if (null curr-theme) (setq curr-theme my-themes))
    (load-theme (car curr-theme) t)
    (message "%s" (car curr-theme))
)

(global-set-key [f12] 'my-theme-cycle)
(setq curr-theme my-themes)
(load-theme (car curr-theme) t) 
相关问题