From 2a58795e1958210b96e9adee52b9dd68f7d1f50e Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 26 Oct 2010 06:34:16 +0200 Subject: [PATCH] Fix empty line bug in capture * lisp/org-capture.el (org-capture-empty-lines-before): (org-capture-empty-lines-after): Make sure the n=0 does not insert any newlines. Marcel van der Boom writes: > I'm in the process of migrating from org-remember to org-capture. > Pretty easy going so far, but it seems org-capture adds newlines, which > I think it should not do. > > My (test) capture-template is: > > (("t" "Todo" entry > (file "~/.outlet/GTD.org") > "* TODO %?" :prepend t :empty-lines 0) > > with the intention of inserting the captured task on the > first line of the file ~/.outlet/GTD.org. What happens when I capture > an task is this: > > > > * TODO Captured task > > > .... > > Both before and after the task is a newline. Also, when capturing and > cancelling the capture with C-c C-k the newlines remain whereas the > task is removed. --- lisp/org-capture.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 7915f7f0c..ef5825295 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -948,7 +948,7 @@ Point will be after the empty lines, so insertion can directly be done." (let ((pos (point))) (org-back-over-empty-lines) (delete-region (point) pos) - (newline n))) + (if (> n 0) (newline n)))) (defun org-capture-empty-lines-after (&optional n) "Arrange for the correct number of empty lines after the inserted string. @@ -957,7 +957,7 @@ Point will remain at the first line after the inserted text." (org-back-over-empty-lines) (while (looking-at "[ \t]*\n") (replace-match "")) (let ((pos (point))) - (newline n) + (if (> n 0) (newline n)) (goto-char pos))) (defvar org-clock-marker) ; Defined in org.el