emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jan Malakhovski <oxij@oxij.org>
To: emacs-orgmode@gnu.org
Cc: Jan Malakhovski <oxij@oxij.org>
Subject: [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Date: Tue,  3 Nov 2015 20:15:44 +0000	[thread overview]
Message-ID: <1446581747-1960-7-git-send-email-oxij@oxij.org> (raw)
In-Reply-To: <1446581747-1960-1-git-send-email-oxij@oxij.org>

* 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             | 15 +++++++++++++--
 8 files changed, 21 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 ba402bf..2bf2b24 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7314,8 +7314,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 c7b46af..c1eb6c6 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)
@@ -188,11 +178,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 c466870..cf0ef1f 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9960,7 +9960,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))
@@ -9969,7 +9969,18 @@ 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))
+      (setq plist (plist-put plist :date-timestamp
+			(ignore-errors
+			  (format-time-string
+			    (org-time-stamp-format t)
+			    (date-to-time x)))))
+      (setq plist (plist-put plist :date-timestamp-inactive
+			(ignore-errors
+			  (format-time-string
+			    (org-time-stamp-format t t)
+			    (date-to-time x)))))))
   (let ((from (plist-get plist :from))
 	(to (plist-get plist :to)))
     (when (and from to org-from-is-user-regexp)
-- 
2.6.2

  parent reply	other threads:[~2015-11-03 20:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 20:15 [PATCH v2 0/9] mail, clock and calc changes Jan Malakhovski
2015-11-03 20:15 ` [PATCH 1/9] org-clock: fix a typo Jan Malakhovski
2015-11-03 20:15 ` [PATCH 2/9] org-colview: add a FIXME Jan Malakhovski
2015-11-03 20:15 ` [PATCH 3/9] org-clock: fix `org-clock-time%' Jan Malakhovski
2015-11-04 11:18   ` Aaron Ecay
2015-11-04 11:46     ` Jan Malakhovski
2015-11-03 20:15 ` [PATCH 4/9] org: move `org-duration-string-to-minutes' to a better place Jan Malakhovski
2015-11-03 20:15 ` [PATCH 5/9] rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere Jan Malakhovski
2015-11-04 11:21   ` Aaron Ecay
2015-11-04 11:47     ` Jan Malakhovski
2015-11-03 20:15 ` Jan Malakhovski [this message]
2015-11-04 11:26   ` [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props Aaron Ecay
2015-11-04 11:45     ` Jan Malakhovski
2015-11-04 14:39       ` Aaron Ecay
2015-11-04 15:21         ` Jan Malakhovski
2015-11-03 20:15 ` [PATCH 7/9] org-notmuch: add date support to org-notmuch-store-link Jan Malakhovski
2015-11-03 20:15 ` [PATCH 8/9] ob-calc: add more API, documentation and examples so that it can be used in tables Jan Malakhovski
2015-11-03 20:15 ` [PATCH 9/9] ob-calc: don't leave garbage on the stack Jan Malakhovski
2015-11-04 11:31   ` Aaron Ecay
2015-11-04 11:53     ` Jan Malakhovski
2015-11-04 14:41       ` Aaron Ecay
2015-11-04 15:24         ` Jan Malakhovski
2015-11-04 11:36 ` [PATCH v2 0/9] mail, clock and calc changes Aaron Ecay
2015-11-04 11:59   ` Jan Malakhovski

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

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

  git send-email \
    --in-reply-to=1446581747-1960-7-git-send-email-oxij@oxij.org \
    --to=oxij@oxij.org \
    --cc=emacs-orgmode@gnu.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://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).