emacs中的org-timer模块加载错误

Tal*_*Kit 7 emacs elisp org-mode

我想在org-mode中使用pomodoro技术,如 http://orgmode.org/worg/org-gtd-etc.html中所述.

我在.emacs文件中添加了以下行

(add-to-list 'org-modules 'org-timer)

(setq org-timer-default-timer 25)

(add-hook 'org-clock-in-hook '(lambda () 
     (if (not org-timer-current-timer) 
      (org-timer-set-timer '(16))))) 
Run Code Online (Sandbox Code Playgroud)

启动emacs时,警告缓冲区中会显示以下警告.

Symbol's value as variable is void: org-modules
Run Code Online (Sandbox Code Playgroud)

我正在使用org-mode版本 - 7.7.291.g37db,它是从git://orgmode.org/org-mode.git克隆的

如何摆脱错误.

Gil*_*il' 9

org-modules定义于org.el.如果要向列表中添加元素,则需要等到定义变量(使用默认列表).一种方法是延迟添加,直到org.el加载后:

(defun my-after-load-org ()
  (add-to-list 'org-modules 'org-timer))
(eval-after-load "org" '(my-after-load-org))
Run Code Online (Sandbox Code Playgroud)

请注意,add-hook可以处理尚未定义的变量,但add-to-list不能.您可以编写(setq org-modules '(org-timer)),但这会覆盖默认模块列表而不是添加到它.