unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp
Date: Sat,  8 Apr 2017 21:33:43 +0300	[thread overview]
Message-ID: <20170408183343.396-1-tomi.ollila@iki.fi> (raw)

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

This is my suggested alternative to id:20170110181525.18269-1-jani@nikula.org
since my comments in id:m2fuimv4mj.fsf@guru.guru-group.fi

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

             reply	other threads:[~2017-04-08 18:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08 18:33 Tomi Ollila [this message]
2017-05-11 23:13 ` [PATCH] emacs: with prefix argument, notmuch-show-stash-date stashes timestamp David Bremner
2017-05-12 18:45   ` Jani Nikula
2017-05-30 12:00 ` David Bremner

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to=20170408183343.396-1-tomi.ollila@iki.fi \
    --to=tomi.ollila@iki.fi \
    --cc=notmuch@notmuchmail.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://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).