Pārlūkot izejas kodu

LaTeX export: Format time stamps

Time stamps in LaTeX export now also honor custom time stamp formats.
Furthermore, the new option `org-export-latex-timestamp-markup' can
specify special markup for time stamps.
Carsten Dominik 16 gadi atpakaļ
vecāks
revīzija
a26f9b5502
3 mainītis faili ar 30 papildinājumiem un 1 dzēšanām
  1. 7 0
      lisp/ChangeLog
  2. 21 0
      lisp/org-latex.el
  3. 2 1
      lisp/org.el

+ 7 - 0
lisp/ChangeLog

@@ -1,5 +1,12 @@
 2009-04-13  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-latex-display-custom-times): New variable.
+	(org-export-latex-timestamp-markup): New option.
+	(org-export-latex-set-initial-vars): Remember the local value of
+	`org-display-custom-times'.
+	(org-export-latex-content): Process time stamps.
+	(org-export-latex-time-stamps): New function.
+
 	* org-macs.el (org-maybe-intangible): Add intangible property
 	again to invisible text.
 

+ 21 - 0
lisp/org-latex.el

@@ -56,6 +56,7 @@
 (defvar org-export-latex-append-header nil)
 (defvar org-export-latex-options-plist nil)
 (defvar org-export-latex-todo-keywords-1 nil)
+(defvar org-export-latex-display-custom-times nil)
 (defvar org-export-latex-all-targets-re nil)
 (defvar org-export-latex-add-level 0)
 (defvar org-export-latex-sectioning "")
@@ -196,6 +197,11 @@ For example \orgTITLE for #+TITLE."
   :group 'org-export-latex
   :type 'string)
 
+(defcustom org-export-latex-timestamp-markup "\\textit{%s}"
+  "A printf format string to be applied to time stamps."
+  :group 'org-export-latex
+  :type 'string)
+
 (defcustom org-export-latex-tables-verbatim nil
   "When non-nil, tables are exported verbatim."
   :group 'org-export-latex
@@ -712,6 +718,7 @@ If NUM, export sections as numerical sections."
 EXT-PLIST is an optional additional plist.
 LEVEL indicates the default depth for export."
   (setq org-export-latex-todo-keywords-1 org-todo-keywords-1
+	org-export-latex-display-custom-times org-display-custom-times
 	org-export-latex-all-targets-re
 	(org-make-target-link-regexp (org-all-targets))
 	org-export-latex-options-plist
@@ -840,6 +847,8 @@ conversion types are: quotation-marks, emphasis, sub-superscript,
 links, keywords, lists, tables, fixed-width"
   (with-temp-buffer
    (insert content)
+   (unless (memq 'timestamps exclude-list)
+     (org-export-latex-time-stamps))
    (unless (memq 'quotation-marks exclude-list)
      (org-export-latex-quotation-marks))
    (unless (memq 'emphasis exclude-list)
@@ -921,6 +930,18 @@ links, keywords, lists, tables, fixed-width"
     (org-export-latex-links)
     (org-trim (buffer-string))))
 
+(defun org-export-latex-time-stamps ()
+  "Format time stamps."
+  (goto-char (point-min))
+  (let ((org-display-custom-times org-export-latex-display-custom-times))
+    (while (re-search-forward org-ts-regexp-both nil t)
+      (org-if-unprotected-at (1- (point))
+       (replace-match
+	(org-export-latex-protect-string
+	 (format org-export-latex-timestamp-markup
+		 (substring (org-translate-time (match-string 0)) 1 -1)))
+	t t)))))
+
 (defun org-export-latex-quotation-marks ()
   "Export quotation marks depending on language conventions."
   (let* ((lang (plist-get org-export-latex-options-plist :language))

+ 2 - 1
lisp/org.el

@@ -2022,7 +2022,8 @@ To turn this on on a per-file basis, insert anywhere in the file:
   "Custom formats for time stamps.  See `format-time-string' for the syntax.
 These are overlayed over the default ISO format if the variable
 `org-display-custom-times' is set.  Time like %H:%M should be at the
-end of the second format."
+end of the second format.  The custom formats are also honored by export
+commands, if custom time display is turned on at the time of export."
   :group 'org-time
   :type 'sexp)