New escape for remember templates to add properties.

Patch by James TD Smith.
This commit is contained in:
Carsten Dominik 2008-09-21 08:05:33 +02:00
parent 8892d9a4bc
commit 7e0dbb6191
3 changed files with 22 additions and 1 deletions

View File

@ -4922,6 +4922,7 @@ insertion of content:
%^L @r{Like @code{%^C}, but insert as link.}
%^g @r{prompt for tags, with completion on tags in target file.}
%^G @r{prompt for tags, with completion all tags in all agenda files.}
%^{prop}p @r{Prompt the user for a value for property @code{prop}}
%:keyword @r{specific information for certain link types, see below}
%[pathname] @r{insert the contents of the file given by @code{pathname}}
%(sexp) @r{evaluate elisp @code{(sexp)} and replace with the result}

View File

@ -1,5 +1,8 @@
2008-09-20 James TD Smith <ahktenzero@mohorovi.cc>
* org-remember.el (org-remember-apply-template): Add a new
expansion for adding properties to remember items.
* org.el (org-add-log-setup): Skip over drawers (properties,
clocks etc) when adding notes.

View File

@ -135,6 +135,7 @@ Furthermore, the following %-escapes will be replaced with content:
%^L Like %^C, but insert as link
%^g prompt for tags, with completion on tags in target file
%^G prompt for tags, with completion all tags in all agenda files
%^{prop}p Prompt the user for a value for property `prop'
%:keyword specific information for certain link types, see below
%[pathname] insert the contents of the file given by `pathname'
%(sexp) evaluate elisp `(sexp)' and replace with the result
@ -435,7 +436,7 @@ to be run from that hook to function properly."
(org-set-local 'org-remember-default-headline headline))
;; Interactive template entries
(goto-char (point-min))
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCL]\\)?" nil t)
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
(setq char (if (match-end 3) (match-string 3))
prompt (if (match-end 2) (match-string 2)))
(goto-char (match-beginning 0))
@ -480,6 +481,22 @@ to be run from that hook to function properly."
(car clipboards)
'(clipboards . 1)
(car clipboards))))))
((equal char "p")
(let*
((prop (substring-no-properties prompt))
(allowed (with-current-buffer
(get-buffer (file-name-nondirectory file))
(org-property-get-allowed-values nil prop 'table)))
(existing (with-current-buffer
(get-buffer (file-name-nondirectory file))
(mapcar 'list (org-property-values prop))))
(propprompt (concat "Value for " prop ": "))
(val (if allowed
(org-completing-read propprompt allowed nil
'req-match)
(org-completing-read propprompt existing nil nil
"" nil ""))))
(org-set-property prop val)))
(char
;; These are the date/time related ones
(setq org-time-was-given (equal (upcase char) char))