From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EH5XOORrH2H2PgEAgWs5BA (envelope-from ) for ; Fri, 20 Aug 2021 10:46:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 0Kv6M+RrH2H6ZQAAbx9fmQ (envelope-from ) for ; Fri, 20 Aug 2021 08:46:28 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 232A191A8 for ; Fri, 20 Aug 2021 10:46:28 +0200 (CEST) Received: from localhost ([::1]:45884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mH0AU-0002fo-R6 for larch@yhetil.org; Fri, 20 Aug 2021 04:46:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mH09g-0002fe-Ja for emacs-orgmode@gnu.org; Fri, 20 Aug 2021 04:45:36 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:44700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mH09f-0000Bf-3P for emacs-orgmode@gnu.org; Fri, 20 Aug 2021 04:45:36 -0400 Received: by mail-wr1-x430.google.com with SMTP id x12so13022203wrr.11 for ; Fri, 20 Aug 2021 01:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=KKk3nTPQRGSxXRDk88rv9qv3OgKnsGL9ojjN6P8qPFs=; b=D5y9qdK9GYBiDjpOBzBOm+HFvQqA3hJQqpBDWl6YxEGeFOaXozzatGq0Z4UJJS62Rz h9Chsv2hI7tQOhkomO/iGsHXh1umyz6LydUrqc0msBzCT/Ob9rjbEXPaqNExI5WvrEBh NBa8j76AIJ331DhZSzVLlHXq4McpghLtyf+UtdKig5ngfNvGSmhY26uvW/iK3hJEYWQ/ GXmLGJFP0q+xIoUeWULy1HtgmzcWHEoh1U1rmfwJrD8YzKbFIouM4xjjRAqEf7K2PYrs eVhcM2aUhuL3ZVHYK5qoUSol9sPhxZBSLLrc9+H6K10orQAaVBDyYHuc5aXE+paD1oVd phmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=KKk3nTPQRGSxXRDk88rv9qv3OgKnsGL9ojjN6P8qPFs=; b=Tf1gDMCxifRK8tO7TVXRwWnj/oyTGVQsMfNPFQYG3LEEOhbr8qxJVi3lVGmTWZ+MrN +aiX2JZhgEdfuusnesnlHhfG/BQjxSioRz3KsmJSU1e8CPZlNTQnns9TQGCkn4lgoT3J Jvg7MuF9lnevIbk4uN45TSCWylVVhySv7ILmfXhFZ1OuI6crqYL5HVJVrxd4v0aCazzf lpsfyYRsucNSemD7Mru3g8MF73Vw+eee+cAdQ0yAcKfZHJfWACa2LEibr7wEmi9MHxAp CmcbyWyfHXk0qX9GvrwsApR50ejur1a2JBHaBy1XTAXXFrKz+w5RkgI/L6CGT+z2locd J0VA== X-Gm-Message-State: AOAM532PWwAAmEXAmKBJVxMXhEdZE+mjmrcdBuVfZCb1IQloYmlXPHKX 3bojkDcJTzC2mAtKpNTIIw/+t/XkydQ= X-Google-Smtp-Source: ABdhPJydDWgQzD9CO5Qdtw6R1MsU6kmHGl+lHcs2mvOLs2kBjrnnwmVqzta/wzJg+iwK2ceaddFSlw== X-Received: by 2002:a5d:6a0c:: with SMTP id m12mr8858962wru.168.1629449133099; Fri, 20 Aug 2021 01:45:33 -0700 (PDT) Received: from localhost (131-199-28-81.ftth.cust.kwaoo.net. [81.28.199.131]) by smtp.gmail.com with ESMTPSA id b10sm6457532wrn.9.2021.08.20.01.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 01:45:32 -0700 (PDT) From: Samuel Loury To: numbchild@gmail.com, Org Mode Subject: Re: [QUESTION] Add advice on command org-add-note not working In-Reply-To: References: Date: Fri, 20 Aug 2021 10:45:27 +0200 Message-ID: <87wnogbj2w.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=konubinix@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1629449188; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=KKk3nTPQRGSxXRDk88rv9qv3OgKnsGL9ojjN6P8qPFs=; b=dN7ryJ4ZMztYQtrBWf4R0s8vtJyGmzNb9E6cKaU1XbIPMeS2larfM3hn54ymHtYn1jOx/8 yiVgJB/9ufppeNoiuZOSpnZEOCnRkvGOGP+1yczWf05G0c6yoWIt14+iifRRuS/s2JI/e6 5xPapkgI7px7otZhJWgnD4E3sLje3ywCXPilfyLcIWH2Csa0DYice35/mEpgU76cU2ocnT a0YPcranN56W8J5zFX8GCh3CUcVJSsBYXGQI/dzw6A5fHqZhcyMcn17Jfu9UlOC8Y5yoiZ KlrBvmoJwqGi1BdpZanAKoPJXjT5JNHXli4rQbKnyiYZrmODXBr0zKqArhrx2g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1629449188; a=rsa-sha256; cv=none; b=uqgWWIRNDvpvBEw9PbWEY9sEZH4JQJ1AIHOmMZ8+MeNs3x1aDYZSESHmeg3d2DP20kQtdh KC6sA+Ngo4TzkDaT3W7R/eUa4dmLRvue8KP/jlWoct8Ajf/hp2NCFjqZc+LwTXoXzezdxp kQ8J0VGuYCZiohy7lXYurSBcAIntTyQIuYVsnfWj/5f1Zmx6Un8WZHO1i3BsqNi6OIM+rq oV83obwRNepn7LOJkzlmrhhhpSl1FMRCtIWkGAuppZjCZFw2r2YGklkXG2B5lm6xPiS3aB 6bNQFhF0LrB0Qz7dzVN4rI7+400TOodBHT2FXkt4THNHDlNnSlXa31rNjatf8g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=D5y9qdK9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.72 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=D5y9qdK9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 232A191A8 X-Spam-Score: -2.72 X-Migadu-Scanner: scn0.migadu.com X-TUID: qEaTcJtbp5Nw --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable "Christopher M. Miles" writes: > <#secure method=3Dpgpmime mode=3Dsign> 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)~, t= hen 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, =2D-=20 Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEWZO+etpl4tkGzlw2ddI87XQ5EGoFAmEfa6cACgkQddI87XQ5 EGptrQf/a4wGEQXNojudh+geVZs/h3p2H+4HIDJYBxw/A8KazCJmNnoXutkL+Ula v2Cddnss4+/Im2KoVjeHTt2lh6lCwwjITstxYS5EP6OXpTsF1fASyUXk2mW1g3Pz 9MnQq6Sv5rxOYFcz12cUOAnau7JNvrPtNaobRj/MzALSHPQc/hBULZgbGhBGBhZ5 NrYQtMhH8s/+C+bUtv6S7pPsODINcTAjXX7P+ynSy7pd0+OHKpOlJn9hFvzIbvB0 7Zu1fLJ+v6xrOxUMYP66qVVPPZEHsuKPgzWGlqy9jl5QqCRzwsTPPbCeTn/n2HCu 6A1Y+LPQsaecpXOHvkAEPadQdKUcnQ== =S04i -----END PGP SIGNATURE----- --=-=-=--