emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Problems with integration between asmyptote and org mode [7.7]
@ 2011-08-10  9:08 Daniel Gonzalez
  2011-08-11 14:54 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Gonzalez @ 2011-08-10  9:08 UTC (permalink / raw)
  To: emacs-orgmode

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See
     http://orgmode.org/manual/Feedback.html#Feedback
Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------
I have this code to activate asymptote:
; Activate asymptote
(setq org-export-blocks
      (cons '(asy org-export-blocks-format-asy) org-export-blocks))
(defun org-export-blocks-format-asy (body &rest headers)
  "Pass block BODY to the asy utility creating an image.
Specify the path at which the image should be saved as the first
element of headers, any additional elements of headers will be
passed to the asy utility as command line arguments. The default
output format is pdf, but you can specify any format supported by
Imagemagick convert program with '-f outformat'."
  (message "asy-formatting...")
  (let* ((out-file (if headers (car headers)))
         (format (or (and (string-match ".+\\.\\(.+\\)" out-file)
                          (match-string 1 out-file))
                     "pdf"))
         (args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
         (data-file (make-temp-file "org-asy")))
    (setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body)
                   body
                 (mapconcat (lambda (x) (substring x (if (> (length x) 1) 2 1)))
                            (org-split-string body "\n")
                            "\n")))
    (cond
     ((or t)
      (with-temp-file data-file (insert body))
      (message (concat "asy -globalwrite -f " format " -o " out-file "
" args " " data-file))
      (shell-command (concat "asy -globalwrite -f " format " -o "
out-file " " args " " data-file))
      (format "\n[[file:%s]]\n" out-file))
     (t (concat
         "\n#+BEGIN_EXAMPLE\n"
         body (if (string-match "\n$" body) "" "\n")
         "#+END_EXAMPLE\n")))))
(Originally the (or t) statement was (or htmlp latexp), but I was
getting an error about htmlp.)
This is the org source that I am using to call asymptote:
#+begin_asy asymptote.png
// This comment is needed, because emacs is swallowing the first non-empty line
import graph;
size(0,4cm);
real f(real t) {return 1+cos(t);}
path g=polargraph(f,0,2pi,operator ..)--cycle;
filldraw(g,pink);
xaxis("$x$",above=true);
yaxis("$y$",above=true);
dot("$(a,0)$",(1,0),N);
dot("$(2a,0)$",(2,0),N+E);
#+end_asy
There are several problems here
 - Problems writing to a subdirectory:
  : asy -globalwrite -f png -o generated/asymptote.png  ~/ii
  :   /usr/share/asymptote/plain_xasy.asy: 93.7: runtime: Cannot write
to generated/generated/asymptote_.tex
 - The first non-empty statement in the asymptote source gets
 "swallowed" by emacs.
So for the time being, a comment must be added at the beginning, and
no subdirectory can be used. This is annoying, because I place my
generated images into a generated directory, so as to keep them out of
version control.
Emacs  : GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2011-03-04 on palmer, modified by Debian
Package: Org-mode version 7.7
current state:
==============
(setq
 org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars)
 org-speed-command-hook '(org-speed-command-default-hook
org-babel-speed-command-hook)
 org-src-fontify-natively t
 org-plantuml-jar-path "~/.java/plantuml.jar"
 org-babel-load-languages '((emacs-lisp . t) (dot . t) (ditaa . t) (R
. t) (python . t) (ruby . t) (gnuplot . t)
                            (clojure . t) (sh . t) (ledger . t) (org .
t) (plantuml . t) (latex . t))
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-babel-tangle-lang-exts '(("latex" . "tex") ("clojure" . "clj")
("ruby" . "rb") ("python" . "py")
                              ("emacs-lisp" . "el"))
 org-startup-folded nil
 org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup)
 org-publish-use-timestamps-flag nil
 org-export-latex-format-toc-function 'org-export-latex-format-toc-default
 org-tab-first-hook '(org-hide-block-toggle-maybe
org-src-native-tab-command-maybe
                      org-babel-hide-result-toggle-maybe)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-export-first-hook '(org-beamer-initialize-open-trackers)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-hide-drawers org-cycle-show-empty-lines
                  org-optimize-window-after-visibility-change)
 org-publish-project-alist '(...)
 org-export-preprocess-before-normalizing-links-hook
'(org-remove-file-link-modifiers)
 org-mode-hook '(#[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook
org-show-block-all append local] 5]
                 #[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook
org-babel-show-result-all append local] 5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-export-htmlize-output-type 'css
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point
org-babel-execute-safely-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-export-interblocks '((lob org-babel-exp-lob-one-liners) (src
org-babel-exp-inline-src-blocks))
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-babel-after-execute-hook '(org-display-inline-images)
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp "\\<gonvaled\\>"
 org-export-preprocess-before-selecting-backend-code-hook
'(org-beamer-select-beamer-code)
 org-confirm-babel-evaluate nil
 org-use-sub-superscripts '{}
 org-export-latex-final-hook '(org-beamer-amend-header
org-beamer-fix-toc org-beamer-auto-fragile-frames
                               org-beamer-place-default-actions-for-lists)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-export-blocks '((asy org-export-blocks-format-asy) (src
org-babel-exp-src-block nil)
                     (comment org-export-blocks-format-comment t)
(ditaa org-export-blocks-format-ditaa nil)
                     (dot org-export-blocks-format-dot nil))
 )

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-12  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-10  9:08 Bug: Problems with integration between asmyptote and org mode [7.7] Daniel Gonzalez
2011-08-11 14:54 ` Nicolas Goaziou
2011-08-12  7:16   ` Daniel Gonzalez

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).