Selaa lähdekoodia

Allow to jump to capture template after finalizing

* lisp/org-capture.el (org-capture-finalize): New prefix argument
STAY-WITH-CAPTURE.
(org-capture-refile): Improve docstring.
* doc/org.texi (Using capture): Document using prefix arguments for
finalizing capture.
Carsten Dominik 14 vuotta sitten
vanhempi
commit
970b2f7b88
2 muutettua tiedostoa jossa 18 lisäystä ja 8 poistoa
  1. 4 2
      doc/org.texi
  2. 14 6
      lisp/org-capture.el

+ 4 - 2
doc/org.texi

@@ -6149,14 +6149,16 @@ narrowed to this new node.  You may then insert the information you want.
 @orgcmd{C-c C-c,org-capture-finalize}
 Once you have finished entering information into the capture buffer, @kbd{C-c
 C-c} will return you to the window configuration before the capture process,
-so that you can resume your work without further distraction.
+so that you can resume your work without further distraction.  When called
+with a prefix arg, finalize and then jump to the captured item.
 
 @orgcmd{C-c C-w,org-capture-refile}
 Finalize the capture process by refiling (@pxref{Refiling notes}) the note to
 a different place.  Please realize that this is a normal refiling command
 that will be executed - so the cursor position at the moment you run this
 command is important.  If you have inserted a tree with a parent and
-children, first move the cursor back to the parent.
+children, first move the cursor back to the parent.  Any prefix argument
+given to this command will be passed on to the @code{org-refile} command.
 
 @orgcmd{C-c C-k,org-capture-kill}
 Abort the capture process and return to the previous state.

+ 14 - 6
lisp/org-capture.el

@@ -473,9 +473,11 @@ bypassed."
      (t (setq txt "* Invalid capture template")))
     (org-capture-put :template txt)))
 
-(defun org-capture-finalize ()
-  "Finalize the capture process."
-  (interactive)
+(defun org-capture-finalize (&optional stay-with-capture)
+  "Finalize the capture process.
+With prefix argument STAY-WITH-CAPTURE, jump to the location of the
+captured item after finalizing."
+  (interactive "P")
   (unless (and org-capture-mode
 	       (buffer-base-buffer (current-buffer)))
     (error "This does not seem to be a capture buffer for Org-mode"))
@@ -562,17 +564,23 @@ bypassed."
       (set-window-configuration return-wconf))
 
     (run-hooks 'org-capture-after-finalize-hook)
-    (when abort-note
+    ;; Special cases
+    (cond
+     (abort-note
       (cond
        ((equal abort-note 'clean)
 	(message "Capture process aborted and target buffer cleaned up"))
        ((equal abort-note 'dirty)
-	(error "Capture process aborted, but target buffer could not be cleaned up correctly"))))))
+	(error "Capture process aborted, but target buffer could not be cleaned up correctly"))))
+     (stay-with-capture
+      (org-capture-goto-last-stored)))
+    ;; Return if we did store something
+    (not abort-note)))
 
 (defun org-capture-refile ()
   "Finalize the current capture and then refile the entry.
 Refiling is done from the base buffer, because the indirect buffer is then
-already gone."
+already gone.  Any prefix argument will be passed to the refile comand."
   (interactive)
   (unless (eq (org-capture-get :type 'local) 'entry)
     (error