diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2011-04-07 17:03:26 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2011-04-07 17:03:26 +0200 |
commit | a54afa7e8e4910bbf0e6354852c3644ccc2afdf3 (patch) | |
tree | e62c3c42eb509682e14657451a0069d4d1bf36f2 | |
parent | 4168fccdc7eab648d9c4517afe56765aaa1e9664 (diff) | |
parent | f1ffed8a6caf041b2c9728e5de03f001fdf2ce9e (diff) | |
download | org-mode-a54afa7e8e4910bbf0e6354852c3644ccc2afdf3.tar.gz |
Merge branch 'capture-plain-text-into-nodes'
-rw-r--r-- | lisp/org-capture.el | 24 | ||||
-rw-r--r-- | lisp/org.el | 21 |
2 files changed, 40 insertions, 5 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 2ae8a74..5512178 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1012,13 +1012,27 @@ it. When it is a variable, retrieve the value. Return whatever we get." (org-table-align))) (defun org-capture-place-plain-text () - "Place the template plainly." + "Place the template plainly. +If the target locator points at an Org node, place the template into +the text of the entry, before the first child. If not, place the +template at the beginning or end of the file. +Of course, if exact position has been required, just put it at point." (let* ((txt (org-capture-get :template)) beg end) - (goto-char (cond - ((org-capture-get :exact-position)) - ((org-capture-get :prepend) (point-min)) - (t (point-max)))) + (cond + ((org-capture-get :exact-position)) + ((and (org-capture-get :target-entry-p) + (bolp) + (looking-at org-outline-regexp)) + ;; we should place the text into this entry + (if (org-capture-get :prepend) + ;; Skip meta data and drawers + (org-end-of-meta-data-and-drawers) + ;; go to ent of the entry text, before the next headline + (outline-next-heading))) + (t + ;; beginning or end of file + (goto-char (if (org-capture-get :prepend) (point-min) (point-max))))) (or (bolp) (newline)) (org-capture-empty-lines-before) (setq beg (point)) diff --git a/lisp/org.el b/lisp/org.el index 24d2077..2c0a09b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19827,6 +19827,27 @@ If there is no such heading, return nil." (unless (eobp) (backward-char 1))) ad-do-it)) +(defun org-end-of-meta-data-and-drawers () + "Jump to the first text after meta data and drawers in the current entry. +This will move over empty lines, lines with planning time stamps, +clocking lines, and drawers." + (org-back-to-heading t) + (let ((end (save-excursion (outline-next-heading) (point))) + (re (concat "[ \t]*$" + "\\|" + "\\(" org-drawer-regexp "\\)" ; group 1 are drawers + "\\|" + "\\([ \t]*\\(" org-keyword-time-regexp "\\)\\)"))) + (forward-line 1) + (while (looking-at (concat "[ \t]*\\(" org-keyword-time-regexp "\\)")) + (if (not (match-end 1)) + ;; empty or planning line + (forward-line 1) + ;; a drawer, find the end + (re-search-forward "^[ \t]*:END:" end 'move) + (forward-line 1))) + (point))) + (defun org-forward-same-level (arg &optional invisible-ok) "Move forward to the arg'th subheading at same level as this one. Stop at the first and last subheadings of a superior heading. |