代码之家  ›  专栏  ›  技术社区  ›  James

如何配置Emacs将完成的任务归档到归档文件?

  •  1
  • James  · 技术社区  · 7 年前

    我把所有的任务都放在一个 todo.org 文件。任务完成后,我想选择并将其归档到一个单独的 archive.org 文件。当然,我想在我的配置文件中设置它,而不是作为每个文件头。

    (setq org-archive-location (concat org-directory "~/Dropbox/logs/archive.org::"))
    

    哪个 似乎 存档.org ,什么都没有。永远不会。然后,每当我关闭并重新打开Emacs时,都会看到错误消息 Symbol's value as variable is void: org-directory .

    如何正确配置Emacs以将我选择的任务归档到正确的位置? 还是组织模式的新手,所以发发发慈悲吧。

    1 回复  |  直到 7 年前
        1
  •  2
  •   lawlist    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)