mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-23 00:10:42 +00:00
Tag ditaa and dod files with hash, to avoid remaking them
Patch by Eric Schulte
This commit is contained in:
parent
9714678f30
commit
67692d258f
|
@ -1,3 +1,9 @@
|
||||||
|
2009-11-17 Eric Schulte <schulte.eric@gmail.com>
|
||||||
|
|
||||||
|
* org-exp-blocks.el (org-export-blocks-format-ditaa): Use sha1
|
||||||
|
hash keys to cache and re-use images generated by the
|
||||||
|
org-exp-blocks interface to ditaa and dot.
|
||||||
|
|
||||||
2009-11-17 Carsten Dominik <carsten.dominik@gmail.com>
|
2009-11-17 Carsten Dominik <carsten.dominik@gmail.com>
|
||||||
|
|
||||||
* org-html.el (org-export-as-html): Move the home/up link into
|
* org-html.el (org-export-as-html): Move the home/up link into
|
||||||
|
|
|
@ -217,9 +217,15 @@ Specify the path at which the image should be saved as the first
|
||||||
element of headers, any additional elements of headers will be
|
element of headers, any additional elements of headers will be
|
||||||
passed to the ditaa utility as command line arguments."
|
passed to the ditaa utility as command line arguments."
|
||||||
(message "ditaa-formatting...")
|
(message "ditaa-formatting...")
|
||||||
(let ((out-file (if headers (car headers)))
|
(let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
|
||||||
(args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
|
(data-file (make-temp-file "org-ditaa"))
|
||||||
(data-file (make-temp-file "org-ditaa")))
|
(hash (sha1 (prin1-to-string (list body args))))
|
||||||
|
(raw-out-file (if headers (car headers)))
|
||||||
|
(out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file)
|
||||||
|
(cons (match-string 1 raw-out-file)
|
||||||
|
(match-string 2 raw-out-file))
|
||||||
|
(cons raw-out-file "png")))
|
||||||
|
(out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts))))
|
||||||
(unless (file-exists-p org-ditaa-jar-path)
|
(unless (file-exists-p org-ditaa-jar-path)
|
||||||
(error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path)))
|
(error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path)))
|
||||||
(setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body)
|
(setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body)
|
||||||
|
@ -229,9 +235,21 @@ passed to the ditaa utility as command line arguments."
|
||||||
"\n")))
|
"\n")))
|
||||||
(cond
|
(cond
|
||||||
((or htmlp latexp docbookp)
|
((or htmlp latexp docbookp)
|
||||||
(with-temp-file data-file (insert body))
|
(unless (file-exists-p out-file)
|
||||||
(message (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file))
|
(mapc ;; remove old hashed versions of this file
|
||||||
(shell-command (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file))
|
(lambda (file)
|
||||||
|
(when (and (string-match (concat (regexp-quote (car out-file-parts))
|
||||||
|
"_\\([[:alnum:]]+\\)\\."
|
||||||
|
(regexp-quote (cdr out-file-parts)))
|
||||||
|
file)
|
||||||
|
(= (length (match-string 1 out-file)) 40))
|
||||||
|
(delete-file (expand-file-name file
|
||||||
|
(file-name-directory out-file)))))
|
||||||
|
(directory-files (or (file-name-directory out-file)
|
||||||
|
default-directory)))
|
||||||
|
(with-temp-file data-file (insert body))
|
||||||
|
(message (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file))
|
||||||
|
(shell-command (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file)))
|
||||||
(format "\n[[file:%s]]\n" out-file))
|
(format "\n[[file:%s]]\n" out-file))
|
||||||
(t (concat
|
(t (concat
|
||||||
"\n#+BEGIN_EXAMPLE\n"
|
"\n#+BEGIN_EXAMPLE\n"
|
||||||
|
@ -259,14 +277,32 @@ digraph data_relationships {
|
||||||
}
|
}
|
||||||
#+end_dot"
|
#+end_dot"
|
||||||
(message "dot-formatting...")
|
(message "dot-formatting...")
|
||||||
(let ((out-file (if headers (car headers)))
|
(let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
|
||||||
(args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
|
(data-file (make-temp-file "org-ditaa"))
|
||||||
(data-file (make-temp-file "org-ditaa")))
|
(hash (sha1 (prin1-to-string (list body args))))
|
||||||
|
(raw-out-file (if headers (car headers)))
|
||||||
|
(out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file)
|
||||||
|
(cons (match-string 1 raw-out-file)
|
||||||
|
(match-string 2 raw-out-file))
|
||||||
|
(cons raw-out-file "png")))
|
||||||
|
(out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts))))
|
||||||
(cond
|
(cond
|
||||||
((or htmlp latexp docbookp)
|
((or htmlp latexp docbookp)
|
||||||
(with-temp-file data-file (insert body))
|
(unless (file-exists-p out-file)
|
||||||
(message (concat "dot " data-file " " args " -o " out-file))
|
(mapc ;; remove old hashed versions of this file
|
||||||
(shell-command (concat "dot " data-file " " args " -o " out-file))
|
(lambda (file)
|
||||||
|
(when (and (string-match (concat (regexp-quote (car out-file-parts))
|
||||||
|
"_\\([[:alnum:]]+\\)\\."
|
||||||
|
(regexp-quote (cdr out-file-parts)))
|
||||||
|
file)
|
||||||
|
(= (length (match-string 1 out-file)) 40))
|
||||||
|
(delete-file (expand-file-name file
|
||||||
|
(file-name-directory out-file)))))
|
||||||
|
(directory-files (or (file-name-directory out-file)
|
||||||
|
default-directory)))
|
||||||
|
(with-temp-file data-file (insert body))
|
||||||
|
(message (concat "dot " data-file " " args " -o " out-file))
|
||||||
|
(shell-command (concat "dot " data-file " " args " -o " out-file)))
|
||||||
(format "\n[[file:%s]]\n" out-file))
|
(format "\n[[file:%s]]\n" out-file))
|
||||||
(t (concat
|
(t (concat
|
||||||
"\n#+BEGIN_EXAMPLE\n"
|
"\n#+BEGIN_EXAMPLE\n"
|
||||||
|
|
Loading…
Reference in a new issue