emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QUESTION] Add advice on command org-add-note not working


From: Samuel Loury
Subject: Re: [QUESTION] Add advice on command org-add-note not working
Date: Fri, 20 Aug 2021 10:45:27 +0200

"Christopher M. Miles" <numbchild@gmail.com> writes:

> <#secure method=pgpmime mode=sign>

Beware this did not actually sign your message.

> I have following advice code:
>
> #+begin_src emacs-lisp
> (defun my/org-add-note--auto-add-tag ()
>   "Auto add tag 'LOG' when add note log."
>   (org-back-to-heading)
>   ;; DEBUG: the following code is not executed.
>   (message "DEBUG")
>   (require 'seq)
>   (org-set-tags (seq-uniq (cons "LOG" (org-get-tags nil t)))))
>
> (advice-add 'org-add-note :after #'my/org-add-note--auto-add-tag)
> #+end_src
>
> With Emacs Edebug, I found it only executed to ~(org-back-to-heading)~, then 
> stopped. The following
> "DEBUG" message is not printed and tag "LOG" is not added.
>
> Does anybody have some clue for this issue?

`org-add-note` only sets up a side buffer to write the content of the
note. The "go back to the heading to actually write the note" is done by
`org-store-log-note`, invoked using C-c C-c on your note.

So it is normal that `org-back-to-heading` fails in the org-note buffer
that indeed does not have a heading.

Hint: press p when in edebug session to find out in which buffer context
the code will apply.

I just tried applying the advice to `org-store-log-note` instead of
`org-add-note` and it worked fine :-).

My best,
-- 
Konubinix
GPG Key    : 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE  5C36 75D2 3CED 7439 106A

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]