* 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
* Re: Bug: Problems with integration between asmyptote and org mode [7.7]
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
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2011-08-11 14:54 UTC (permalink / raw)
To: Daniel Gonzalez; +Cc: emacs-orgmode
Hello,
Daniel Gonzalez <gonvaled@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug: Problems with integration between asmyptote and org mode [7.7]
2011-08-11 14:54 ` Nicolas Goaziou
@ 2011-08-12 7:16 ` Daniel Gonzalez
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Gonzalez @ 2011-08-12 7:16 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
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.goaziou@gmail.com> wrote:
> Hello,
>
> Daniel Gonzalez <gonvaled@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
>
^ 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).