From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id IPImA36ZS18TfwAA0tVLHw (envelope-from ) for ; Sun, 30 Aug 2020 12:20:14 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id cPSIOn2ZS1+JawAAB5/wlQ (envelope-from ) for ; Sun, 30 Aug 2020 12:20:13 +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 8458E9402CC for ; Sun, 30 Aug 2020 12:20:12 +0000 (UTC) Received: from localhost ([::1]:45672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCMJd-0005GC-EE for larch@yhetil.org; Sun, 30 Aug 2020 08:20:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCMJ8-0005Fq-9O for emacs-orgmode@gnu.org; Sun, 30 Aug 2020 08:19:38 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40995) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCMJ3-0002V7-J9 for emacs-orgmode@gnu.org; Sun, 30 Aug 2020 08:19:38 -0400 Received: by mail-pf1-x443.google.com with SMTP id t9so3034481pfq.8 for ; Sun, 30 Aug 2020 05:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=2MK+t4UnaNdmZiU3Bo/DI4K5XTRl2vu78W3yzo61FpE=; b=Ho8HjKsb2U5+Dn9mZmIur1Aclw9o5RmlLYSVoa9HOOljgGbbVdzsGVce/d9qkHLBBN wcmJPxAqoSQK9Ln9K4gN/cJd2FWceOYIZjW1tSrhhGC96zufAe42p9KPZpT+FhMGMjjv AqLf4CtwAcsRBXnFWLRfr80E102iilOjYMoY4SBUrJVRtkyapdyjMIlAX5QMQm6oI7a0 yMixZaf288jdyaZb16HHyHSWw2MvCt/d+e9ACb96Ua6oliSgXsA4rtAwjiNlgxXRv7BK mOBCuYvY1XRv85kT3dAJ6/fn2ymH7j3yyA8ZfEnRkxBrYrQoIMp78hRdB/ho7nCgw/Bs ruPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=2MK+t4UnaNdmZiU3Bo/DI4K5XTRl2vu78W3yzo61FpE=; b=iOvc9PXqPP9lDuLIuyoWuLehJXcCwD8hEXnoGh+QMLhLwFgzlo4hRBk/AGwmcjJH03 5613SZEhwp3JNWRZES5vO3XndWGGuhg5IVuYcQnsP6bpaLVIY+jwCNp0lJWC0yUEQyeJ zrABEXcfSwpwIGCUHtPKfHhGhd7OMldkDGRUAr+L7fJgY1iwGEw+2I2q70mMztoCCFQn kDiEGLUfai8AbDN47OABsCv4hSbw/HcW5pSUawUij6Co/7qWkvMxOCV/ZjoXGzxRxtdq 4II8K17UnVjV7+3HT94SdpjyYQNUlvwpIS2xYAIUk+x2Pqkohm2bVsK4C26G544gbjmT x1PA== X-Gm-Message-State: AOAM530JqbiQEHbduCn2ZsImwCQUtHMKdwXmJb249Hu4SMF0iQEG5yi7 ujKfGdjEM8dCh5NqG3Szz0Q= X-Google-Smtp-Source: ABdhPJw3dQdDdtO79zjB2hzsI5+7+ykkpesFU/7wCUY6BXDdgrNJevVpVmcMVK0STn9+QDpei3DUPQ== X-Received: by 2002:a63:ab43:: with SMTP id k3mr5202542pgp.426.1598789972014; Sun, 30 Aug 2020 05:19:32 -0700 (PDT) Received: from localhost ([23.27.206.160]) by smtp.gmail.com with ESMTPSA id g9sm499204pfo.144.2020.08.30.05.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 05:19:31 -0700 (PDT) From: Ihor Radchenko To: Nicolas Goaziou Subject: Re: [feature request] A new cookie type [!] showing the last note taken In-Reply-To: <871rjo8kgr.fsf@nicolasgoaziou.fr> References: <87zh6eymxs.fsf@localhost> <87h7skldpt.fsf@nicolasgoaziou.fr> <875z90xvqk.fsf@localhost> <871rjo8kgr.fsf@nicolasgoaziou.fr> Date: Sun, 30 Aug 2020 20:18:29 +0800 Message-ID: <873644xr6y.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=yantar92@gmail.com; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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: , 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=pass header.d=gmail.com header.s=20161025 header.b=Ho8HjKsb; 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-Spam-Score: 0.29 X-TUID: /c9y9CZ+1YwX > Again, on a given document, you can only guess what is the "last note". > This is not reliable enough to extend the syntax. I feel that my understand of "note" in context of org is different from yours. Is there a formal definition of "note" in org? If no, there is indeed no reliable way to capture "last note". However, we can formalise the "last note taken" to "last note taken using org-add-note". > 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. org-add-note is the only way I am aware about (except plain text, indeed). That's why I wrote the function saving the last note taken using org-add-note into SUMMARY. The property is only used here for convenient retrieval, not because I implied showing a property value. May I know what are the other ways to add note via interactive function in Org? Best, Ihor Nicolas Goaziou writes: > 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,