summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-10-26 06:34:16 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-10-26 06:34:16 +0200
commit2a58795e1958210b96e9adee52b9dd68f7d1f50e (patch)
tree22bba4a4d29a96bd8e9b3d481605e4e667748e8c
parent6d44fef50a396617b6d1c86fc64451def31f4739 (diff)
downloadorg-mode-2a58795e1958210b96e9adee52b9dd68f7d1f50e.tar.gz
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: > > <beginning of file> > > * TODO Captured task > > <original first line of file here> > .... > > 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.
-rw-r--r--lisp/org-capture.el4
1 files changed, 2 insertions, 2 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 7915f7f..ef58252 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