[PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp

classic Classic list List threaded Threaded
4 messages Options
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp

Using timestamp of a message is useful in many Xapian queries.
---

This is my suggested alternative to id:[hidden email]
since my comments in id:[hidden email]

This variant uses prefix argument to `c d` to do stashing of a timestamp
and do not (at this time) define any customization variable (and set the
format of that potential variable in stone).
Time will tell whether this is enough -- I currently don't see how any
other format would be useful (unless, someone(tm) wants to have some
stupid national formats in their date strings ;/)

I did implement that list format in customization variable:

:+(defcustom notmuch-show-stash-date-additional-formats '()
:+  "List of additional date formats to use when stashing date."
:+  :type '(repeat string)
:+  :group 'notmuch-show)
:+

: (defun notmuch-show-stash-date ()
:   "Copy date of current message to kill-ring."
:   (interactive)
:-  (notmuch-common-do-stash (notmuch-show-get-date)))
:+  (notmuch-common-do-stash
:+   (if (= (length notmuch-show-stash-date-additional-formats) 0)
:+       (notmuch-show-get-date)
:+     (let ((time (seconds-to-time (notmuch-show-get-timestamp)))
:+          (history-length 0))
:+       (completing-read "Formatted date to stash: "
:+                       (mapcar (lambda (i) (format-time-string i time))
:+                               notmuch-show-stash-date-additional-formats)
:+                       nil nil (notmuch-show-get-date))))))

but for now this patch might just be enough (?)

I also have some preliminary docid changes (but it looks to me that
it would require Xapian 1.4 RangeProcessor (i.e. no *Value* there) to
do it) -- have to get a system with Xapian 1.4 for use first...


 emacs/notmuch-show.el | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c670160..e7c22da 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1674,6 +1674,9 @@ (defun notmuch-show-get-cc ()
 (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))
 
@@ -2239,10 +2242,17 @@ (defun notmuch-show-stash-cc ()
   (interactive)
   (notmuch-common-do-stash (notmuch-show-get-cc)))
 
-(defun notmuch-show-stash-date ()
-  "Copy date of current message to kill-ring."
-  (interactive)
-  (notmuch-common-do-stash (notmuch-show-get-date)))
+(put 'notmuch-show-stash-date 'notmuch-prefix-doc
+     "Copy timestamp of current message to kill-ring.")
+(defun notmuch-show-stash-date (&optional stash-timestamp)
+  "Copy date of current message to kill-ring.
+
+If invoked with a prefix argument, copy timestamp of current
+message to kill-ring."
+  (interactive "P")
+  (if stash-timestamp
+      (notmuch-common-do-stash (format "%d" (notmuch-show-get-timestamp)))
+    (notmuch-common-do-stash (notmuch-show-get-date))))
 
 (defun notmuch-show-stash-filename ()
   "Copy filename of current message to kill-ring."
--
2.9.3

_______________________________________________
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
|  
Report Content as Inappropriate

Re: [PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp

Tomi Ollila <[hidden email]> writes:

> Using timestamp of a message is useful in many Xapian queries.
> ---
>
> This is my suggested alternative to id:[hidden email]
> since my comments in id:[hidden email]

In case it's not obvious, I'm waiting for you two to come to some
consensus on this one.

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Jani Nikula Jani Nikula
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp

On Thu, 11 May 2017, David Bremner <[hidden email]> wrote:

> Tomi Ollila <[hidden email]> writes:
>
>> Using timestamp of a message is useful in many Xapian queries.
>> ---
>>
>> This is my suggested alternative to id:[hidden email]
>> since my comments in id:[hidden email]
>
> In case it's not obvious, I'm waiting for you two to come to some
> consensus on this one.

This patch seems like a worthwhile addition no matter what, and doesn't
prevent us from adding formatted stashing later if we so decide.

BR,
Jani.
_______________________________________________
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
|  
Report Content as Inappropriate

Re: [PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp

In reply to this post by Tomi Ollila-2
Tomi Ollila <[hidden email]> writes:

> Using timestamp of a message is useful in many Xapian queries.
> ---

pushed to master

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