From: Alexandre Passos <alexandre.tp@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Odd constrained failure mode in org-format-latex
Date: Sat, 31 Jul 2010 19:35:29 -0300 [thread overview]
Message-ID: <AANLkTimNrOQSNOBBESRsCJT1OTEcGAy7DV5VJjTWzwEy@mail.gmail.com> (raw)
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 them
(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))))))))
--
- Alexandre
next reply other threads:[~2010-07-31 22:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-31 22:35 Alexandre Passos [this message]
2010-08-01 8:08 ` Odd constrained failure mode in org-format-latex Bastien
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTimNrOQSNOBBESRsCJT1OTEcGAy7DV5VJjTWzwEy@mail.gmail.com \
--to=alexandre.tp@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.