diff options
author | Bastien Guerry <bzg@altern.org> | 2012-08-11 11:17:35 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-08-11 11:17:35 +0200 |
commit | 1737d3c4ee3278ae747945b570b01749737d0088 (patch) | |
tree | 6e7484318fb78a6c819b7a304a0f6abe077fdca6 | |
parent | 777ee3a4f9f544255b4433fc8c041b490df50e75 (diff) | |
download | org-mode-1737d3c4ee3278ae747945b570b01749737d0088.tar.gz |
New command `org-capture-string'
* org-capture.el (org-capture-string): New command to prompt
for the interactive text interactively. This can also be used
in Elisp programs to use ̀org-capture' with some initial text.
(org-capture-initial): New variable to store the initial text.
(org-capture): Use `org-capture-initial'.
-rw-r--r-- | lisp/org-capture.el | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 53eb2ba..84e5ff6 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -431,6 +431,14 @@ for a capture buffer.") ;;; The main commands ;;;###autoload +(defvar org-capture-initial nil) +(defun org-capture-string (string &optional keys) + (interactive "sInitial text: \n") + (let ((org-capture-initial string) + (entry (org-capture-select-template keys))) + (org-capture))) + +;;;###autoload (defun org-capture (&optional goto keys) "Capture something. \\<org-capture-mode-map> @@ -462,9 +470,11 @@ bypassed." org-capture-link-is-already-stored) (plist-get org-store-link-plist :annotation) (ignore-errors (org-store-link nil)))) - (initial (and (org-region-active-p) - (buffer-substring (point) (mark)))) - (entry (org-capture-select-template keys))) + (entry (or entry (org-capture-select-template keys))) + initial) + (setq initial (or org-capture-initial + (and (org-region-active-p) + (buffer-substring (point) (mark))))) (when (stringp initial) (remove-text-properties 0 (length initial) '(read-only t) initial)) (when (stringp annotation) |