So far I have written this code...

(defun org-capture-expand-headline (headline)
  "Expand functions, symbols and strings for HEADLINE.


When HEADLINE is a function, call it.  When it is a form, evaluate


it.  When it is a variable, return its value.  When it is a string,


treat it as a headline title. When it is `t', select existing headline


title or enter a new one.  In any other case, raise an error."
  (let* ((headlines (org-map-entries (lambda ()
                                       (org-element-property :title
(org-element-at-point)))))
         (final-headline (cond ((stringp headline) headline)
                               ((functionp headline) (funcall headline
headlines))
                               ((eq headline t) (completing-read "Enter
headline: " headlines  nil 'confirm))
                               ((and (symbolp headline) (boundp headline))
(symbol-value headline))
                               (t nil))))
    (or (org-string-nw-p final-headline)
(error "Invalid headline: %S" headline))))

and I updated `org-capture-set-target-location' to use that function when
handling with target `file+headline'

What I am concerned about is the amount of tests I might have to write or
update for `org-capture'.

testing/lisp/test-org-capture.el


125:          `(("t" "Todo" entry (file+headline ,file "A") "** H1 %?"))))


144:             `(("t" "Todo" entry (file+headline ,file2 "A")


175:          `(("t" "Todo" entry (file+headline ,file "A") "** H1 %?"))))


221:          `(("t" "Todo" entry (file+headline ,file "A") "** H1 %?"))))


233:          `(("t" "Test" entry (file+headline ,file "A") "** H\nFoo"


243:         `(("t" "Test" entry (file+headline ,file "A") "** "


279:          `(("t" "Item" item (file+headline ,file "A") "- X"))))


312:          `(("t" "Item" item (file+headline ,file "A") "- X"))))


323:          `(("t" "Item" item (file+headline ,file "A") "- X"


337:          `(("t" "Item" item (file+headline ,file "A") "- X"


358:          `(("t" "Item" item (file+headline ,file "A") "- X"


371:          `(("t" "Item" item (file+headline ,file "A") "- X"))))


538:                `(("t" "Table" table-line (file+headline ,file "Inbox")


552:                `(("t" "Table" table-line (file+headline ,file "Inbox")


723:                `(("t" "Text" plain (file+headline ,file "A") "Foo"


733:                `(("t" "Text" plain (file+headline ,file "A") "Foo"

How do you think it should be tested if the headline can be 4 different
types?

Apology in advance if the formatting is off.

Reply via email to