summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-06-16 16:39:25 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-06-16 17:03:22 +0200
commit42a2c248eb1ce1125531a688cefc01e3884f4182 (patch)
treea9e053363fd81442ed538d8713ca8cb631569472
parentdcf179663626872bae88ff36f58ad1c745f96b45 (diff)
downloadorg-mode-42a2c248eb1ce1125531a688cefc01e3884f4182.tar.gz
org-capture: Fix completion for properties in capture buffer
* lisp/org.el (org-read-property-value): * lisp/org-capture.el (org-capture-fill-template): Sidestep `org-set-property'. Use previous function and `org-entry-put' instead. Reported-by: Eric Danan <eric.danan@u-cergy.fr> <http://lists.gnu.org/r/emacs-orgmode/2018-06/msg00061.html>
-rw-r--r--lisp/org-capture.el14
-rw-r--r--lisp/org.el42
2 files changed, 39 insertions, 17 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index eeddd2a..ef694dd 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1695,7 +1695,19 @@ The template may still contain \"%?\" for cursor positioning."
first-value)))
(_ (error "Invalid `org-capture--clipboards' value: %S"
org-capture--clipboards)))))
- ("p" (org-set-property prompt nil))
+ ("p"
+ (let ((value (org-read-property-value
+ prompt
+ (set-marker (make-marker)
+ (org-capture-get :pos)
+ (org-capture-get :buffer)))))
+ (org-entry-put
+ nil prompt
+ (pcase (assoc-string prompt
+ org-properties-postprocess-alist
+ t)
+ (`(,_ . ,f) (funcall f value))
+ (_ value)))))
((or "t" "T" "u" "U")
;; These are the date/time related ones.
(let* ((upcase? (equal (upcase key) key))
diff --git a/lisp/org.el b/lisp/org.el
index 2dba348..94ff48b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15636,23 +15636,33 @@ This is computed according to `org-property-set-functions-alist'."
(or (cdr (assoc property org-property-set-functions-alist))
'org-completing-read))
-(defun org-read-property-value (property)
- "Read PROPERTY value from user."
+(defun org-read-property-value (property &optional pom)
+ "Read value for PROPERTY, as a string.
+When optional argument POM is non-nil, completion uses additional
+information, i.e., allowed or existing values at point or marker
+POM."
(let* ((completion-ignore-case t)
- (allowed (org-property-get-allowed-values nil property 'table))
- (cur (org-entry-get nil property))
- (prompt (concat property " value"
- (if (and cur (string-match "\\S-" cur))
- (concat " [" cur "]") "") ": "))
- (set-function (org-set-property-function property))
- (val (if allowed
- (funcall set-function prompt allowed nil
- (not (get-text-property 0 'org-unrestricted
- (caar allowed))))
- (funcall set-function prompt
- (mapcar 'list (org-property-values property))
- nil nil "" nil cur))))
- (org-trim val)))
+ (allowed
+ (or (org-property-get-allowed-values nil property 'table)
+ (and pom (org-property-get-allowed-values pom property 'table))))
+ (current (org-entry-get nil property))
+ (prompt (format "%s value%s: "
+ property
+ (if (org-string-nw-p current)
+ (format " [%s]" current)
+ "")))
+ (set-function (org-set-property-function property)))
+ (org-trim
+ (if allowed
+ (funcall set-function
+ prompt allowed nil
+ (not (get-text-property 0 'org-unrestricted (caar allowed))))
+ (let ((all (mapcar #'list
+ (append (org-property-values property)
+ (and pom
+ (org-with-point-at pom
+ (org-property-values property)))))))
+ (funcall set-function prompt all nil nil "" nil current))))))
(defvar org-last-set-property nil)
(defvar org-last-set-property-value nil)