From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Gonzalez Subject: Bug: Problems with integration between asmyptote and org mode [7.7] Date: Wed, 10 Aug 2011 11:08:05 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qr4mB-00046y-RU for emacs-orgmode@gnu.org; Wed, 10 Aug 2011 05:08:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qr4mA-0005Jq-BF for emacs-orgmode@gnu.org; Wed, 10 Aug 2011 05:08:35 -0400 Received: from mo-p00-ob.rzone.de ([81.169.146.162]:48519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qr4m9-0005JQ-NG for emacs-orgmode@gnu.org; Wed, 10 Aug 2011 05:08:34 -0400 Received: from mail-gy0-f169.google.com ([209.85.160.169]) by smtp.strato.de (jimi mo47) (RZmta 26.2) with ESMTPA id K07525n7A8q3Ey for ; Wed, 10 Aug 2011 11:08:25 +0200 (MEST) Received: by gyg10 with SMTP id 10so584411gyg.0 for ; Wed, 10 Aug 2011 02:08:25 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Remember to cover the basics, that is, what you expected to happen and what in fact did happen. =A0You don't know how to make a good report? =A0Se= e =A0 =A0 =A0http://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 =A0 =A0 =A0 (cons '(asy org-export-blocks-format-asy) org-export-blocks)) (defun org-export-blocks-format-asy (body &rest headers) =A0 "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'." =A0 (message "asy-formatting...") =A0 (let* ((out-file (if headers (car headers))) =A0 =A0 =A0 =A0 =A0(format (or (and (string-match ".+\\.\\(.+\\)" out-file) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match-string 1 out-fil= e)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"pdf")) =A0 =A0 =A0 =A0 =A0(args (if (cdr headers) (mapconcat 'identity (cdr header= s) " "))) =A0 =A0 =A0 =A0 =A0(data-file (make-temp-file "org-asy"))) =A0 =A0 (setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0body =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(mapconcat (lambda (x) (substring x (if = (> (length x) 1) 2 1))) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-split-string b= ody "\n") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "\n"))) =A0 =A0 (cond =A0 =A0 =A0((or t) =A0 =A0 =A0 (with-temp-file data-file (insert body)) =A0 =A0 =A0 (message (concat "asy -globalwrite -f " format " -o " out-file = " " args " " data-file)) =A0 =A0 =A0 (shell-command (concat "asy -globalwrite -f " format " -o " out-file " " args " " data-file)) =A0 =A0 =A0 (format "\n[[file:%s]]\n" out-file)) =A0 =A0 =A0(t (concat =A0 =A0 =A0 =A0 =A0"\n#+BEGIN_EXAMPLE\n" =A0 =A0 =A0 =A0 =A0body (if (string-match "\n$" body) "" "\n") =A0 =A0 =A0 =A0 =A0"#+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=3Dpolargraph(f,0,2pi,operator ..)--cycle; filldraw(g,pink); xaxis("$x$",above=3Dtrue); yaxis("$y$",above=3Dtrue); dot("$(a,0)$",(1,0),N); dot("$(2a,0)$",(2,0),N+E); #+end_asy There are several problems here =A0- Problems writing to a subdirectory: =A0 : asy -globalwrite -f png -o generated/asymptote.png =A0~/ii =A0 : =A0 /usr/share/asymptote/plain_xasy.asy: 93.7: runtime: Cannot write to generated/generated/asymptote_.tex =A0- The first non-empty statement in the asymptote source gets =A0"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 =A0: GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1) =A0of 2011-03-04 on palmer, modified by Debian Package: Org-mode version 7.7 current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq =A0org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars= ) =A0org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook) =A0org-src-fontify-natively t =A0org-plantuml-jar-path "~/.java/plantuml.jar" =A0org-babel-load-languages '((emacs-lisp . t) (dot . t) (ditaa . t) (R . t) (python . t) (ruby . t) (gnuplot . t) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (clojure . t) (sh .= t) (ledger . t) (org . t) (plantuml . t) (latex . t)) =A0org-metaup-hook '(org-babel-load-in-session-maybe) =A0org-after-todo-state-change-hook '(org-clock-out-if-current) =A0org-babel-tangle-lang-exts '(("latex" . "tex") ("clojure" . "clj") ("ruby" . "rb") ("python" . "py") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ("emacs-lisp" .= "el")) =A0org-startup-folded nil =A0org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup) =A0org-publish-use-timestamps-flag nil =A0org-export-latex-format-toc-function 'org-export-latex-format-toc-defaul= t =A0org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 org-babel-hide-result-toggle-ma= ybe) =A0org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer) =A0org-confirm-shell-link-function 'yes-or-no-p =A0org-export-first-hook '(org-beamer-initialize-open-trackers) =A0org-agenda-before-write-hook '(org-agenda-add-entry-text) =A0org-babel-pre-tangle-hook '(save-buffer) =A0org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-show-empty-lines =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 org-optimize-window-after-visibility-ch= ange) =A0org-publish-project-alist '(...) =A0org-export-preprocess-before-normalizing-links-hook '(org-remove-file-link-modifiers) =A0org-mode-hook '(#[nil "\300\301\302\303\304$\207" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[org-add-hook change-major-mode-hook org-show-block-all append local] 5] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#[nil "\300\301\302\303\304$\207" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0org-babel-result-hide-spec org-babel-hid= e-all-hashes) =A0org-export-htmlize-output-type 'css =A0org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe) =A0org-confirm-elisp-link-function 'yes-or-no-p =A0org-export-interblocks '((lob org-babel-exp-lob-one-liners) (src org-babel-exp-inline-src-blocks)) =A0org-clock-out-hook '(org-clock-remove-empty-clock-drawer) =A0org-babel-after-execute-hook '(org-display-inline-images) =A0org-occur-hook '(org-first-headline-recenter) =A0org-from-is-user-regexp "\\" =A0org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-beamer-code) =A0org-confirm-babel-evaluate nil =A0org-use-sub-superscripts '{} =A0org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-toc org-beamer-auto-fragile-frames =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0org-beamer-p= lace-default-actions-for-lists) =A0org-metadown-hook '(org-babel-pop-to-session-maybe) =A0org-export-blocks '((asy org-export-blocks-format-asy) (src org-babel-exp-src-block nil) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(comment org-export-blocks-forma= t-comment t) (ditaa org-export-blocks-format-ditaa nil) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(dot org-export-blocks-format-do= t nil)) =A0)