New capture property :kill-buffer

* lisp/org-capture.el (org-capture-templates): New capture
property `:kill-buffer'. (org-capture-finalize): Kill target buffer
if that is desired.
(org-capture-target-buffer): Remember if we have to make the buffer.

Proposal by Samuel Wales.
This commit is contained in:
Carsten Dominik 2010-10-26 17:44:34 +02:00
parent 8e12716f68
commit 7635429d44
2 changed files with 24 additions and 3 deletions

View File

@ -6152,6 +6152,10 @@ with the capture.
@item :unnarrowed
Do not narrow the target buffer, simply show the full buffer. Default is to
narrow it so that you only see the new material.
@item :kill-buffer
If the target file was not yet visited when capture was invoked, kill the
buffer again after capture is completed.
@end table
@end table

View File

@ -186,6 +186,10 @@ properties are:
which means that the new line should become the third
line before the second horizontal separator line.
:kill-buffer If the target file was not yet visited by a buffer when
capture was invoked, kill the buffer again after capture
is finalized.
The template defines the text to be inserted. Often this is an org-mode
entry (so the first line should start with a star) that will be filed as a
child of the target headline. It can also be freely formatted text.
@ -301,7 +305,8 @@ calendar | %:type %:date"
((const :format "%v " :empty-lines) (const 1))
((const :format "%v " :clock-in) (const t))
((const :format "%v " :clock-resume) (const t))
((const :format "%v " :unnarrowed) (const t))))))))
((const :format "%v " :unnarrowed) (const t))
((const :format "%v " :kill-buffer) (const t))))))))
(defcustom org-capture-before-finalize-hook nil
"Hook that is run right before a remember process is finalized.
@ -529,8 +534,19 @@ bypassed."
;; Kill the indirect buffer
(save-buffer)
(let ((return-wconf (org-capture-get :return-to-wconf 'local)))
(let ((return-wconf (org-capture-get :return-to-wconf 'local))
(new-buffer (org-capture-get :new-buffer 'local))
(kill-buffer (org-capture-get :kill-buffer 'local))
(base-buffer (buffer-base-buffer (current-buffer))))
;; Kill the indiret buffer
(kill-buffer (current-buffer))
;; Kill the target buffer if that is desired
(when (and base-buffer new-buffer kill-buffer)
(with-current-buffer base-buffer (save-buffer))
(kill-buffer base-buffer))
;; Restore the window configuration before capture
(set-window-configuration return-wconf))
(when abort-note
@ -667,7 +683,8 @@ already gone."
org-default-notes-file
(error "No notes file specified, and no default available")))
(or (org-find-base-buffer-visiting file)
(find-file-noselect (expand-file-name file org-directory))))
(progn (org-capture-put :new-buffer t)
(find-file-noselect (expand-file-name file org-directory)))))
(defun org-capture-steal-local-variables (buffer)
"Install Org-mode local variables."