From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH 5/9] Fix note insertion in entries with drawers. Date: Thu, 16 Oct 2008 06:50:12 +0200 Message-ID: References: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> <20080920210906.19759.21084.stgit@nyarlathotep.internal.mohorovi.cc> Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KqKoZ-0004gl-Nq for emacs-orgmode@gnu.org; Thu, 16 Oct 2008 00:50:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KqKoY-0004gM-RY for emacs-orgmode@gnu.org; Thu, 16 Oct 2008 00:50:23 -0400 Received: from [199.232.76.173] (port=53836 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KqKoY-0004gG-Ls for emacs-orgmode@gnu.org; Thu, 16 Oct 2008 00:50:22 -0400 Received: from ey-out-1920.google.com ([74.125.78.149]:46184) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KqKoX-0005wQ-8s for emacs-orgmode@gnu.org; Thu, 16 Oct 2008 00:50:21 -0400 Received: by ey-out-1920.google.com with SMTP id 4so1166063eyg.24 for ; Wed, 15 Oct 2008 21:50:16 -0700 (PDT) In-Reply-To: <20080920210906.19759.21084.stgit@nyarlathotep.internal.mohorovi.cc> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: James TD Smith Cc: emacs-orgmode@gnu.org Hi JD, I have now made this change configurable, please configure the new option `org-log-state-notes-insert-after-drawers' if you want your notes after the drawers. Default is the old behavior to insert before the drawers (I got some requests for this). - Carsten On Sep 20, 2008, at 11:09 PM, James TD Smith wrote: > The code to find the insertion point after a heading for notes was > not skipping > over drawers, resulting in notes being added inbetween the > scheduling keywords > and the first drawer. Notes are now inserted after any drawers in an > item. > --- > > lisp/ChangeLog | 2 ++ > lisp/org.el | 41 +++++++++++++++++++++++------------------ > 2 files changed, 25 insertions(+), 18 deletions(-) > > diff --git a/lisp/ChangeLog b/lisp/ChangeLog > index b52700d..1753881 100755 > --- a/lisp/ChangeLog > +++ b/lisp/ChangeLog > @@ -3,6 +3,8 @@ > * org.el (org-get-refile-targets): Replace links with their > descriptions > (org-imenu-get-tree): Replace links with their descriptions > + (org-add-log-setup): Skip over drawers (properties, clocks etc) > + when adding notes. > > * org-agenda.el (org-agenda-get-closed): show durations of clocked > items as well as the start and end times. > diff --git a/lisp/org.el b/lisp/org.el > index 99b62d0..10c2cdc 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -9038,7 +9038,7 @@ The auto-repeater uses this.") > "Add a note to the current entry. > This is done in the same way as adding a state change note." > (interactive) > - (org-add-log-setup 'note nil t nil)) > + (org-add-log-setup 'note nil 'findpos nil)) > > (defun org-add-log-setup (&optional purpose state findpos how > &optional extra) > "Set up the post command hook to take a note. > @@ -9047,23 +9047,28 @@ When FINDPOS is non-nil, find the correct > position for the note in > the current entry. If not, assume that it can be inserted at point. > HOW is an indicator what kind of note should be created. > EXTRA is additional text that will be inserted into the notes buffer." > - (save-excursion > - (when findpos > - (org-back-to-heading t) > - (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*" > - "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp > - "[^\r\n]*\\)?")) > - (goto-char (match-end 0)) > - (unless org-log-states-order-reversed > - (and (= (char-after) ?\n) (forward-char 1)) > - (org-skip-over-state-notes) > - (skip-chars-backward " \t\n\r"))) > - (move-marker org-log-note-marker (point)) > - (setq org-log-note-purpose purpose > - org-log-note-state state > - org-log-note-how how > - org-log-note-extra extra) > - (add-hook 'post-command-hook 'org-add-log-note 'append))) > + (save-restriction > + (save-excursion > + (when findpos > + (org-back-to-heading t) > + (org-narrow-to-subtree) > + (while (re-search-forward > + (concat "\\(" org-drawer-regexp "\\|" org-property-end-re "\\)") > + (point-max) t) (forward-line)) > + (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*" > + "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp > + "[^\r\n]*\\)?")) > + (goto-char (match-end 0)) > + (unless org-log-states-order-reversed > + (and (= (char-after) ?\n) (forward-char 1)) > + (org-skip-over-state-notes) > + (skip-chars-backward " \t\n\r"))) > + (move-marker org-log-note-marker (point)) > + (setq org-log-note-purpose purpose > + org-log-note-state state > + org-log-note-how how > + org-log-note-extra extra) > + (add-hook 'post-command-hook 'org-add-log-note 'append)))) > > (defun org-skip-over-state-notes () > "Skip past the list of State notes in an entry." > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode