From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: org-capture does not fully clean up after C-c C-k Date: Tue, 12 Jul 2011 01:00:01 +0200 Message-ID: <87hb6sh18u.fsf@gnu.org> References: <28021D5A-92CD-4732-8462-8AD1EBA7262D@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgPS8-0003Pn-DY for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 18:59:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QgPS4-0002eH-Ih for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 18:59:47 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:62685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgPS4-0002e1-2L for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 18:59:44 -0400 Received: by fxd18 with SMTP id 18so749488fxd.39 for ; Mon, 11 Jul 2011 15:59:39 -0700 (PDT) In-Reply-To: (Leo's message of "Mon, 11 Jul 2011 17:45:04 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Leo Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Leo, Leo writes: > On 2011-06-16 15:51 +0800, Carsten Dominik wrote: >> Hi Leo, >> >> I am unable to reproduce this. I do get an empty line the first time, >> but when the empty line is already there, then there is no problem. >> >> Do you find the insertion of this one empty line a problem? >> >> - Carsten > > Sorry for the long delay. I can reproduce this in Emacs -q with > > (setq org-blank-before-new-entry '((heading))) Please let me know if the attached patch fixes this issue. Thanks, --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-capture.el-Fix-bug-about-insert-blank-line-when-.patch >From 38334f29f4c949cad76c199433f60250a824878d Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 12 Jul 2011 00:57:57 +0200 Subject: [PATCH] org-capture.el: Fix bug about insert blank line when aborting. * org-capture.el (org-capture-finalize): bugfix about inserted blank line when killing the capture buffer and `org-blank-before-new-entry' tells to not insert anything before a heading. Thanks to Leo for reporting this. --- lisp/org-capture.el | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index d547f3d..dd74ecc 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -551,6 +551,9 @@ captured item after finalizing." (m2 (org-capture-get :end-marker 'local))) (if (and m1 m2 (= m1 beg) (= m2 end)) (progn + (setq m2 (if (cdr (assoc 'heading org-blank-before-new-entry)) + m2 (1+ m2)) + m2 (if (< (point-max) m2) (point-max) m2)) (setq abort-note 'clean) (kill-region m1 m2)) (setq abort-note 'dirty))) @@ -576,16 +579,14 @@ captured item after finalizing." (org-at-table-p)) (if (org-table-get-stored-formulas) (org-table-recalculate 'all) ;; FIXME: Should we iterate??? - (org-table-align))) - ) + (org-table-align)))) ;; Store this place as the last one where we stored something ;; Do the marking in the base buffer, so that it makes sense after ;; the indirect buffer has been killed. (org-capture-bookmark-last-stored-position) ;; Run the hook - (run-hooks 'org-capture-before-finalize-hook) - ) + (run-hooks 'org-capture-before-finalize-hook)) ;; Kill the indirect buffer (save-buffer) @@ -665,7 +666,8 @@ already gone. Any prefix argument will be passed to the refile command." (interactive) ;; FIXME: This does not do the right thing, we need to remove the new stuff ;; By hand it is easy: undo, then kill the buffer - (let ((org-note-abort t) (org-capture-before-finalize-hook nil)) + (let ((org-note-abort t) + (org-capture-before-finalize-hook nil)) (org-capture-finalize))) (defun org-capture-goto-last-stored () -- 1.7.5.2 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--