Re: [O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Aaron Ecaywrites: > Checking the source, date-to-time can raise an error (invalid date). > format-time-string is a C function, so it’s less easy for me to > understand. But it looks like if it raises any errors, these are bugs > that we want to know about and not suppress. > > The ignore-error call was introduced to org-gnus in commit 0dfde2da. > Based on the commit message, it looks like the problem being solved was > invalid dates getting passed to date-to-time. > > So I think the ignore-error can just wrap the date-to-time call. Thanks. Ok.
Re: [O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Hi Jan, 2015ko azaroak 4an, Jan Malakhovski-ek idatzi zuen: [...] >> Also, what is ignore-errors protecting? The call to date-to-time, or >> format-time-string? I think the scope of ignore-errors should be as >> narrow as it can be. > > I have no idea. I moved these lines from org-gnus, equivalent lines in > org-*other-mail-reader*s don't use ignore-errors at all. I don't use > gnus so went for the safest change. Checking the source, date-to-time can raise an error (invalid date). format-time-string is a C function, so it’s less easy for me to understand. But it looks like if it raises any errors, these are bugs that we want to know about and not suppress. The ignore-error call was introduced to org-gnus in commit 0dfde2da. Based on the commit message, it looks like the problem being solved was invalid dates getting passed to date-to-time. So I think the ignore-error can just wrap the date-to-time call. -- Aaron Ecay
Re: [O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Aaron Ecaywrites: > Can you introduce a let binding so that (date-to-time x) is only called > once? Ok. > Also, what is ignore-errors protecting? The call to date-to-time, or > format-time-string? I think the scope of ignore-errors should be as > narrow as it can be. I have no idea. I moved these lines from org-gnus, equivalent lines in org-*other-mail-reader*s don't use ignore-errors at all. I don't use gnus so went for the safest change.
Re: [O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Hi Jan, 2015ko azaroak 3an, Jan Malakhovski-ek idatzi zuen: [...] > 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 ( 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))) Can you introduce a let binding so that (date-to-time x) is only called once? Also, what is ignore-errors protecting? The call to date-to-time, or format-time-string? I think the scope of ignore-errors should be as narrow as it can be. -- Aaron Ecay
[O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
* 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