>From 37cfa6214f0875ed7ddceae27948394cf78d18d6 Mon Sep 17 00:00:00 2001 From: Toby S. Cubitt Date: Sun, 29 Jan 2012 16:52:08 +0100 Subject: [PATCH] Capture: Allow more control over inserted whitespace in capture templates * lisp/org-capture.el (org-capture-place-entry): Place captured entry immediately after last subheading of target, instead of just before next heading at same level as target. * lisp/org-capture.el (org-capture-templates): Document new capture template properties. * lisp/org-capture.el (org-capture-place-entry, org-capture-empty-lines-before): Make new :empty-lines-before property override :empty-lines when inserting empty lines before captured captured entry. * lisp/org-capture.el (org-capture-finalize, org-capture-empty-lines-after): Make new :empty-lines-after property override :empty-lines when inserting empty lines after captured captured entry. --- lisp/org-capture.el | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 01ec85d..d79c5a4 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -183,6 +183,14 @@ properties are: before and after the new item. Default 0, only common other value is 1. + :empty-lines-before Set this to the number of lines the should be inserted + before the new item. Overrides :empty-lines for the + number lines inserted before. + + :empty-lines-after Set this to the number of lines the should be inserted + after the new item. Overrides :empty-lines for the + number of lines inserted after. + :clock-in Start the clock in this item. :clock-keep Keep the clock running when filing the captured entry. @@ -574,7 +582,8 @@ captured item after finalizing." (goto-char end) (or (bolp) (newline)) (org-capture-empty-lines-after - (or (org-capture-get :empty-lines 'local) 0)))) + (or (org-capture-get :empty-lines-after 'local) + (org-capture-get :empty-lines 'local) 0)))) ;; Postprocessing: Update Statistics cookies, do the sorting (when (eq major-mode 'org-mode) (save-excursion @@ -890,7 +899,7 @@ it. When it is a variable, retrieve the value. Return whatever we get." (progn (outline-next-heading) (or (bolp) (insert "\n"))) - (org-end-of-subtree t t) + (org-end-of-subtree t nil) (or (bolp) (insert "\n"))))) (org-capture-empty-lines-before) (setq beg (point)) @@ -1125,7 +1134,8 @@ Of course, if exact position has been required, just put it there." (defun org-capture-empty-lines-before (&optional n) "Arrange for the correct number of empty lines before the insertion point. Point will be after the empty lines, so insertion can directly be done." - (setq n (or n (org-capture-get :empty-lines) 0)) + (setq n (or n (org-capture-get :empty-lines-before) + (org-capture-get :empty-lines) 0)) (let ((pos (point))) (org-back-over-empty-lines) (delete-region (point) pos) @@ -1134,7 +1144,8 @@ Point will be after the empty lines, so insertion can directly be done." (defun org-capture-empty-lines-after (&optional n) "Arrange for the correct number of empty lines after the inserted string. Point will remain at the first line after the inserted text." - (setq n (or n (org-capture-get :empty-lines) 0)) + (setq n (or n (org-capture-get :empty-lines-after) + (org-capture-get :empty-lines) 0)) (org-back-over-empty-lines) (while (looking-at "[ \t]*\n") (replace-match "")) (let ((pos (point))) -- 1.7.3.4