From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Suckling Subject: Re: Format for timestamp export Date: Sun, 12 Apr 2009 19:43:21 +0100 Message-ID: <80EB2F27-E64D-4643-82E5-EFBAE76806F6@gmail.com> References: <87skkle5qx.fsf@gmail.com> <87ocv1d8hf.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: multipart/mixed; boundary=Apple-Mail-4--738403200 Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lt4eQ-0007zX-EK for emacs-orgmode@gnu.org; Sun, 12 Apr 2009 14:43:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lt4eL-0007uq-Rh for emacs-orgmode@gnu.org; Sun, 12 Apr 2009 14:43:29 -0400 Received: from [199.232.76.173] (port=42689 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lt4eL-0007ud-G2 for emacs-orgmode@gnu.org; Sun, 12 Apr 2009 14:43:25 -0400 Received: from mail-ew0-f160.google.com ([209.85.219.160]:48832) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lt4eK-0007oH-QY for emacs-orgmode@gnu.org; Sun, 12 Apr 2009 14:43:25 -0400 Received: by ewy4 with SMTP id 4so2162200ewy.42 for ; Sun, 12 Apr 2009 11:43:24 -0700 (PDT) In-Reply-To: <87ocv1d8hf.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Daniel Clemente Cc: mailing-list-org-mode --Apple-Mail-4--738403200 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit 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 --Apple-Mail-4--738403200 Content-Disposition: attachment; filename=org-latex-timestamp.el Content-Type: application/octet-stream; x-unix-mode=0644; name="org-latex-timestamp.el" Content-Transfer-Encoding: 7bit ;; 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) --Apple-Mail-4--738403200 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-4--738403200 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --Apple-Mail-4--738403200--