emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Phil Hudson <phil.hudson@iname.com>
To: Bastien <bzg@gnu.org>
Cc: emacs orgmode-mailinglist <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Re: RFE: Capture: property prompt: default completion
Date: Wed, 23 Sep 2020 12:40:46 +0100	[thread overview]
Message-ID: <CAJ1MqVF7EP0BUtTiWvOyi8SAeV==1LPTy6YnfmAUT9NPetV8Eg@mail.gmail.com> (raw)
In-Reply-To: <87wo0khhgv.fsf@gnu.org>

[-- 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

  reply	other threads:[~2020-09-23 11:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-09-23 12:12             ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ1MqVF7EP0BUtTiWvOyi8SAeV==1LPTy6YnfmAUT9NPetV8Eg@mail.gmail.com' \
    --to=phil.hudson@iname.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).