Fix custom timestamps during export

* lisp/org.el (org-translate-time): Remove function.
(org-timestamp-translate): Rewrite function so it doesn't use the one
above.

* lisp/ox-ascii.el (org-ascii-clock, org-ascii-planning):
* lisp/ox-html.el (org-html-clock, org-html-planning, org-html-timestamp):
* lisp/ox-latex.el (org-latex-clock, org-latex-planning):
* lisp/ox-texinfo.el (org-texinfo-clock, org-texinfo-planning): Use
  `org-timestamp-translate' instead of `org-translate-time'.

* etc/ORG-NEWS: Document function removal.

Reported-by: Ian Barton <lists@wilkesley.net>
<http://permalink.gmane.org/gmane.emacs.orgmode/93127>
This commit is contained in:
Nicolas Goaziou 2014-12-03 17:09:43 +01:00
parent e4727803be
commit e1adb17ba5
6 changed files with 38 additions and 83 deletions

View File

@ -65,6 +65,8 @@ docstring for more information.
- ~org-latex-format-headline-function~
- ~org-latex-format-inlinetask-function~
** Removed functions
*** Removed function ~org-translate-time~
Use ~org-timestamp-translate~ instead.
*** Removed function ~org-beamer-insert-options-template~
This function inserted a Beamer specific template at point or in
current subtree. Use ~org-export-insert-default-template~ instead, as

View File

@ -17181,33 +17181,6 @@ The command returns the inserted time stamp."
(put-text-property beg end 'end-glyph (make-glyph str)))
(put-text-property beg end 'display str))))
(defun org-translate-time (string)
"Translate all timestamps in STRING to custom format.
But do this only if the variable `org-display-custom-times' is set."
(when org-display-custom-times
(save-match-data
(let* ((start 0)
(re org-ts-regexp-both)
t1 with-hm inactive tf time str beg end)
(while (setq start (string-match re string start))
(setq beg (match-beginning 0)
end (match-end 0)
t1 (save-match-data
(org-parse-time-string (substring string beg end) t))
with-hm (and (nth 1 t1) (nth 2 t1))
inactive (equal (substring string beg (1+ beg)) "[")
tf (funcall (if with-hm 'cdr 'car)
org-time-stamp-custom-formats)
time (org-fix-decoded-time t1)
str (format-time-string
(concat
(if inactive "[" "<") (substring tf 1 -1)
(if inactive "]" ">"))
(apply 'encode-time time))
string (replace-match str t t string)
start (+ start (length str)))))))
string)
(defun org-fix-decoded-time (time)
"Set 0 instead of nil for the first 6 elements of time.
Don't touch the rest."
@ -23471,27 +23444,28 @@ TIMESTAMP."
split-ts :raw-value (org-element-interpret-data split-ts)))))))
(defun org-timestamp-translate (timestamp &optional boundary)
"Apply `org-translate-time' on a TIMESTAMP object.
"Translate TIMESTAMP object to custom format.
Format string is defined in `org-time-stamp-custom-formats',
which see.
When optional argument BOUNDARY is non-nil, it is either the
symbol `start' or `end'. In this case, only translate the
starting or ending part of TIMESTAMP if it is a date or time
range. Otherwise, translate both parts."
(if (and (not boundary)
(memq (org-element-property :type timestamp)
'(active-range inactive-range)))
(concat
(org-translate-time
(org-element-property :raw-value
(org-timestamp-split-range timestamp)))
"--"
(org-translate-time
(org-element-property :raw-value
(org-timestamp-split-range timestamp t))))
(org-translate-time
(org-element-property
:raw-value
(if (not boundary) timestamp
(org-timestamp-split-range timestamp (eq boundary 'end)))))))
range. Otherwise, translate both parts.
Return timestamp as-is if `org-display-custom-times' is nil or if
it has a `diary' type."
(let ((type (org-element-property :type timestamp)))
(if (or (not org-display-custom-times) (eq type 'diary))
(org-element-interpret-data timestamp)
(let ((fmt (funcall (if (org-timestamp-has-time-p timestamp) #'cdr #'car)
org-time-stamp-custom-formats)))
(if (and (not boundary) (memq type '(active-range inactive-range)))
(concat (org-timestamp-format timestamp fmt)
"--"
(org-timestamp-format timestamp fmt t))
(org-timestamp-format timestamp fmt (eq boundary 'end)))))))

View File

@ -1143,9 +1143,7 @@ CONTENTS is nil. INFO is a plist holding contextual
information."
(org-ascii--justify-element
(concat org-clock-string " "
(org-translate-time
(org-element-property :raw-value
(org-element-property :value clock)))
(org-timestamp-translate (org-element-property :value clock))
(let ((time (org-element-property :duration clock)))
(and time
(concat " => "
@ -1620,18 +1618,15 @@ channel."
(list (let ((closed (org-element-property :closed planning)))
(when closed
(concat org-closed-string " "
(org-translate-time
(org-element-property :raw-value closed)))))
(org-timestamp-translate closed))))
(let ((deadline (org-element-property :deadline planning)))
(when deadline
(concat org-deadline-string " "
(org-translate-time
(org-element-property :raw-value deadline)))))
(org-timestamp-translate deadline))))
(let ((scheduled (org-element-property :scheduled planning)))
(when scheduled
(concat org-scheduled-string " "
(org-translate-time
(org-element-property :raw-value scheduled)))))))
(org-timestamp-translate scheduled))))))
" ")
planning info))

View File

@ -2210,9 +2210,7 @@ channel."
</span>
</p>"
org-clock-string
(org-translate-time
(org-element-property :raw-value
(org-element-property :value clock)))
(org-timestamp-translate (org-element-property :value clock))
(let ((time (org-element-property :duration clock)))
(and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
@ -3017,18 +3015,15 @@ channel."
(let ((closed (org-element-property :closed planning)))
(when closed
(format span-fmt org-closed-string
(org-translate-time
(org-element-property :raw-value closed)))))
(org-timestamp-translate closed))))
(let ((deadline (org-element-property :deadline planning)))
(when deadline
(format span-fmt org-deadline-string
(org-translate-time
(org-element-property :raw-value deadline)))))
(org-timestamp-translate deadline))))
(let ((scheduled (org-element-property :scheduled planning)))
(when scheduled
(format span-fmt org-scheduled-string
(org-translate-time
(org-element-property :raw-value scheduled)))))))
(org-timestamp-translate scheduled))))))
" "))))
;;;; Property Drawer
@ -3349,8 +3344,7 @@ information."
"Transcode a TIMESTAMP object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(let ((value (org-html-plain-text
(org-timestamp-translate timestamp) info)))
(let ((value (org-html-plain-text (org-timestamp-translate timestamp) info)))
(format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
(replace-regexp-in-string "--" "&#x2013;" value))))

View File

@ -1318,9 +1318,7 @@ information."
"\\noindent"
(format "\\textbf{%s} " org-clock-string)
(format (plist-get info :latex-inactive-timestamp-format)
(concat (org-translate-time
(org-element-property :raw-value
(org-element-property :value clock)))
(concat (org-timestamp-translate (org-element-property :value clock))
(let ((time (org-element-property :duration clock)))
(and time (format " (%s)" time)))))
"\\\\"))
@ -2135,22 +2133,19 @@ information."
(concat
(format "\\textbf{%s} " org-closed-string)
(format (plist-get info :latex-inactive-timestamp-format)
(org-translate-time
(org-element-property :raw-value closed))))))
(org-timestamp-translate closed)))))
(let ((deadline (org-element-property :deadline planning)))
(when deadline
(concat
(format "\\textbf{%s} " org-deadline-string)
(format (plist-get info :latex-active-timestamp-format)
(org-translate-time
(org-element-property :raw-value deadline))))))
(org-timestamp-translate deadline)))))
(let ((scheduled (org-element-property :scheduled planning)))
(when scheduled
(concat
(format "\\textbf{%s} " org-scheduled-string)
(format (plist-get info :latex-active-timestamp-format)
(org-translate-time
(org-element-property :raw-value scheduled))))))))
(org-timestamp-translate scheduled)))))))
" ")
"\\\\"))

View File

@ -643,9 +643,7 @@ information."
"@noindent"
(format "@strong{%s} " org-clock-string)
(format (plist-get info :texinfo-inactive-timestamp-format)
(concat (org-translate-time
(org-element-property :raw-value
(org-element-property :value clock)))
(concat (org-timestamp-translate (org-element-property :value clock))
(let ((time (org-element-property :duration clock)))
(and time (format " (%s)" time)))))
"@*"))
@ -1168,22 +1166,19 @@ information."
(concat
(format "@strong{%s} " org-closed-string)
(format (plist-get info :texinfo-inactive-timestamp-format)
(org-translate-time
(org-element-property :raw-value closed))))))
(org-timestamp-translate closed)))))
(let ((deadline (org-element-property :deadline planning)))
(when deadline
(concat
(format "@strong{%s} " org-deadline-string)
(format (plist-get info :texinfo-active-timestamp-format)
(org-translate-time
(org-element-property :raw-value deadline))))))
(org-timestamp-translate deadline)))))
(let ((scheduled (org-element-property :scheduled planning)))
(when scheduled
(concat
(format "@strong{%s} " org-scheduled-string)
(format (plist-get info :texinfo-active-timestamp-format)
(org-translate-time
(org-element-property :raw-value scheduled))))))))
(org-timestamp-translate scheduled)))))))
" ")
"@*"))