emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-capture-templates: %date is too long
@ 2021-03-04  9:22 Uwe Brauer
  2021-03-04 11:57 ` Alberto AP
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Brauer @ 2021-03-04  9:22 UTC (permalink / raw)
  To: emacs-orgmode



Hi

I try to add a new entry to my org-capture-templates
for mails what I read via gnus. I'd like to have a timestamp that
reflects when the message was received, not when the entry was created
(for that I would to have to use %t)

Now I have set 

         "| | %:fromname|%:fromaddress|%^{Sheet|1|2|3|4|5|6|7|8|9} | %:date |[ ] | | %a " :prepend t)

Using the description of the org-capture-template

------------------------+------------------------------------------------------
gnus                    |  %:from %:fromname %:fromaddress
                        |  %:to   %:toname   %:toaddress
                        |  %:fromto (either "to NAME" or "from NAME")
                        |  %:date %:date-timestamp (as active timestamp)
                        |  %:date-timestamp-inactive (as inactive timestamp)
gnus                    |  %:group, for messages also all email fields

The problem is this results in 

| Number | name     | email             | sheet | date                           | status |
|        | John Doe | footbar@gmail.com |     2 | Tue, 2 Mar 2021 19:35:03 +0100 | [ ]    |

I don't need the hour, and for sure I don't need +0100

Any idea how to shorten that?

regards

Uwe Brauer 



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

* Re: org-capture-templates: %date is too long
  2021-03-04  9:22 org-capture-templates: %date is too long Uwe Brauer
@ 2021-03-04 11:57 ` Alberto AP
  2021-03-04 14:22   ` Uwe Brauer
  0 siblings, 1 reply; 10+ messages in thread
From: Alberto AP @ 2021-03-04 11:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi

What I use is the result of format-time-string (as explained in the Org
Capture Templates help; check also the help for the format-time-string
function).

The string I use is:
%<%Y%m%d-T%H%M%S>
It gives me, for example, 20210304-T095526.

If you don't want the hour just remove "-T%H%M%S"

Best,
Alberto

Uwe Brauer <oub@mat.ucm.es> writes:

> Hi
>
> I try to add a new entry to my org-capture-templates
> for mails what I read via gnus. I'd like to have a timestamp that
> reflects when the message was received, not when the entry was created
> (for that I would to have to use %t)
>
> Now I have set 
>
>          "| | %:fromname|%:fromaddress|%^{Sheet|1|2|3|4|5|6|7|8|9} | %:date |[ ] | | %a " :prepend t)
>
> Using the description of the org-capture-template
>
> ------------------------+------------------------------------------------------
> gnus                    |  %:from %:fromname %:fromaddress
>                         |  %:to   %:toname   %:toaddress
>                         |  %:fromto (either "to NAME" or "from NAME")
>                         |  %:date %:date-timestamp (as active timestamp)
>                         |  %:date-timestamp-inactive (as inactive timestamp)
> gnus                    |  %:group, for messages also all email fields
>
> The problem is this results in 
>
> | Number | name     | email             | sheet | date                           | status |
> |        | John Doe | footbar@gmail.com |     2 | Tue, 2 Mar 2021 19:35:03 +0100 | [ ]    |
>
> I don't need the hour, and for sure I don't need +0100
>
> Any idea how to shorten that?
>
> regards
>
> Uwe Brauer 


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

* Re: org-capture-templates: %date is too long
  2021-03-04 11:57 ` Alberto AP
@ 2021-03-04 14:22   ` Uwe Brauer
  2021-03-04 17:06     ` Robert Pluim
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Brauer @ 2021-03-04 14:22 UTC (permalink / raw)
  To: emacs-orgmode

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

>>> "AA" == Alberto AP <alberto.arias@gm.uca.es> writes:

Hi


> Hi
> What I use is the result of format-time-string (as explained in the Org
> Capture Templates help; check also the help for the format-time-string
> function).

> The string I use is:
> %<%Y%m%d-T%H%M%S>
> It gives me, for example, 20210304-T095526.

> If you don't want the hour just remove "-T%H%M%S"

Sorry, you misunderstood me, this time string, inserts the time string,
when I execute the capture, but I want to extract the time string, when
the message was received. This is why I used 
%:date
in my first attempt, that works but inserts 
Tue, 2 Mar 2021 19:35:03 +0100  

Which I find way too long.

Just 
Tue, 2 Mar 2021 

Would be fine or 02.03.2021

But not the hour, seconds etc

Uwe Brauer 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: org-capture-templates: %date is too long
  2021-03-04 14:22   ` Uwe Brauer
@ 2021-03-04 17:06     ` Robert Pluim
  2021-03-04 20:24       ` Uwe Brauer
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Pluim @ 2021-03-04 17:06 UTC (permalink / raw)
  To: emacs-orgmode

>>>>> On Thu, 04 Mar 2021 15:22:21 +0100, Uwe Brauer <oub@mat.ucm.es> said:
    Uwe> Sorry, you misunderstood me, this time string, inserts the time string,
    Uwe> when I execute the capture, but I want to extract the time string, when
    Uwe> the message was received. This is why I used 
    Uwe> %:date
    Uwe> in my first attempt, that works but inserts 
    Uwe> Tue, 2 Mar 2021 19:35:03 +0100  

    Uwe> Which I find way too long.

    Uwe> Just 
    Uwe> Tue, 2 Mar 2021 

    Uwe> Would be fine or 02.03.2021

    Uwe> But not the hour, seconds etc

It looks like the %:date handling respects the
'org-time-stamp-formats' variable, so if you can arrange for that to
be let-bound appropriately during the capture process, it might do the
right thing.

Robert
-- 


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

* Re: org-capture-templates: %date is too long
  2021-03-04 17:06     ` Robert Pluim
@ 2021-03-04 20:24       ` Uwe Brauer
  2021-03-04 20:37         ` Tim Cross
  2021-03-09 15:21         ` Robert Pluim
  0 siblings, 2 replies; 10+ messages in thread
From: Uwe Brauer @ 2021-03-04 20:24 UTC (permalink / raw)
  To: emacs-orgmode

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

>>> "RP" == Robert Pluim <rpluim@gmail.com> writes:

   >>>>>> On Thu, 04 Mar 2021 15:22:21 +0100, Uwe Brauer <oub@mat.ucm.es> said:
   Uwe> Sorry, you misunderstood me, this time string, inserts the time string,
   Uwe> when I execute the capture, but I want to extract the time string, when
   Uwe> the message was received. This is why I used 
   Uwe> %:date
   Uwe> in my first attempt, that works but inserts 
   Uwe> Tue, 2 Mar 2021 19:35:03 +0100  

   Uwe> Which I find way too long.

   Uwe> Just 
   Uwe> Tue, 2 Mar 2021 

   Uwe> Would be fine or 02.03.2021

   Uwe> But not the hour, seconds etc

   > It looks like the %:date handling respects the
   > 'org-time-stamp-formats' variable, so if you can arrange for that to
   > be let-bound appropriately during the capture process, it might do the
   > right thing.

Hm that variable is set to 

Its value is ("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")

So if I call with a prefix it inserts 
<2021-03-04 jue 21:19>

But nothing like +0100  

I am not acquainted with let-bound (only with let)

So are you saying I should may use defadvice to modify org-capture?

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: org-capture-templates: %date is too long
  2021-03-04 20:24       ` Uwe Brauer
@ 2021-03-04 20:37         ` Tim Cross
  2021-03-05  7:32           ` Uwe Brauer
  2021-03-09 15:21         ` Robert Pluim
  1 sibling, 1 reply; 10+ messages in thread
From: Tim Cross @ 2021-03-04 20:37 UTC (permalink / raw)
  To: emacs-orgmode


Uwe Brauer <oub@mat.ucm.es> writes:

>>>> "RP" == Robert Pluim <rpluim@gmail.com> writes:
>
>    >>>>>> On Thu, 04 Mar 2021 15:22:21 +0100, Uwe Brauer <oub@mat.ucm.es> said:
>    Uwe> Sorry, you misunderstood me, this time string, inserts the time string,
>    Uwe> when I execute the capture, but I want to extract the time string, when
>    Uwe> the message was received. This is why I used
>    Uwe> %:date
>    Uwe> in my first attempt, that works but inserts
>    Uwe> Tue, 2 Mar 2021 19:35:03 +0100
>
>    Uwe> Which I find way too long.
>
>    Uwe> Just
>    Uwe> Tue, 2 Mar 2021
>
>    Uwe> Would be fine or 02.03.2021
>
>    Uwe> But not the hour, seconds etc
>
>    > It looks like the %:date handling respects the
>    > 'org-time-stamp-formats' variable, so if you can arrange for that to
>    > be let-bound appropriately during the capture process, it might do the
>    > right thing.
>
> Hm that variable is set to
>
> Its value is ("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
>
> So if I call with a prefix it inserts
> <2021-03-04 jue 21:19>
>
> But nothing like +0100
>
> I am not acquainted with let-bound (only with let)
>
> So are you saying I should may use defadvice to modify org-capture?

Capture templates allow inclusion of an arbitrary elisp expression with
%(EXP). You could try defining an elisp function which accepts %:date as
an argument (i.e. a string arg) and formats it using normal elisp date/time functions and
returns the result as a string and then call that function within your
template?

--
Tim Cross


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

* Re: org-capture-templates: %date is too long
  2021-03-04 20:37         ` Tim Cross
@ 2021-03-05  7:32           ` Uwe Brauer
  0 siblings, 0 replies; 10+ messages in thread
From: Uwe Brauer @ 2021-03-05  7:32 UTC (permalink / raw)
  To: emacs-orgmode

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


> Uwe Brauer <oub@mat.ucm.es> writes:

Uwe> Sorry, you misunderstood me, this time string, inserts the time string,
Uwe> when I execute the capture, but I want to extract the time string, when
Uwe> the message was received. This is why I used
Uwe> %:date
Uwe> in my first attempt, that works but inserts
Uwe> Tue, 2 Mar 2021 19:35:03 +0100
Uwe> Which I find way too long.
Uwe> Just
Uwe> Tue, 2 Mar 2021
Uwe> Would be fine or 02.03.2021
Uwe> But not the hour, seconds etc

> Capture templates allow inclusion of an arbitrary elisp expression with
> %(EXP). You could try defining an elisp function which accepts %:date as
> an argument (i.e. a string arg) and formats it using normal elisp date/time functions and
> returns the result as a string and then call that function within your
> template?

Ah, ok now I see I will give it a try at the weekend.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: org-capture-templates: %date is too long
  2021-03-04 20:24       ` Uwe Brauer
  2021-03-04 20:37         ` Tim Cross
@ 2021-03-09 15:21         ` Robert Pluim
  2021-03-12 15:58           ` Uwe Brauer
  1 sibling, 1 reply; 10+ messages in thread
From: Robert Pluim @ 2021-03-09 15:21 UTC (permalink / raw)
  To: emacs-orgmode

>>>>> On Thu, 04 Mar 2021 21:24:03 +0100, Uwe Brauer <oub@mat.ucm.es> said:

    Uwe> I am not acquainted with let-bound (only with let)

'let-bound' is a shorthand for saying 'binding a value using let'

    Uwe> So are you saying I should may use defadvice to modify org-capture?

Well, you have control over how org-capture is invoked, so you could
do:

(defun my-org-capture ()
       (let ((org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a>")))
            (org-capture)))

although you could do it with advice if you wanted. Untested, of course :-)

Robert
-- 


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

* Re: org-capture-templates: %date is too long
  2021-03-09 15:21         ` Robert Pluim
@ 2021-03-12 15:58           ` Uwe Brauer
  2021-03-12 16:36             ` Robert Pluim
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Brauer @ 2021-03-12 15:58 UTC (permalink / raw)
  To: emacs-orgmode

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

>>> "RP" == Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Thu, 04 Mar 2021 21:24:03 +0100, Uwe Brauer <oub@mat.ucm.es> said:
Uwe> I am not acquainted with let-bound (only with let)

> 'let-bound' is a shorthand for saying 'binding a value using let'

Uwe> So are you saying I should may use defadvice to modify org-capture?

> Well, you have control over how org-capture is invoked, so you could
> do:

> (defun my-org-capture ()
>        (let ((org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a>")))
>             (org-capture)))

> although you could do it with advice if you wanted. Untested, of course :-)


Well, in order to run it I added an interactive call, but then 
%:date reminded unimpressed by this setting


the result was 

| user | user@ucm.es |     3 |        3 | [] | Fri, 12 Mar 2021 16:14:35 +0100 |

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: org-capture-templates: %date is too long
  2021-03-12 15:58           ` Uwe Brauer
@ 2021-03-12 16:36             ` Robert Pluim
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Pluim @ 2021-03-12 16:36 UTC (permalink / raw)
  To: emacs-orgmode

>>>>> On Fri, 12 Mar 2021 16:58:27 +0100, Uwe Brauer <oub@mat.ucm.es> said:


    Uwe> Well, in order to run it I added an interactive call, but then 
    Uwe> %:date reminded unimpressed by this setting


    Uwe> the result was 

    Uwe> | user | user@ucm.es |     3 |        3 | [] | Fri, 12 Mar 2021 16:14:35 +0100 |

My mistake, itʼs a defconst, not a defvar, so it may well have been
inserted verbatim into the org code.

Robert
-- 


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

end of thread, other threads:[~2021-03-12 16:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04  9:22 org-capture-templates: %date is too long Uwe Brauer
2021-03-04 11:57 ` Alberto AP
2021-03-04 14:22   ` Uwe Brauer
2021-03-04 17:06     ` Robert Pluim
2021-03-04 20:24       ` Uwe Brauer
2021-03-04 20:37         ` Tim Cross
2021-03-05  7:32           ` Uwe Brauer
2021-03-09 15:21         ` Robert Pluim
2021-03-12 15:58           ` Uwe Brauer
2021-03-12 16:36             ` Robert Pluim

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).