[PATCH] emacs: add support for stashing formatted timestamp

classic Classic list List threaded Threaded
3 messages Options
Jani Nikula Jani Nikula
Reply | Threaded
Open this post in threaded view
|

[PATCH] emacs: add support for stashing formatted timestamp

notmuch-show-stash-date stashes the Date: header of the message
verbatim. While that is useful, sometimes more control of the output
is desirable.

Add support for stashing the message timestamp (as parsed by gmime at
the lib level from the Date: header) according to a user customizable
format. The user can use this to stash the message date in the
preferred format, or perhaps as a date: range query, for example
"date:@%s.." to find all messages since the current message.
---
 emacs/notmuch-show.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 364004b82040..694b6de54104 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -182,6 +182,14 @@ each attachment handler is logged in buffers with names beginning
 \" *notmuch-part*\". This option requires emacs version at least
 24.3 to work.")
 
+(defcustom notmuch-show-stash-timestamp-format "%s"
+  "Format string for `notmuch-show-stash-timestamp'.
+
+This is the FORMAT-STRING passed to `format-time-string' for
+stashing the current message's timestamp."
+  :type 'string
+  :group 'notmuch-show)
+
 (defcustom notmuch-show-stash-mlarchive-link-alist
   '(("Gmane" . "http://mid.gmane.org/")
     ("MARC" . "https://marc.info/?i=")
@@ -1403,6 +1411,7 @@ reset based on the original query."
   (let ((map (make-sparse-keymap)))
     (define-key map "c" 'notmuch-show-stash-cc)
     (define-key map "d" 'notmuch-show-stash-date)
+    (define-key map "D" 'notmuch-show-stash-timestamp)
     (define-key map "F" 'notmuch-show-stash-filename)
     (define-key map "f" 'notmuch-show-stash-from)
     (define-key map "i" 'notmuch-show-stash-message-id)
@@ -1666,6 +1675,9 @@ current thread."
 (defun notmuch-show-get-date ()
   (notmuch-show-get-header :Date))
 
+(defun notmuch-show-get-timestamp ()
+  (notmuch-show-get-prop :timestamp))
+
 (defun notmuch-show-get-from ()
   (notmuch-show-get-header :From))
 
@@ -2236,6 +2248,13 @@ thread from search."
   (interactive)
   (notmuch-common-do-stash (notmuch-show-get-date)))
 
+(defun notmuch-show-stash-timestamp ()
+  "Copy timestamp of current message to kill-ring, formatted according to `notmuch-show-stash-timestamp-format'."
+  (interactive)
+  (notmuch-common-do-stash
+   (format-time-string notmuch-show-stash-timestamp-format
+       (seconds-to-time (notmuch-show-get-timestamp)))))
+
 (defun notmuch-show-stash-filename ()
   "Copy filename of current message to kill-ring."
   (interactive)
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: add support for stashing formatted timestamp

Jani Nikula <[hidden email]> writes:

> notmuch-show-stash-date stashes the Date: header of the message
> verbatim. While that is useful, sometimes more control of the output
> is desirable.
>
> Add support for stashing the message timestamp (as parsed by gmime at
> the lib level from the Date: header) according to a user customizable
> format. The user can use this to stash the message date in the
> preferred format, or perhaps as a date: range query, for example
> "date:@%s.." to find all messages since the current message.
> ---

I'm not opposed to this, but I'd like at least one vote from someone
other than Jani that would find it useful.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] emacs: add support for stashing formatted timestamp

On Thu, Mar 09 2017, David Bremner <[hidden email]> wrote:

> Jani Nikula <[hidden email]> writes:
>
>> notmuch-show-stash-date stashes the Date: header of the message
>> verbatim. While that is useful, sometimes more control of the output
>> is desirable.
>>
>> Add support for stashing the message timestamp (as parsed by gmime at
>> the lib level from the Date: header) according to a user customizable
>> format. The user can use this to stash the message date in the
>> preferred format, or perhaps as a date: range query, for example
>> "date:@%s.." to find all messages since the current message.
>> ---
>
> I'm not opposed to this, but I'd like at least one vote from someone
> other than Jani that would find it useful.

I've had plenty of thoughts for alternatives, but haven't got time
to write those out.

shortly: 1) initially no customization -> see 2
         2) if customization, have list instead of one item
            -- would be incompatible change if this patch were applied
         3) make the customization to current date stashing, by default
            being with one item so it could work like it is working now...
            ... that would save 'D' for docid (if we ever agree this
            should be implemented (+2 (usability, convenience) from me.

>
> d

Tomi
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch