emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link
  2015-10-25 13:36 [PATCH] remove some copy-paste and " Jan Malakhovski
@ 2015-10-25 13:36 ` Jan Malakhovski
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Malakhovski @ 2015-10-25 13:36 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Jan Malakhovski

---
 contrib/lisp/org-notmuch.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/lisp/org-notmuch.el b/contrib/lisp/org-notmuch.el
index 712ec5a..265742e 100644
--- a/contrib/lisp/org-notmuch.el
+++ b/contrib/lisp/org-notmuch.el
@@ -71,15 +71,16 @@ Should accept a notmuch search string as the sole argument."
 (defun org-notmuch-store-link ()
   "Store a link to a notmuch search or message."
   (when (eq major-mode 'notmuch-show-mode)
-    (let* ((message-id (notmuch-show-get-prop :id))
+    (let* ((message-id (notmuch-show-get-message-id t))
 	   (subject (notmuch-show-get-subject))
 	   (to (notmuch-show-get-to))
 	   (from (notmuch-show-get-from))
+	   (date (org-trim (notmuch-show-get-date)))
 	   desc link)
-      (org-store-link-props :type "notmuch" :from from :to to
+      (org-store-link-props :type "notmuch" :from from :to to :date date
        			    :subject subject :message-id message-id)
       (setq desc (org-email-link-description))
-      (setq link (concat "notmuch:"  "id:" message-id))
+      (setq link (concat "notmuch:id:" message-id))
       (org-add-link-props :link link :description desc)
       link)))
 
-- 
2.5.3

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

* [PATCH v3 part2 0/2] date-timestamp* calculations
@ 2015-12-27 14:54 Jan Malakhovski
  2015-12-27 14:54 ` [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props Jan Malakhovski
  2015-12-27 14:54 ` [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link Jan Malakhovski
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Malakhovski @ 2015-12-27 14:54 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Jan Malakhovski

This is a date-timestamp* piece of "[PATCH v2 0/9] mail, clock and
calc changes" updated with Aaron Ecay's suggestions.

Jan Malakhovski (2):
  factor out date-timestamp* calculations to org-store-link-props
  org-notmuch: add date support to org-notmuch-store-link

 contrib/lisp/org-mew.el     | 11 +----------
 contrib/lisp/org-notmuch.el |  7 ++++---
 contrib/lisp/org-vm.el      | 11 +----------
 contrib/lisp/org-wl.el      | 10 +---------
 doc/org.texi                |  4 ++--
 lisp/org-gnus.el            | 15 +--------------
 lisp/org-mhe.el             | 10 +---------
 lisp/org-rmail.el           | 11 +----------
 lisp/org.el                 | 12 ++++++++++--
 9 files changed, 22 insertions(+), 69 deletions(-)

-- 
2.6.4

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

* [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props
  2015-12-27 14:54 [PATCH v3 part2 0/2] date-timestamp* calculations Jan Malakhovski
@ 2015-12-27 14:54 ` Jan Malakhovski
  2015-12-29 20:24   ` Nicolas Goaziou
  2015-12-27 14:54 ` [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link Jan Malakhovski
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Malakhovski @ 2015-12-27 14:54 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Jan Malakhovski

* lisp/org.el (org-store-link-props): Rewrite function to get date-timestamp*
  calculations.
* lisp/org-gnus.el:
* lisp/org-mhe.el:
* lisp/org-rmail.el:
* contrib/lisp/org-mew.el:
* contrib/lisp/org-vm.el:
* contrib/lisp/org-wl.el: Remove date-timestamp* copy-paste.
* doc/org.texi: Fix `org-capture-templates' documentation.
---
 contrib/lisp/org-mew.el | 11 +----------
 contrib/lisp/org-vm.el  | 11 +----------
 contrib/lisp/org-wl.el  | 10 +---------
 doc/org.texi            |  4 ++--
 lisp/org-gnus.el        | 15 +--------------
 lisp/org-mhe.el         | 10 +---------
 lisp/org-rmail.el       | 11 +----------
 lisp/org.el             | 12 ++++++++++--
 8 files changed, 18 insertions(+), 66 deletions(-)

diff --git a/contrib/lisp/org-mew.el b/contrib/lisp/org-mew.el
index eb0afc0..35fdd8b 100644
--- a/contrib/lisp/org-mew.el
+++ b/contrib/lisp/org-mew.el
@@ -167,19 +167,10 @@ with \"t\" key."
 	       (from (mew-header-get-value "From:"))
 	       (to (mew-header-get-value "To:"))
 	       (date (mew-header-get-value "Date:"))
-	       (date-ts (and date (format-time-string
-				   (org-time-stamp-format t)
-				   (date-to-time date))))
-	       (date-ts-ia (and date (format-time-string
-				      (org-time-stamp-format t t)
-				      (date-to-time date))))
 	       (subject (mew-header-get-value "Subject:"))
 	       desc link)
-	  (org-store-link-props :type "mew" :from from :to to
+	  (org-store-link-props :type "mew" :from from :to to :date date
 				:subject subject :message-id message-id)
-	  (when date
-	    (org-add-link-props :date date :date-timestamp date-ts
-				:date-timestamp-inactive date-ts-ia))
 	  (setq message-id (org-remove-angle-brackets message-id))
 	  (setq desc (org-email-link-description))
 	  (setq link (concat "mew:" folder-name "#" message-id))
diff --git a/contrib/lisp/org-vm.el b/contrib/lisp/org-vm.el
index 5d30f64..da242cb 100644
--- a/contrib/lisp/org-vm.el
+++ b/contrib/lisp/org-vm.el
@@ -77,12 +77,6 @@
              (message-id (vm-su-message-id message))
              (link-type (if (vm-imap-folder-p) "vm-imap" "vm"))
 	     (date (vm-get-header-contents message "Date"))
-	     (date-ts (and date (format-time-string
-				 (org-time-stamp-format t)
-				 (date-to-time date))))
-	     (date-ts-ia (and date (format-time-string
-				    (org-time-stamp-format t t)
-				    (date-to-time date))))
 	     folder desc link)
         (if (vm-imap-folder-p)
 	    (let ((spec (vm-imap-find-spec-for-buffer (current-buffer))))
@@ -95,10 +89,7 @@
                 (setq folder (replace-match "" t t folder)))))
         (setq message-id (org-remove-angle-brackets message-id))
 	(org-store-link-props :type link-type :from from :to to :subject subject
-			      :message-id message-id)
-	(when date
-	  (org-add-link-props :date date :date-timestamp date-ts
-			      :date-timestamp-inactive date-ts-ia))
+			      :message-id message-id :date date)
 	(setq desc (org-email-link-description))
 	(setq link (concat (concat link-type ":") folder "#" message-id))
 	(org-add-link-props :link link :description desc)
diff --git a/contrib/lisp/org-wl.el b/contrib/lisp/org-wl.el
index 632c9e3..2cc333c 100644
--- a/contrib/lisp/org-wl.el
+++ b/contrib/lisp/org-wl.el
@@ -198,12 +198,6 @@ ENTITY is a message entity."
 		 (xref (org-wl-message-field 'xref wl-message-entity))
 		 (subject (org-wl-message-field 'subject wl-message-entity))
 		 (date (org-wl-message-field 'date wl-message-entity))
-		 (date-ts (and date (format-time-string
-				     (org-time-stamp-format t)
-				     (date-to-time date))))
-		 (date-ts-ia (and date (format-time-string
-					(org-time-stamp-format t t)
-					(date-to-time date))))
 		 desc link)
 
 	    ;; remove text properties of subject string to avoid possible bug
@@ -243,9 +237,7 @@ ENTITY is a message entity."
 	      (setq desc (org-email-link-description))
 	      (setq link (concat "wl:" folder-name "#" message-id-no-brackets))
 	      (org-add-link-props :link link :description desc)))
-	    (when date
-	      (org-add-link-props :date date :date-timestamp date-ts
-				  :date-timestamp-inactive date-ts-ia))
+	    (org-add-link-props :date date)
 	    (or link xref)))))))
 
 (defun org-wl-open-nntp (path)
diff --git a/doc/org.texi b/doc/org.texi
index 8f3e248..c3c5b4d 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7303,8 +7303,8 @@ Link type                        |  Available keywords
 ---------------------------------+----------------------------------------------
 bbdb                             |  %:name %:company
 irc                              |  %:server %:port %:nick
-vm, vm-imap, wl, mh, mew, rmail  |  %:type %:subject %:message-id
-                                 |  %:from %:fromname %:fromaddress
+vm, vm-imap, wl, mh, mew, rmail, |  %:type %:subject %:message-id
+gnus                             |  %:from %:fromname %:fromaddress
                                  |  %:to   %:toname   %:toaddress
                                  |  %:date @r{(message date header field)}
                                  |  %:date-timestamp @r{(date as active timestamp)}
diff --git a/lisp/org-gnus.el b/lisp/org-gnus.el
index 9ad3dd8..514ea5c 100644
--- a/lisp/org-gnus.el
+++ b/lisp/org-gnus.el
@@ -159,16 +159,6 @@ If `org-store-link' was called with a prefix arg the meaning of
 	   (from (mail-header-from header))
 	   (message-id (org-remove-angle-brackets (mail-header-id header)))
 	   (date (org-trim (mail-header-date header)))
-	   (date-ts (and date
-			 (ignore-errors
-			   (format-time-string
-			    (org-time-stamp-format t)
-			    (date-to-time date)))))
-	   (date-ts-ia (and date
-			    (ignore-errors
-			      (format-time-string
-			       (org-time-stamp-format t t)
-			       (date-to-time date)))))
 	   (subject (copy-sequence (mail-header-subject header)))
 	   (to (cdr (assq 'To (mail-header-extra header))))
 	   newsgroups x-no-archive desc link)
@@ -190,11 +180,8 @@ If `org-store-link' was called with a prefix arg the meaning of
 	(setq to (or to (gnus-fetch-original-field "To"))
 	      newsgroups (gnus-fetch-original-field "Newsgroups")
 	      x-no-archive (gnus-fetch-original-field "x-no-archive")))
-      (org-store-link-props :type "gnus" :from from :subject subject
+      (org-store-link-props :type "gnus" :from from :date date :subject subject
 			    :message-id message-id :group group :to to)
-      (when date
-	(org-add-link-props :date date :date-timestamp date-ts
-			    :date-timestamp-inactive date-ts-ia))
       (setq desc (org-email-link-description)
 	    link (org-gnus-article-link
 		  group	newsgroups message-id x-no-archive))
diff --git a/lisp/org-mhe.el b/lisp/org-mhe.el
index e184440..3fcbc46 100644
--- a/lisp/org-mhe.el
+++ b/lisp/org-mhe.el
@@ -88,17 +88,9 @@ supported by MH-E."
 	     (message-id (org-mhe-get-header "Message-Id:"))
 	     (subject (org-mhe-get-header "Subject:"))
 	     (date (org-mhe-get-header "Date:"))
-	     (date-ts (and date (format-time-string
-				 (org-time-stamp-format t) (date-to-time date))))
-	     (date-ts-ia (and date (format-time-string
-				    (org-time-stamp-format t t)
-				    (date-to-time date))))
 	     link desc)
-	(org-store-link-props :type "mh" :from from :to to
+	(org-store-link-props :type "mh" :from from :to to :date date
 			      :subject subject :message-id message-id)
-	(when date
-	  (org-add-link-props :date date :date-timestamp date-ts
-			      :date-timestamp-inactive date-ts-ia))
 	(setq desc (org-email-link-description))
 	(setq link (concat "mhe:" (org-mhe-get-message-real-folder) "#"
 			   (org-remove-angle-brackets message-id)))
diff --git a/lisp/org-rmail.el b/lisp/org-rmail.el
index af47e0f..4732f51 100644
--- a/lisp/org-rmail.el
+++ b/lisp/org-rmail.el
@@ -65,19 +65,10 @@
 	       (to (mail-fetch-field "to"))
 	       (subject (mail-fetch-field "subject"))
 	       (date (mail-fetch-field "date"))
-	       (date-ts (and date (format-time-string
-				   (org-time-stamp-format t)
-				   (date-to-time date))))
-	       (date-ts-ia (and date (format-time-string
-				      (org-time-stamp-format t t)
-				      (date-to-time date))))
 	       desc link)
 	  (org-store-link-props
-	   :type "rmail" :from from :to to
+	   :type "rmail" :from from :to to :date date
 	   :subject subject :message-id message-id)
-	  (when date
-	    (org-add-link-props :date date :date-timestamp date-ts
-				:date-timestamp-inactive date-ts-ia))
 	  (setq message-id (org-remove-angle-brackets message-id))
 	  (setq desc (org-email-link-description))
 	  (setq link (concat "rmail:" folder "#" message-id))
diff --git a/lisp/org.el b/lisp/org.el
index dd5d7ac..74d1c4c 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9922,7 +9922,7 @@ active region."
 	 (car org-stored-links))))))
 
 (defun org-store-link-props (&rest plist)
-  "Store link properties, extract names and addresses."
+  "Store link properties, extract names, addresses and dates."
   (let (x adr)
     (when (setq x (plist-get plist :from))
       (setq adr (mail-extract-address-components x))
@@ -9931,7 +9931,15 @@ active region."
     (when (setq x (plist-get plist :to))
       (setq adr (mail-extract-address-components x))
       (setq plist (plist-put plist :toname (car adr)))
-      (setq plist (plist-put plist :toaddress (nth 1 adr)))))
+      (setq plist (plist-put plist :toaddress (nth 1 adr))))
+    (when (setq x (plist-get plist :date))
+      (when (setq x (ignore-errors (date-to-time x)))
+	(setq plist (plist-put plist :date-timestamp
+			(format-time-string
+			  (org-time-stamp-format t) x)))
+	(setq plist (plist-put plist :date-timestamp-inactive
+			(format-time-string
+			  (org-time-stamp-format t t) x))))))
   (let ((from (plist-get plist :from))
 	(to (plist-get plist :to)))
     (when (and from to org-from-is-user-regexp)
-- 
2.6.4

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

* [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link
  2015-12-27 14:54 [PATCH v3 part2 0/2] date-timestamp* calculations Jan Malakhovski
  2015-12-27 14:54 ` [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props Jan Malakhovski
@ 2015-12-27 14:54 ` Jan Malakhovski
  2015-12-29 20:24   ` Nicolas Goaziou
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Malakhovski @ 2015-12-27 14:54 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Jan Malakhovski

* contrib/lisp/org-notmuch.el (org-notmuch-store-link): Add date support.
* doc/org.texi: Fix `org-capture-templates' documentation.
---
 contrib/lisp/org-notmuch.el | 7 ++++---
 doc/org.texi                | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/contrib/lisp/org-notmuch.el b/contrib/lisp/org-notmuch.el
index 712ec5a..265742e 100644
--- a/contrib/lisp/org-notmuch.el
+++ b/contrib/lisp/org-notmuch.el
@@ -71,15 +71,16 @@ Should accept a notmuch search string as the sole argument."
 (defun org-notmuch-store-link ()
   "Store a link to a notmuch search or message."
   (when (eq major-mode 'notmuch-show-mode)
-    (let* ((message-id (notmuch-show-get-prop :id))
+    (let* ((message-id (notmuch-show-get-message-id t))
 	   (subject (notmuch-show-get-subject))
 	   (to (notmuch-show-get-to))
 	   (from (notmuch-show-get-from))
+	   (date (org-trim (notmuch-show-get-date)))
 	   desc link)
-      (org-store-link-props :type "notmuch" :from from :to to
+      (org-store-link-props :type "notmuch" :from from :to to :date date
        			    :subject subject :message-id message-id)
       (setq desc (org-email-link-description))
-      (setq link (concat "notmuch:"  "id:" message-id))
+      (setq link (concat "notmuch:id:" message-id))
       (org-add-link-props :link link :description desc)
       link)))
 
diff --git a/doc/org.texi b/doc/org.texi
index c3c5b4d..92ec29a 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7304,7 +7304,7 @@ Link type                        |  Available keywords
 bbdb                             |  %:name %:company
 irc                              |  %:server %:port %:nick
 vm, vm-imap, wl, mh, mew, rmail, |  %:type %:subject %:message-id
-gnus                             |  %:from %:fromname %:fromaddress
+gnus, notmuch                    |  %:from %:fromname %:fromaddress
                                  |  %:to   %:toname   %:toaddress
                                  |  %:date @r{(message date header field)}
                                  |  %:date-timestamp @r{(date as active timestamp)}
-- 
2.6.4

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

* Re: [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link
  2015-12-27 14:54 ` [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link Jan Malakhovski
@ 2015-12-29 20:24   ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-12-29 20:24 UTC (permalink / raw)
  To: Jan Malakhovski; +Cc: emacs-orgmode

Hello,

Jan Malakhovski <oxij@oxij.org> writes:

> * contrib/lisp/org-notmuch.el (org-notmuch-store-link): Add date support.
> * doc/org.texi: Fix `org-capture-templates' documentation.

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props
  2015-12-27 14:54 ` [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props Jan Malakhovski
@ 2015-12-29 20:24   ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-12-29 20:24 UTC (permalink / raw)
  To: Jan Malakhovski; +Cc: emacs-orgmode

Hello,

Jan Malakhovski <oxij@oxij.org> writes:

> * lisp/org.el (org-store-link-props): Rewrite function to get date-timestamp*
>   calculations.
> * lisp/org-gnus.el:
> * lisp/org-mhe.el:
> * lisp/org-rmail.el:
> * contrib/lisp/org-mew.el:
> * contrib/lisp/org-vm.el:
> * contrib/lisp/org-wl.el: Remove date-timestamp* copy-paste.
> * doc/org.texi: Fix `org-capture-templates' documentation.

Applied, with one minor refactoring. Thank you.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2015-12-29 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-27 14:54 [PATCH v3 part2 0/2] date-timestamp* calculations Jan Malakhovski
2015-12-27 14:54 ` [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props Jan Malakhovski
2015-12-29 20:24   ` Nicolas Goaziou
2015-12-27 14:54 ` [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link Jan Malakhovski
2015-12-29 20:24   ` Nicolas Goaziou
  -- strict thread matches above, loose matches on Subject: below --
2015-10-25 13:36 [PATCH] remove some copy-paste and " Jan Malakhovski
2015-10-25 13:36 ` [PATCH 2/2] org-notmuch: " Jan Malakhovski

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