From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id gDgSEoyHS18oQgAA0tVLHw (envelope-from ) for ; Sun, 30 Aug 2020 11:03:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QMnjDYyHS19QXAAA1q6Kng (envelope-from ) for ; Sun, 30 Aug 2020 11:03:40 +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 C9B10940602 for ; Sun, 30 Aug 2020 11:03:39 +0000 (UTC) Received: from localhost ([::1]:59194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCL7Y-0002y7-Su for larch@yhetil.org; Sun, 30 Aug 2020 07:03:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCL75-0002xx-F4 for emacs-orgmode@gnu.org; Sun, 30 Aug 2020 07:03:07 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:26151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCL72-0002a6-W0 for emacs-orgmode@gnu.org; Sun, 30 Aug 2020 07:03:07 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id EED60240004; Sun, 30 Aug 2020 11:03:00 +0000 (UTC) From: Nicolas Goaziou To: Ihor Radchenko Subject: Re: [feature request] A new cookie type [!] showing the last note taken References: <87zh6eymxs.fsf@localhost> <87h7skldpt.fsf@nicolasgoaziou.fr> <875z90xvqk.fsf@localhost> Mail-Followup-To: Ihor Radchenko , emacs-orgmode@gnu.org Date: Sun, 30 Aug 2020 13:03:00 +0200 In-Reply-To: <875z90xvqk.fsf@localhost> (Ihor Radchenko's message of "Sun, 30 Aug 2020 18:40:19 +0800") Message-ID: <871rjo8kgr.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.193; envelope-from=mail@nicolasgoaziou.fr; helo=relay1-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/30 07:03:01 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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-Spam-Score: 0.49 X-TUID: BkpPf3+bXSW6 Ihor Radchenko writes: > I was mainly referring to org-add-note. The last note taken with > org-add-note can be found quite reliably. > > I am using the following code saving the last note into :SUMMARY: > property upon exiting the note buffer. Though it may be an overkill, not > sure how easy would it be to parse the note syntax for notes created by > org-add-note. You cannot reliably. > (defvar yant/last-note-taken "" > "Text of the last note taken.") > > (define-advice org-store-log-note (:before (&rest args) yant/org-store-last-note) > "Store the last saved note into `yant/last-note-taken'." > (let ((txt (buffer-string))) > (while (string-match "\\`# .*\n[ \t\n]*" txt) > (setq txt (replace-match "" t t txt))) > (when (string-match "\\s-+\\'" txt) > (setq txt (replace-match " " t t txt))) > (when (string-match "\n" txt) > (setq txt (replace-match " " t t txt))) > (if (not (seq-empty-p txt)) > (setq yant/last-note-taken txt)))) > > (define-advice org-store-log-note (:after (&rest args) yant/org-save-last-note-into-summary-prop) > "Save the last saved note into SUMMARY property." > (when (and (not org-note-abort) (not (seq-empty-p yant/last-note-taken))) > (if (eq major-mode 'org-agenda-mode) > (org-with-point-at-org-buffer > (org-set-property "SUMMARY" (or yant/last-note-taken ""))) > (org-set-property "SUMMARY" (or yant/last-note-taken ""))) > (setq yant/last-note-taken nil))) This implementation is only tangentially related to a "last note". You want to introduce some syntax to display the value a given property, here SUMMARY. But `org-add-note' is not the only way to add a note. Again, on a given document, you can only guess what is the "last note". This is not reliable enough to extend the syntax. Regards,