0

I have a lot of org capture templates defined in my .emacs file.

I'd like to be able to add a "comment" into some of them - how would I do that?

For example when I'm capturing a new GTD Project, I want the capture buffer to start out looking something like this:

;; GTD Project
;; What has to be true for this to be done?
** PROJECT |

And then, when I hit C-c C-c to capture the project, the commented lines (starting with ;;) must NOT be captured.

In case it is relevant, I use doct to make my capture template config easier to read.

1 Answer 1

1

There is no built-in way to do this, though you can certainly add some custom lisp on capture to remove your hint text from what is saved.

Another option might be to use the prompt template element. For example:

(add-to-list
 'org-capture-templates
 '("g" "GTD Project" entry
   (file+headline "" "GTD")
   "* PROJECT %^{What has to be true for this to be done?} "))

If you want to have the comments in-line, here's a start. This defines a custom hook to remove comment lines before finalizing the capture:

(defun my/org-capture-cleanup ()
  (interactive)
  (goto-char 0)
  (flush-lines "^\s+;;"))

(add-hook 'org-capture-prepare-finalize-hook 'my/org-capture-cleanup)

(add-to-list
 'org-capture-templates
 '("g" "GTD Project" entry
   (file+headline "" "Tasks")
   "* PROJECT %?
;; GTD Project
;; What has to be true for this to be done?"))
1
  • Note that I put the comments after the heading because otherwise you don't have a valid entry and Org will raise an error opening the capture template.
    – glucas
    Commented Apr 2, 2022 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.