From: Christopher Suckling <suckling.list@googlemail.com>
To: Daniel Clemente <n142857@gmail.com>
Cc: mailing-list-org-mode <emacs-orgmode@gnu.org>
Subject: Re: Format for timestamp export
Date: Sun, 12 Apr 2009 19:43:21 +0100 [thread overview]
Message-ID: <80EB2F27-E64D-4643-82E5-EFBAE76806F6@gmail.com> (raw)
In-Reply-To: <87ocv1d8hf.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
On 12 Apr 2009, at 19:37, Daniel Clemente wrote:
> El jue, abr 09 2009, Carsten Dominik va escriure:
>>>
>>> Can I format timestamps on export?
>>
>> You can customize them for display, which will also
>> transfer to exported files.
>> Check out the variables `org-display-custom-times' and
>> `org-time-stamp-custom-formats'.
>>
> Thanks; I didn't know that org-display-custom-times would affect
> also the export. Could the documentation say that?
>
BTW, this doesn't work in the latex exporter. I used the attached ugly
hack rather than fix the latex exporter - I suspect I was in a rush to
get a piece of work out to someone. Anyway, the function cas/org-
export-as-latex-to-buffer-with-timestamp behaves the same as org-
export-as-latex-to-buffer, but translates all timestamps to org-time-
stamp-custom-formats.
Best,
Christopher
[-- Attachment #2: org-latex-timestamp.el --]
[-- Type: application/octet-stream, Size: 2237 bytes --]
;; org-mode export as LaTeX with timestamp translation.
;; Author: Christopher Suckling
;; An ugly hack to preprocess timestamp translation for latex
;; export. All timestamps are converted to the format held by
;; org-time-stamp-custom-formats.
(defun cas/org-translate-time (string)
"Translate all timestamps in STRING to custom format."
(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))))));)
(prin1 string))
(defun cas/delete-export-files (list)
(while list
(delete-file (car list))
(setq list (cdr list))))
(defun cas/org-export-as-latex-to-buffer-with-timestamp ()
"Ugly hack;; behaves as org-export-as-latex-to-buffer, but translates all timestamps to org-time-stamp-custom-formats"
(interactive)
(with-output-to-temp-buffer "*org-export*"
(cas/org-translate-time (buffer-substring-no-properties (mark) (point))))
(switch-to-buffer "*org-export*")
(delete-other-windows)
(org-mode)
(goto-char (point-min))
(save-excursion
(while
(re-search-forward "[]\\[]" nil t)
(replace-match "")))
(save-excursion
(while
(re-search-forward "\"" nil t)
(replace-match "")))
(write-file org-directory)
(org-export-as-latex org-export-headline-levels nil nil "*Org LaTeX Export*")
(set-buffer-modified-p nil)
(kill-buffer "*org-export*")
(switch-to-buffer-other-window "*Org LaTeX Export*")
(latex-mode)
(setq tempExportFiles (directory-files org-directory 1 "*org-export*"))
(cas/delete-export-files tempExportFiles))
(provide 'org-latex-timestamp)
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
[-- Attachment #4: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2009-04-12 18:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-06 23:12 Format for timestamp export Daniel Clemente
2009-04-09 7:37 ` Carsten Dominik
2009-04-12 18:37 ` Daniel Clemente
2009-04-12 18:43 ` Christopher Suckling [this message]
2009-04-13 6:54 ` Carsten Dominik
2009-04-13 8:50 ` Christopher Suckling
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=80EB2F27-E64D-4643-82E5-EFBAE76806F6@gmail.com \
--to=suckling.list@googlemail.com \
--cc=emacs-orgmode@gnu.org \
--cc=n142857@gmail.com \
/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).