From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexandre Passos Subject: Odd constrained failure mode in org-format-latex Date: Sat, 31 Jul 2010 19:35:29 -0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=46042 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfKfj-0000bd-KK for emacs-orgmode@gnu.org; Sat, 31 Jul 2010 18:36:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OfKek-0002pk-Gd for emacs-orgmode@gnu.org; Sat, 31 Jul 2010 18:35:51 -0400 Received: from mail-qw0-f41.google.com ([209.85.216.41]:45022) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfKek-0002pZ-ES for emacs-orgmode@gnu.org; Sat, 31 Jul 2010 18:35:50 -0400 Received: by qwk4 with SMTP id 4so937026qwk.0 for ; Sat, 31 Jul 2010 15:35:49 -0700 (PDT) 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: emacs-orgmode@gnu.org Hi, I was editing an org document on a server earlier today, remotely using tramp, and continuously exporting it to html. When I added LaTeX, it exported once and then not anymore, failing because it couldn't create a directory anymore. So I found out that patching org-export-latex to pass a "t" parameter to org-make-directory fixes this, and it continues to work perfectly. This is the modified version of that function, if anyone else is interested in this constrained case. The only change I made was right under the "make sure directory exists" comment. (defun org-format-latex (prefix &optional dir overlays msg at forbuffer) "Replace LaTeX fragments with links to an image, and produce images." (if (and overlays (fboundp 'clear-image-cache)) (clear-image-cache)) (let* ((prefixnodir (file-name-nondirectory prefix)) (absprefix (expand-file-name prefix dir)) (todir (file-name-directory absprefix)) (opt org-format-latex-options) (matchers (plist-get opt :matchers)) (re-list org-latex-regexps) (cnt 0) txt link beg end re e checkdir m n block linkfile movefile ov) ;; Check if there are old images files with this prefix, and remove the= m (when (file-directory-p todir) (mapc 'delete-file (directory-files todir 'full (concat (regexp-quote prefixnodir) "_[0-9]+\\.png$")))) ;; Check the different regular expressions (while (setq e (pop re-list)) (setq m (car e) re (nth 1 e) n (nth 2 e) block (if (nth 3 e) "\n\n" "")) (when (member m matchers) (goto-char (point-min)) (while (re-search-forward re nil t) (when (and (or (not at) (equal (cdr at) (match-beginning n))) (not (get-text-property (match-beginning n) 'org-protected))) (setq txt (match-string n) beg (match-beginning n) end (match-end n) cnt (1+ cnt) linkfile (format "%s_%04d.png" prefix cnt) movefile (format "%s_%04d.png" absprefix cnt) link (concat block "[[file:" linkfile "]]" block)) (if msg (message msg cnt)) (goto-char beg) (unless checkdir ; make sure the directory exists (setq checkdir t) (or (file-directory-p todir) (make-directory todir t))) (org-create-formula-image txt movefile opt forbuffer) (if overlays (progn (setq ov (org-make-overlay beg end)) (if (featurep 'xemacs) (progn (org-overlay-put ov 'invisible t) (org-overlay-put ov 'end-glyph (make-glyph (vector 'png :file movefile)))) (org-overlay-put ov 'display (list 'image :type 'png :file movefile :ascent 'center))) (push ov org-latex-fragment-image-overlays) (goto-char end)) (delete-region beg end) (insert link)))))))) --=20 =C2=A0- Alexandre