如何配置 Emacs 将完成的任务存档到存档文件?
How to configure Emacs to archive Done tasks to archive file?
我将所有任务保存在 todo.org
文件中。任务完成后,我想 select 并将其存档到单独的 archive.org
文件中。当然,我想在我的配置文件中设置它,而不是 per-file header。
我试过这个:
(setq org-archive-location (concat org-directory "~/Dropbox/logs/archive.org::"))
似乎 有效;我看到一条消息,表明任务已存档到我选择的路径。但是——当我打开 archive.org
时,那里什么也没有。曾经。然后,每当我关闭并重新打开 Emacs 时,我都会看到错误消息 Symbol's value as variable is void: org-directory
.
所以:如何正确配置 Emacs 以将我选择的任务归档到正确的位置? 还是 Org 模式的新手,请见谅。
编辑:使用 Emacs 25.3.2 和 Org 9.1.7。
只要O.P。还表达了(在原始问题下方的评论中)自动保存目标存档缓冲区的愿望,这个答案也解决了这个问题:
(require 'org)
(setq org-archive-location "~/Dropbox/logs/archive.org::")
(defun org-archive-save-buffer ()
(let ((afile (org-extract-archive-file (org-get-local-archive-location))))
(if (file-exists-p afile)
(let ((buffer (find-file-noselect afile)))
(if (y-or-n-p (format "Save (%s)" buffer))
(with-current-buffer buffer
(save-buffer))
(message "You expressly chose _not_ to save (%s)" buffer)))
(message "Ooops ... (%s) does not exist." afile))))
(add-hook 'org-archive-hook 'org-archive-save-buffer)
我将所有任务保存在 todo.org
文件中。任务完成后,我想 select 并将其存档到单独的 archive.org
文件中。当然,我想在我的配置文件中设置它,而不是 per-file header。
我试过这个:
(setq org-archive-location (concat org-directory "~/Dropbox/logs/archive.org::"))
似乎 有效;我看到一条消息,表明任务已存档到我选择的路径。但是——当我打开 archive.org
时,那里什么也没有。曾经。然后,每当我关闭并重新打开 Emacs 时,我都会看到错误消息 Symbol's value as variable is void: org-directory
.
所以:如何正确配置 Emacs 以将我选择的任务归档到正确的位置? 还是 Org 模式的新手,请见谅。
编辑:使用 Emacs 25.3.2 和 Org 9.1.7。
只要O.P。还表达了(在原始问题下方的评论中)自动保存目标存档缓冲区的愿望,这个答案也解决了这个问题:
(require 'org)
(setq org-archive-location "~/Dropbox/logs/archive.org::")
(defun org-archive-save-buffer ()
(let ((afile (org-extract-archive-file (org-get-local-archive-location))))
(if (file-exists-p afile)
(let ((buffer (find-file-noselect afile)))
(if (y-or-n-p (format "Save (%s)" buffer))
(with-current-buffer buffer
(save-buffer))
(message "You expressly chose _not_ to save (%s)" buffer)))
(message "Ooops ... (%s) does not exist." afile))))
(add-hook 'org-archive-hook 'org-archive-save-buffer)