Reuse date prompts values in a capture templates

I was finally able to send a FR to the mailing list with a link to @akashp fix. @nobiot I will try your last piece of code a bit later today.
Thanks again to everyone.

1 Like

I confirm it works fine for me too.

It also taught me how to place the cursor below the metadata block which I was actually looking for for another function that I am trying to build to reformat existing files.

Since the function does not have the word ‘point’ ‘go’ or ‘move’ in it, my usual way of trying my luck with a consult symbol search did not pay out. So thanks for that too :+1:

2 Likes

@lyndhurst Remove your customisation regarding changing the org-capture function. @nobiot 's solution is better for user customisation. You don’t need to change the big function anymore, since you circumvent the whole point of org-capture not allowing dates to be kept as strings.

Since they did not change the function in so long - probably they won’t change it - they might have some rationale that we are not aware of, I think they intentionally dont let the last %N string capture the date entered - its not a bug its most probably intent.

I agree with @akashp , this big function copied in my config did not feel right.

As I was saying earlier I had simplfied my template example to make my problem clearer. In ‘real life’ I have two log templates one to log punctual events using the LOGSTART property, and another to log what occured during an period of time which adds the LOGEND property to define the time interval.

I had to modify slightly @nobiot function. I am sure it can be improved as I am just starting to understand some basics of elisp logic, and I am repeating code too but this is working nonetheless.

(defun +org-roam-capture-logs-insert-timestamps ()
  "Insert log timestamps in notes first line during capture."

  (when-let ((s (org-entry-get (point) "LOGSTART"))
             (e (org-entry-get (point) "LOGEND")))
    (org-roam-end-of-meta-data t)
    (org-beginning-of-line)
    (insert (concat "\n/Logging from " s " to " e "/\n")))

  (when-let (p (org-entry-get (point) "LOGSTART"))
    (if (not (org-entry-get (point) "LOGEND"))
    (progn (org-roam-end-of-meta-data t)
    (org-beginning-of-line)
    (insert (concat "\n/Logged on " p "/\n"))))))

2 Likes