Re: [O] Bug: Problems with integration between asmyptote and org mode [7.7]
Hi Nicolas, Thanks for your info. It seems I was following an outdated howto. I didn't know asymptote was already integrated in babel. Now it is working fine. I am using the following org source: #+begin_src asymptote :file generated/asymptote.png :exports both 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_src #+results: [[file:generated/asymptote.png]] The problem with the subdirectory remains, though. I am able to publish the PNG to the directory where the org file is, but it is not possible to publish to a subdirectory (I call it generated), even though the subdirectory already exists. It seems that the export is being done in several steps, and one of them is concatenating subdirectories when the export is not done to the current directory. This is the relevant part of the *Messages* buffer: executing Asymptote code block... asy -globalwrite -f png -o /home/gonvaled/projects/dgv_notes/generated/asymptote.png /tmp/babel-3787Y5M/asymptote-3787wpa /usr/share/asymptote/plain_xasy.asy: 93.7: runtime: Cannot write to /home/gonvaled/projects/dgv_notes/generated//home/gonvaled/projects/dgv_notes/generated/asymptote_.tex Code block evaluation complete. Regards, Daniel On Thu, Aug 11, 2011 at 4:54 PM, Nicolas Goaziou n.goaz...@gmail.com wrote: Hello, Daniel Gonzalez gonva...@gonvaled.com writes: I have this code to activate asymptote: [...] Asymptote is included in Babel. Be sure to load the language: #+begin_src org (org-babel-do-load-languages 'org-babel-load-languages '((asymptote . t) (emacs-lisp . t))) #+end_src Then it's just about doing (when ii/ is created): #+begin_src asymptote :file ii/asy-output.png 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_src Regards, -- Nicolas Goaziou
[O] Bug: Problems with integration between asmyptote and org mode [7.7]
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
Re: [O] Bug: Problems with integration between asmyptote and org mode [7.7]
Hello, Daniel Gonzalez gonva...@gonvaled.com writes: I have this code to activate asymptote: [...] Asymptote is included in Babel. Be sure to load the language: #+begin_src org (org-babel-do-load-languages 'org-babel-load-languages '((asymptote . t) (emacs-lisp . t))) #+end_src Then it's just about doing (when ii/ is created): #+begin_src asymptote :file ii/asy-output.png 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_src Regards, -- Nicolas Goaziou