emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* The patch (org-exp-blocks), the question and the bug
@ 2009-05-17 12:36 emacs-orgmode
  2009-05-17 23:14 ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: emacs-orgmode @ 2009-05-17 12:36 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I have created (in fact, I have copied and pasted with slights
modifications) a function to use asymptote's code
(http://asymptote.sourceforge.net) with the help of org-exp-blocks.
Unfortunately, I am clueless about how to make a patch with git. So,
with all my apologies, I will put it here as it might be useful to
someone.

(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)))
	(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 htmlp latexp)
      (with-temp-file data-file (insert body))
      (message (concat "asy -globalwrite -f pdf -o " out-file " " args " " data-file))
      (shell-command (concat "asy -globalwrite -f pdf -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")))))

Don't forget to change accordingly org-export-blocks.

But that leads me to a question. I use (setq
org-export-latex-image-default-option "") in my .emacs. But, as it might
not be convenient for everyone, I would like to disable locally that
option in the asymptote's block. In fact, the code should take
precedence above export options : if I put 'size(5cm,0);' in my block, I
don't want no variable messing with that. Is there a way to do that ?

Last, but not least, I have something looking like a bug to report.
Sometimes, when I hit C-k in agenda view, it kills me 2 lines instead of
the one I am currently on. I can tell that kill-whole-line has nothing
to do with that. It scares me so much that I have to TAB first while in
agenda view in order to kill the item I want to make disappear. I use
6.26d but I could swear this bug has been on for ages (maybe 4.xx,
certainly 5.xx).

Thanks.

-- 
Nicolas Goaziou

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

* Re: The patch (org-exp-blocks), the question and the bug
  2009-05-17 12:36 The patch (org-exp-blocks), the question and the bug emacs-orgmode
@ 2009-05-17 23:14 ` Eric Schulte
  2009-05-17 23:32   ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2009-05-17 23:14 UTC (permalink / raw)
  To: emacs-orgmode

emacs-orgmode@gnu.org writes:

> Hello,
>
> I have created (in fact, I have copied and pasted with slights
> modifications) a function to use asymptote's code
> (http://asymptote.sourceforge.net) with the help of org-exp-blocks.
> Unfortunately, I am clueless about how to make a patch with git. So,
> with all my apologies, I will put it here as it might be useful to
> someone.
>

Thanks, asymptote looks like an interesting tool.

Rather than continually adding new block definitions directly to
org-exp-blocks.el I think we should add a section to the org-exp-blocks
page on worg where code implementing new blocks can be shared.  I'll try
to do this in the next couple of days with your asymptote code as the
first new block type.

> But that leads me to a question. I use (setq
> org-export-latex-image-default-option "") in my .emacs. But, as it might
> not be convenient for everyone, I would like to disable locally that
> option in the asymptote's block. In fact, the code should take
> precedence above export options : if I put 'size(5cm,0);' in my block, I
> don't want no variable messing with that. Is there a way to do that ?
>

I'm sorry, I have no experience with this variable.  However any number
of options could be specified in the headers line of the asymptote
block.  These will then be available inside the asymptote function (in
the `headers' list) where they could be used to change the values of
elisp variables.

>
> Last, but not least, I have something looking like a bug to report.
> Sometimes, when I hit C-k in agenda view, it kills me 2 lines instead of
> the one I am currently on. I can tell that kill-whole-line has nothing
> to do with that. It scares me so much that I have to TAB first while in
> agenda view in order to kill the item I want to make disappear. I use
> 6.26d but I could swear this bug has been on for ages (maybe 4.xx,
> certainly 5.xx).
>

Sorry, I can't help on this front.

>
> Thanks.

Thanks for sharing! -- Eric

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

* Re: The patch (org-exp-blocks), the question and the bug
  2009-05-17 23:14 ` Eric Schulte
@ 2009-05-17 23:32   ` Eric Schulte
  2009-05-18 11:54     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2009-05-17 23:32 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I've added an asymptote section to the org-exp-blocks page [1] which
should be published to worg within the next hour or so.  This section
would benefit from an example asymptote block, which I am unable to
provide.

Thanks -- Eric

[1] http://orgmode.org/worg/org-contrib/org-exp-blocks.php

"Eric Schulte" <schulte.eric@gmail.com> writes:

> emacs-orgmode@gnu.org writes:
>
>> Hello,
>>
>> I have created (in fact, I have copied and pasted with slights
>> modifications) a function to use asymptote's code
>> (http://asymptote.sourceforge.net) with the help of org-exp-blocks.
>> Unfortunately, I am clueless about how to make a patch with git. So,
>> with all my apologies, I will put it here as it might be useful to
>> someone.
>>
>
> Thanks, asymptote looks like an interesting tool.
>
> Rather than continually adding new block definitions directly to
> org-exp-blocks.el I think we should add a section to the org-exp-blocks
> page on worg where code implementing new blocks can be shared.  I'll try
> to do this in the next couple of days with your asymptote code as the
> first new block type.
>
>> But that leads me to a question. I use (setq
>> org-export-latex-image-default-option "") in my .emacs. But, as it might
>> not be convenient for everyone, I would like to disable locally that
>> option in the asymptote's block. In fact, the code should take
>> precedence above export options : if I put 'size(5cm,0);' in my block, I
>> don't want no variable messing with that. Is there a way to do that ?
>>
>
> I'm sorry, I have no experience with this variable.  However any number
> of options could be specified in the headers line of the asymptote
> block.  These will then be available inside the asymptote function (in
> the `headers' list) where they could be used to change the values of
> elisp variables.
>
>>
>> Last, but not least, I have something looking like a bug to report.
>> Sometimes, when I hit C-k in agenda view, it kills me 2 lines instead of
>> the one I am currently on. I can tell that kill-whole-line has nothing
>> to do with that. It scares me so much that I have to TAB first while in
>> agenda view in order to kill the item I want to make disappear. I use
>> 6.26d but I could swear this bug has been on for ages (maybe 4.xx,
>> certainly 5.xx).
>>
>
> Sorry, I can't help on this front.
>
>>
>> Thanks.
>
> Thanks for sharing! -- Eric

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

* Re: The patch (org-exp-blocks), the question and the bug
  2009-05-17 23:32   ` Eric Schulte
@ 2009-05-18 11:54     ` Nicolas Goaziou
  2009-05-18 13:30       ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2009-05-18 11:54 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Hello,

Here is a simple asymptote block :

#+begin_asy out.pdf
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

The output should be 
http://asymptote.sourceforge.net/gallery/cardioid.pdf

-- 
Nicolas Goaziou

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

* Re: The patch (org-exp-blocks), the question and the bug
  2009-05-18 11:54     ` Nicolas Goaziou
@ 2009-05-18 13:30       ` Eric Schulte
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2009-05-18 13:30 UTC (permalink / raw)
  To: emacs-orgmode

Thanks for the example.

I've added it along with a line crediting you as the author to the
org-exp-blocks page on worg.

Cheers -- Eric

Nicolas Goaziou <n.goaziou@neuf.fr> writes:

> Hello,
>
> Here is a simple asymptote block :
>
> #+begin_asy out.pdf
> 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
>
> The output should be 
> http://asymptote.sourceforge.net/gallery/cardioid.pdf

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

end of thread, other threads:[~2009-05-18 13:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-17 12:36 The patch (org-exp-blocks), the question and the bug emacs-orgmode
2009-05-17 23:14 ` Eric Schulte
2009-05-17 23:32   ` Eric Schulte
2009-05-18 11:54     ` Nicolas Goaziou
2009-05-18 13:30       ` Eric Schulte

Code repositories for project(s) associated with this 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).