New escape %& in remember templates, to visit note after storing it.

This was a request by Adam Spiers.
This commit is contained in:
Carsten Dominik 2008-06-11 07:15:56 +02:00
parent edfd4f8abf
commit 52bd68a47a
3 changed files with 29 additions and 1 deletions

View File

@ -4873,6 +4873,7 @@ insertion of content:
%(sexp) @r{evaluate elisp @code{(sexp)} and replace with the result}
%! @r{immediately store note after completing the template}
@r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
%& @r{jump to target location immediately after storing note}
@end example
@noindent

View File

@ -1,5 +1,11 @@
2008-06-10 Carsten Dominik <dominik@science.uva.nl>
* org-remember.el (org-jump-to-target-location): New variable.
(org-remember-apply-template): Set `org-remember-apply-template'
if requested by template.
(org-remember-handler): Start an idle timer to jump to remember
location.
* org-exp.el (org-get-current-options): Add the FILETAGS setting.
* org.el (org-set-regexps-and-options): Fix bug with parsing of

View File

@ -130,6 +130,7 @@ Furthermore, the following %-escapes will be replaced with content:
%[pathname] insert the contents of the file given by `pathname'
%(sexp) evaluate elisp `(sexp)' and replace with the result
%! Store this note immediately after filling the template
%& Visit note immediately after storing it
%? After completing the template, position cursor here.
@ -216,6 +217,7 @@ RET on headline -> Store as sublevel entry to current headline
RET at beg-of-buf -> Append to file as level 2 headline
<left>/<right> -> before/after current headline, same headings level")
(defvar org-jump-to-target-location nil)
(defvar org-remember-previous-location nil)
(defvar org-force-remember-template-char) ;; dynamically scoped
@ -475,6 +477,11 @@ to be run from that hook to function properly."
(and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
(org-mode)
(org-set-local 'org-finish-function 'org-remember-finalize))
(when (save-excursion
(goto-char (point-min))
(re-search-forward "%&" nil t))
(replace-match "")
(org-set-local 'org-jump-to-target-location t))
(when (save-excursion
(goto-char (point-min))
(re-search-forward "%!" nil t))
@ -489,6 +496,17 @@ from that hook."
(when org-finish-function
(funcall org-finish-function)))
(defun org-remember-visit-immediately ()
"File remember note immediately.
This should be run in `post-command-hook' and will remove itself
from that hook."
(org-remember '(16))
(message "%s"
(format
(substitute-command-keys
"Restore window configuration with \\[jump-to-register] %c")
remember-register)))
(defvar org-clock-marker) ; Defined in org.el
(defun org-remember-finalize ()
"Finalize the remember process."
@ -625,7 +643,8 @@ See also the variable `org-reverse-note-order'."
(beginning-of-line 1))
(catch 'quit
(if org-note-abort (throw 'quit nil))
(let* ((fastp (org-xor (equal current-prefix-arg '(4))
(let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
(fastp (org-xor (equal current-prefix-arg '(4))
org-remember-store-without-prompt))
(file (cond
(fastp org-default-notes-file)
@ -672,6 +691,7 @@ See also the variable `org-reverse-note-order'."
(when (and (eq org-remember-interactive-interface 'refile)
(not fastp))
(org-refile nil (or visiting (find-file-noselect file)))
(and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
(throw 'quit t))
;; Find the file
(if (not visiting) (find-file-noselect file))
@ -718,6 +738,7 @@ See also the variable `org-reverse-note-order'."
(t (error "This should not happen")))
(if (not spos) (throw 'quit nil)) ; return nil to show we did
; not handle this note
(and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
(goto-char spos)
(cond ((org-on-heading-p t)
(org-back-to-heading t)