unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: add support for stashing formatted timestamp
@ 2017-01-10 18:15 Jani Nikula
  2017-03-09 13:34 ` David Bremner
  0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2017-01-10 18:15 UTC (permalink / raw)
  To: notmuch

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

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

* Re: [PATCH] emacs: add support for stashing formatted timestamp
  2017-01-10 18:15 [PATCH] emacs: add support for stashing formatted timestamp Jani Nikula
@ 2017-03-09 13:34 ` David Bremner
  2017-03-09 15:42   ` Tomi Ollila
  0 siblings, 1 reply; 3+ messages in thread
From: David Bremner @ 2017-03-09 13:34 UTC (permalink / raw)
  To: Jani Nikula, notmuch

Jani Nikula <jani@nikula.org> 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

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

* Re: [PATCH] emacs: add support for stashing formatted timestamp
  2017-03-09 13:34 ` David Bremner
@ 2017-03-09 15:42   ` Tomi Ollila
  0 siblings, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2017-03-09 15:42 UTC (permalink / raw)
  To: notmuch

On Thu, Mar 09 2017, David Bremner <david@tethera.net> wrote:

> Jani Nikula <jani@nikula.org> 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

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

end of thread, other threads:[~2017-03-09 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-10 18:15 [PATCH] emacs: add support for stashing formatted timestamp Jani Nikula
2017-03-09 13:34 ` David Bremner
2017-03-09 15:42   ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).