summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-05-23 18:10:06 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-05-23 18:10:06 +0200
commitd6f096546e795430844098af85c3ed703b1597e2 (patch)
tree80c2c51f45047fe75ca2fa8ec8199993e7666e26
parent7f0391cfe0e6a9f82b222aeb2898849d5154c52f (diff)
downloadorg-mode-d6f096546e795430844098af85c3ed703b1597e2.tar.gz
org-capture: Fix number of blank lines with :unnarrowed option
* lisp/org-capture.el (org-capture-finalize): Remove blank lines number fix, which only applies to narrowed capture buffers. (org-capture-insert-template-here): (org-capture-place-plain-text): (org-capture-place-item): (org-capture-place-entry): Do not hard-code number of blank lines after entry. Reported-by: Igor Perepelytsya <igorquail@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/113093> Reported-by: Jay Dresser <jay@jaydresser.us> <http://permalink.gmane.org/gmane.emacs.orgmode/113449>
-rw-r--r--lisp/org-capture.el31
-rw-r--r--testing/lisp/test-org-capture.el2
2 files changed, 13 insertions, 20 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 551ff28..755bf73 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -723,16 +723,6 @@ captured item after finalizing."
(kill-region m1 m2))
(setq abort-note 'dirty)))
- ;; Make sure that the empty lines after are correct
- (when (and (> (point-max) end) ; indeed, the buffer was still narrowed
- (member (org-capture-get :type 'local)
- '(entry item checkitem plain)))
- (save-excursion
- (goto-char end)
- (or (bolp) (newline))
- (org-capture-empty-lines-after
- (or (org-capture-get :empty-lines-after 'local)
- (org-capture-get :empty-lines 'local) 0))))
;; Postprocessing: Update Statistics cookies, do the sorting
(when (derived-mode-p 'org-mode)
(save-excursion
@@ -1101,7 +1091,7 @@ may have been stored before."
(setq beg (point))
(org-capture-verify-tree txt)
(org-paste-subtree level txt 'for-yank)
- (org-capture-empty-lines-after 1)
+ (org-capture-empty-lines-after)
(org-capture-position-for-last-stored beg)
(outline-next-heading)
(setq end (point))
@@ -1161,7 +1151,7 @@ may have been stored before."
"\n"))
;; Insert item.
(insert txt)
- (org-capture-empty-lines-after 1)
+ (org-capture-empty-lines-after)
(org-capture-position-for-last-stored beg)
(forward-char 1)
(setq end (point))
@@ -1282,7 +1272,7 @@ Of course, if exact position has been required, just put it there."
(org-capture-empty-lines-before)
(setq beg (point))
(insert txt)
- (org-capture-empty-lines-after 1)
+ (org-capture-empty-lines-after)
(org-capture-position-for-last-stored beg)
(setq end (point))
(org-capture-mark-kill-region beg (1- end))
@@ -1366,7 +1356,7 @@ Point will remain at the first line after the inserted text."
(let* ((template (org-capture-get :template))
(type (org-capture-get :type))
beg end pp)
- (or (bolp) (newline))
+ (unless (bolp) (insert "\n"))
(setq beg (point))
(cond
((and (eq type 'entry) (derived-mode-p 'org-mode))
@@ -1388,13 +1378,16 @@ Point will remain at the first line after the inserted text."
(org-capture-empty-lines-after)
(goto-char beg)
(org-list-repair)
- (org-end-of-item)
- (setq end (point)))
- (t (insert template)))
+ (org-end-of-item))
+ (t
+ (insert template)
+ (org-capture-empty-lines-after)
+ (skip-chars-forward " \t\n")
+ (unless (eobp) (beginning-of-line))))
(setq end (point))
(goto-char beg)
- (if (re-search-forward "%\\?" end t)
- (replace-match ""))))
+ (when (re-search-forward "%\\?" end t)
+ (replace-match ""))))
(defun org-capture-set-plist (entry)
"Initialize the property list from the template definition."
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index c630142..7b022b1 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -1,6 +1,6 @@
;;; test-org-capture.el --- Tests for org-capture.el -*- lexical-binding: t; -*-
-;; Copyright (C) 2015 Nicolas Goaziou
+;; Copyright (C) 2015, 2017 Nicolas Goaziou
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>