首页 > 解决方案 > 如何在交互式输入标题下捕获注释

问题描述

我正在使用这篇文章中的捕获模板。该脚本让我可以选择我想在哪个标题下提交我的新笔记。我想使用这个脚本,以便我可以在女巫标题下动态选择来提交我的新笔记。

而不是使用entry (file+headline "~/org/gtd.org" "Movies")预定义标题的位置

不幸的是,这个脚本不能正常工作。它不会将其写入正确的标题下,而是使用此结果创建一个新标题

* inbox.org/Movies
*  Watch new james bond movie
<2020-07-12 Sun 17:03:28>

而不是在 inbox.org 文件中创建标题

* Movies
**  Watch new james bond movie
<2020-07-12 Sun 17:03:28>
(setq org-capture-templates  
(append org-capture-templates
     (quote (

                ("t" "add task")
    
("to" "other" 
entry (file+function "~/org/gtd.org" org-ask-location)
    "\n\n** %?\n<%<%Y-%m-%d %a %T>>"
    :empty-lines 1)


               )
        )
     )
)



(defun org-ask-location ()
  (let* ((org-refile-targets '((nil :maxlevel . 9)))
         (hd (condition-case nil
                 (car (org-refile-get-location "Headline" nil t))
               (error (car org-refile-history)))))
    (goto-char (point-min))
    (outline-next-heading)
    (if (re-search-forward
         (format org-complex-heading-regexp-format (regexp-quote hd))
         nil t)
        (goto-char (point-at-bol))
      (goto-char (point-max))
      (or (bolp) (insert "\n\n"))
      (insert "* " hd "\n\n")))
    (end-of-line))

标签: org-modecapture

解决方案


推荐阅读