Browse Source

New escape for remember templates to add properties.

Patch by James TD Smith.
Carsten Dominik 16 years ago
parent
commit
7e0dbb6191
3 changed files with 22 additions and 1 deletions
  1. 1 0
      doc/org.texi
  2. 3 0
      lisp/ChangeLog
  3. 18 1
      lisp/org-remember.el

+ 1 - 0
doc/org.texi

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

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-09-20  James TD Smith  <ahktenzero@mohorovi.cc>
 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,
 	* org.el (org-add-log-setup): Skip over drawers (properties,
 	clocks etc) when adding notes.
 	clocks etc) when adding notes.
 
 

+ 18 - 1
lisp/org-remember.el

@@ -135,6 +135,7 @@ Furthermore, the following %-escapes will be replaced with content:
   %^L         Like %^C, but insert as link
   %^L         Like %^C, but insert as link
   %^g         prompt for tags, with completion on tags in target file
   %^g         prompt for tags, with completion on tags in target file
   %^G         prompt for tags, with completion all tags in all agenda files
   %^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
   %:keyword   specific information for certain link types, see below
   %[pathname] insert the contents of the file given by `pathname'
   %[pathname] insert the contents of the file given by `pathname'
   %(sexp)     evaluate elisp `(sexp)' and replace with the result
   %(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))
 	    (org-set-local 'org-remember-default-headline headline))
 	;; Interactive template entries
 	;; Interactive template entries
 	(goto-char (point-min))
 	(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))
 	  (setq char (if (match-end 3) (match-string 3))
 		prompt (if (match-end 2) (match-string 2)))
 		prompt (if (match-end 2) (match-string 2)))
 	  (goto-char (match-beginning 0))
 	  (goto-char (match-beginning 0))
@@ -480,6 +481,22 @@ to be run from that hook to function properly."
 						   (car clipboards)
 						   (car clipboards)
 						   '(clipboards . 1)
 						   '(clipboards . 1)
 						   (car clipboards))))))
 						   (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
 	   (char
 	    ;; These are the date/time related ones
 	    ;; These are the date/time related ones
 	    (setq org-time-was-given (equal (upcase char) char))
 	    (setq org-time-was-given (equal (upcase char) char))