unofficial mirror of emacs-orgmode@gnu.org
 help / color / mirror / Atom feed
* RFE: Capture: property prompt: default completion
@ 2020-09-12 18:20 Phil Hudson
  2020-09-13 23:32 ` Phil Hudson
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Hudson @ 2020-09-12 18:20 UTC (permalink / raw)
  To: emacs orgmode-mailinglist

I'd like us to add the ability to provide a default completion value
for a property prompt in a capture template, as already exists for a
non-property prompt.

So where at the moment we can have:

    %^{prompt|default|completion2|completion3|...}

I want, by analogy:

    %^{prop|default}p

with the remaining completions provided by the #+prop_ALL in-buffer
setting, and with the implied constraint that "default" is a member of
that set.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFE: Capture: property prompt: default completion
  2020-09-12 18:20 RFE: Capture: property prompt: default completion Phil Hudson
@ 2020-09-13 23:32 ` Phil Hudson
  2020-09-14  8:20   ` [PATCH] " Phil Hudson
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Hudson @ 2020-09-13 23:32 UTC (permalink / raw)
  To: emacs orgmode-mailinglist

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

On Sat, 12 Sep 2020 at 19:20, Phil Hudson <phil.hudson@iname.com> wrote:
>
> I'd like us to add the ability to provide a default completion value
> for a property prompt in a capture template, as already exists for a
> non-property prompt.
>
> So where at the moment we can have:
>
>     %^{prompt|default|completion2|completion3|...}
>
> I want, by analogy:
>
>     %^{prop|default}p
>
> with the remaining completions provided by the #+prop_ALL in-buffer
> setting, and with the implied constraint that "default" is a member of
> that set.

I'm going to take silence for consent, then. Patch attached.

[-- Attachment #2: org-capture-default-for-property.patch --]
[-- Type: text/x-patch, Size: 2879 bytes --]

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 46498bd22..659e3ffaf 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7854,7 +7854,8 @@ here:
 
 - =%^{PROP}p= ::
 
-  Prompt the user for a value for property {{{var(PROP)}}}.
+  Prompt the user for a value for property {{{var(PROP)}}}.  You may
+  specify a default value with =%^{PROP|default}=.
 
 - =%^{PROMPT}= ::
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d9c8472b9..de2e19a8b 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -331,8 +331,10 @@ be replaced with content and expanded:
   %^C         Interactive selection of which kill or clip to use.
   %^L         Like %^C, but insert as link.
   %^{prop}p   Prompt the user for a value for property `prop'.
+              A default value can be specified like this:
+              %^{prop|default}p.
   %^{prompt}  Prompt the user for a string and replace this sequence with it.
-              A default value and a completion table ca be specified like this:
+              A default value and a completion table can be specified like this:
               %^{prompt|default|completion2|completion3|...}.
   %?          After completing the template, position cursor here.
   %\\1 ... %\\N Insert the text entered at the nth %^{prompt}, where N
@@ -1782,7 +1784,8 @@ The template may still contain \"%?\" for cursor positioning."
 					   (setq l (org-up-heading-safe)))
 					 (if l (point-marker)
 					   (point-min-marker)))))))
-			    (value (org-read-property-value prompt pom)))
+			    (value
+			     (org-read-property-value prompt pom default)))
 		       (org-set-property prompt value)))
 		    ((or "t" "T" "u" "U")
 		     ;; These are the date/time related ones.
diff --git a/lisp/org.el b/lisp/org.el
index 3264694aa..4077530f1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13300,11 +13300,12 @@ 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 &optional pom)
+(defun org-read-property-value (property &optional pom default)
   "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."
+POM.
+Optional argument DEFAULT provides a default value for PROPERTY."
   (let* ((completion-ignore-case t)
 	 (allowed
 	  (or (org-property-get-allowed-values nil property 'table)
@@ -13320,7 +13321,8 @@ POM."
      (if allowed
 	 (funcall set-function
 		  prompt allowed nil
-		  (not (get-text-property 0 'org-unrestricted (caar allowed))))
+		  (not (get-text-property 0 'org-unrestricted (caar allowed)))
+		  default nil default)
        (let ((all (mapcar #'list
 			  (append (org-property-values property)
 				  (and pom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] Re: RFE: Capture: property prompt: default completion
  2020-09-13 23:32 ` Phil Hudson
@ 2020-09-14  8:20   ` Phil Hudson
  2020-09-23  7:21     ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Hudson @ 2020-09-14  8:20 UTC (permalink / raw)
  To: emacs orgmode-mailinglist

[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

Sorry, should have changed the subject. Re-sending patch (no alterations).

On Mon, 14 Sep 2020 at 00:32, Phil Hudson <phil.hudson@iname.com> wrote:
>
> On Sat, 12 Sep 2020 at 19:20, Phil Hudson <phil.hudson@iname.com> wrote:
> >
> > I'd like us to add the ability to provide a default completion value
> > for a property prompt in a capture template, as already exists for a
> > non-property prompt.
> >
> > So where at the moment we can have:
> >
> >     %^{prompt|default|completion2|completion3|...}
> >
> > I want, by analogy:
> >
> >     %^{prop|default}p
> >
> > with the remaining completions provided by the #+prop_ALL in-buffer
> > setting, and with the implied constraint that "default" is a member of
> > that set.

[-- Attachment #2: org-capture-default-for-property.patch --]
[-- Type: text/x-patch, Size: 2879 bytes --]

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 46498bd22..659e3ffaf 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7854,7 +7854,8 @@ here:
 
 - =%^{PROP}p= ::
 
-  Prompt the user for a value for property {{{var(PROP)}}}.
+  Prompt the user for a value for property {{{var(PROP)}}}.  You may
+  specify a default value with =%^{PROP|default}=.
 
 - =%^{PROMPT}= ::
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d9c8472b9..de2e19a8b 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -331,8 +331,10 @@ be replaced with content and expanded:
   %^C         Interactive selection of which kill or clip to use.
   %^L         Like %^C, but insert as link.
   %^{prop}p   Prompt the user for a value for property `prop'.
+              A default value can be specified like this:
+              %^{prop|default}p.
   %^{prompt}  Prompt the user for a string and replace this sequence with it.
-              A default value and a completion table ca be specified like this:
+              A default value and a completion table can be specified like this:
               %^{prompt|default|completion2|completion3|...}.
   %?          After completing the template, position cursor here.
   %\\1 ... %\\N Insert the text entered at the nth %^{prompt}, where N
@@ -1782,7 +1784,8 @@ The template may still contain \"%?\" for cursor positioning."
 					   (setq l (org-up-heading-safe)))
 					 (if l (point-marker)
 					   (point-min-marker)))))))
-			    (value (org-read-property-value prompt pom)))
+			    (value
+			     (org-read-property-value prompt pom default)))
 		       (org-set-property prompt value)))
 		    ((or "t" "T" "u" "U")
 		     ;; These are the date/time related ones.
diff --git a/lisp/org.el b/lisp/org.el
index 3264694aa..4077530f1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13300,11 +13300,12 @@ 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 &optional pom)
+(defun org-read-property-value (property &optional pom default)
   "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."
+POM.
+Optional argument DEFAULT provides a default value for PROPERTY."
   (let* ((completion-ignore-case t)
 	 (allowed
 	  (or (org-property-get-allowed-values nil property 'table)
@@ -13320,7 +13321,8 @@ POM."
      (if allowed
 	 (funcall set-function
 		  prompt allowed nil
-		  (not (get-text-property 0 'org-unrestricted (caar allowed))))
+		  (not (get-text-property 0 'org-unrestricted (caar allowed)))
+		  default nil default)
        (let ((all (mapcar #'list
 			  (append (org-property-values property)
 				  (and pom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Re: RFE: Capture: property prompt: default completion
  2020-09-14  8:20   ` [PATCH] " Phil Hudson
@ 2020-09-23  7:21     ` Bastien
  2020-09-23  9:55       ` Phil Hudson
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2020-09-23  7:21 UTC (permalink / raw)
  To: Phil Hudson; +Cc: emacs orgmode-mailinglist

Hi Phil,

Phil Hudson <phil.hudson@iname.com> writes:

> Sorry, should have changed the subject. Re-sending patch (no alterations).

It looks good to me.

Can you update your patch by adding a proper commit message?

See https://orgmode.org/worg/org-contribute.html#commit-messages

Thanks a lot,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Re: RFE: Capture: property prompt: default completion
  2020-09-23  7:21     ` Bastien
@ 2020-09-23  9:55       ` Phil Hudson
  2020-09-23 11:15         ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Hudson @ 2020-09-23  9:55 UTC (permalink / raw)
  To: Bastien; +Cc: emacs orgmode-mailinglist

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

On Wed, 23 Sep 2020 at 08:21, Bastien <bzg@gnu.org> wrote:
> It looks good to me.
>
> Can you update your patch by adding a proper commit message?

Herewith. Hope I've got it right. I've signed the FSF papers.

[-- Attachment #2: org-capture-default-for-property.patch --]
[-- Type: text/x-patch, Size: 3320 bytes --]

org-capture.el: Give a default value when prompting for a property

* lisp/org-capture.el (org-capture-templates, org-capture-fill-template):
  Enable declaring a default value when prompting for a property during
  capture.

* lisp/org.el (org-read-property-value): Add parameter DEFAULT for an
  initial/default/suggested property value.

* doc/org-manual.org: Document declaring a default value for a prompted
  property during capture.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 46498bd22..659e3ffaf 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7854,7 +7854,8 @@ here:
 
 - =%^{PROP}p= ::
 
-  Prompt the user for a value for property {{{var(PROP)}}}.
+  Prompt the user for a value for property {{{var(PROP)}}}.  You may
+  specify a default value with =%^{PROP|default}=.
 
 - =%^{PROMPT}= ::
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d9c8472b9..de2e19a8b 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -331,8 +331,10 @@ be replaced with content and expanded:
   %^C         Interactive selection of which kill or clip to use.
   %^L         Like %^C, but insert as link.
   %^{prop}p   Prompt the user for a value for property `prop'.
+              A default value can be specified like this:
+              %^{prop|default}p.
   %^{prompt}  Prompt the user for a string and replace this sequence with it.
-              A default value and a completion table ca be specified like this:
+              A default value and a completion table can be specified like this:
               %^{prompt|default|completion2|completion3|...}.
   %?          After completing the template, position cursor here.
   %\\1 ... %\\N Insert the text entered at the nth %^{prompt}, where N
@@ -1782,7 +1784,8 @@ The template may still contain \"%?\" for cursor positioning."
 					   (setq l (org-up-heading-safe)))
 					 (if l (point-marker)
 					   (point-min-marker)))))))
-			    (value (org-read-property-value prompt pom)))
+			    (value
+			     (org-read-property-value prompt pom default)))
 		       (org-set-property prompt value)))
 		    ((or "t" "T" "u" "U")
 		     ;; These are the date/time related ones.
diff --git a/lisp/org.el b/lisp/org.el
index 3264694aa..4077530f1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13300,11 +13300,12 @@ 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 &optional pom)
+(defun org-read-property-value (property &optional pom default)
   "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."
+POM.
+Optional argument DEFAULT provides a default value for PROPERTY."
   (let* ((completion-ignore-case t)
 	 (allowed
 	  (or (org-property-get-allowed-values nil property 'table)
@@ -13320,7 +13321,8 @@ POM."
      (if allowed
 	 (funcall set-function
 		  prompt allowed nil
-		  (not (get-text-property 0 'org-unrestricted (caar allowed))))
+		  (not (get-text-property 0 'org-unrestricted (caar allowed)))
+		  default nil default)
        (let ((all (mapcar #'list
 			  (append (org-property-values property)
 				  (and pom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Re: RFE: Capture: property prompt: default completion
  2020-09-23  9:55       ` Phil Hudson
@ 2020-09-23 11:15         ` Bastien
  2020-09-23 11:40           ` Phil Hudson
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2020-09-23 11:15 UTC (permalink / raw)
  To: Phil Hudson; +Cc: emacs orgmode-mailinglist

Phil Hudson <phil.hudson@iname.com> writes:

> On Wed, 23 Sep 2020 at 08:21, Bastien <bzg@gnu.org> wrote:
>> It looks good to me.
>>
>> Can you update your patch by adding a proper commit message?
>
> Herewith. Hope I've got it right. I've signed the FSF papers.

Sorry, I should have mentioned this, but the patch does not apply on
master.  If you have time to merge recent changes and reformat it, I
can apply it right afterwarsds, otherwise I will try to do it myself
later this week.

Thanks,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Re: RFE: Capture: property prompt: default completion
  2020-09-23 11:15         ` Bastien
@ 2020-09-23 11:40           ` Phil Hudson
  2020-09-23 12:12             ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Hudson @ 2020-09-23 11:40 UTC (permalink / raw)
  To: Bastien; +Cc: emacs orgmode-mailinglist

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

On Wed, 23 Sep 2020 at 12:15, Bastien <bzg@gnu.org> wrote:
>
> Sorry, I should have mentioned this, but the patch does not apply on
> master.  If you have time to merge recent changes and reformat it, I
> can apply it right afterwarsds, otherwise I will try to do it myself
> later this week.

OK, herewith.

[-- Attachment #2: org-capture-default-for-property.patch --]
[-- Type: text/x-patch, Size: 3099 bytes --]

org-capture.el: Give a default value when prompting for a property

* lisp/org-capture.el (org-capture-templates, org-capture-fill-template):
  Enable declaring a default value when prompting for a property during
  capture.

* lisp/org.el (org-read-property-value): Add parameter DEFAULT for an
  initial/default/suggested property value.

* doc/org-manual.org: Document declaring a default value for a prompted
  property during capture.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 043f2ddd1..e7d25b90e 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7858,7 +7858,8 @@ here:
 
 - =%^{PROP}p= ::
 
-  Prompt the user for a value for property {{{var(PROP)}}}.
+  Prompt the user for a value for property {{{var(PROP)}}}.  You may
+  specify a default value with =%^{PROP|default}=.
 
 - =%^{PROMPT}= ::
 
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 2ef55cd5c..9ea0e9e73 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -332,6 +332,8 @@ be replaced with content and expanded:
   %^C         Interactive selection of which kill or clip to use.
   %^L         Like %^C, but insert as link.
   %^{prop}p   Prompt the user for a value for property `prop'.
+              A default value can be specified like this:
+              %^{prop|default}p.
   %^{prompt}  Prompt the user for a string and replace this sequence with it.
               A default value and a completion table can be specified like this:
               %^{prompt|default|completion2|completion3|...}.
@@ -1787,7 +1789,8 @@ The template may still contain \"%?\" for cursor positioning."
 					   (setq l (org-up-heading-safe)))
 					 (if l (point-marker)
 					   (point-min-marker)))))))
-			    (value (org-read-property-value prompt pom)))
+			    (value
+			     (org-read-property-value prompt pom default))) 
 		       (org-set-property prompt value)))
 		    ((or "t" "T" "u" "U")
 		     ;; These are the date/time related ones.
diff --git a/lisp/org.el b/lisp/org.el
index d45a789f2..ec336c723 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13300,11 +13300,12 @@ 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 &optional pom)
+(defun org-read-property-value (property &optional pom default)
   "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."
+POM.
+Optional argument DEFAULT provides a default value for PROPERTY."
   (let* ((completion-ignore-case t)
 	 (allowed
 	  (or (org-property-get-allowed-values nil property 'table)
@@ -13320,7 +13321,8 @@ POM."
      (if allowed
 	 (funcall set-function
 		  prompt allowed nil
-		  (not (get-text-property 0 'org-unrestricted (caar allowed))))
+		  (not (get-text-property 0 'org-unrestricted (caar allowed)))
+		  default nil default)
        (let ((all (mapcar #'list
 			  (append (org-property-values property)
 				  (and pom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Re: RFE: Capture: property prompt: default completion
  2020-09-23 11:40           ` Phil Hudson
@ 2020-09-23 12:12             ` Bastien
  0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2020-09-23 12:12 UTC (permalink / raw)
  To: Phil Hudson; +Cc: emacs orgmode-mailinglist

Phil Hudson <phil.hudson@iname.com> writes:

> On Wed, 23 Sep 2020 at 12:15, Bastien <bzg@gnu.org> wrote:
>>
>> Sorry, I should have mentioned this, but the patch does not apply on
>> master.  If you have time to merge recent changes and reformat it, I
>> can apply it right afterwarsds, otherwise I will try to do it myself
>> later this week.
>
> OK, herewith.

Applied, thanks!

-- 
 Bastien


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-23 12:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-12 18:20 RFE: Capture: property prompt: default completion Phil Hudson
2020-09-13 23:32 ` Phil Hudson
2020-09-14  8:20   ` [PATCH] " Phil Hudson
2020-09-23  7:21     ` Bastien
2020-09-23  9:55       ` Phil Hudson
2020-09-23 11:15         ` Bastien
2020-09-23 11:40           ` Phil Hudson
2020-09-23 12:12             ` Bastien

unofficial mirror of emacs-orgmode@gnu.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/orgmode/0 orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ https://yhetil.org/orgmode \
		emacs-orgmode@gnu.org
	public-inbox-index orgmode

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git