emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* new exporter, conditional options according to backend
@ 2013-01-18 15:47 Ezequiel Birman
  2013-01-19 22:48 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Ezequiel Birman @ 2013-01-18 15:47 UTC (permalink / raw)
  To: emacs-orgmode

Is it possible to write something like this with the new exporter?

#+OPTIONS: (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'e-beamer)) "H:1" "H:3")

From what I read in org-export.el the backend is stored in a plist, not
sure how to get it's value when exporting.

Or, maybe I need to write a filter function to be run from
org-export-before-process-hook?

-- 
Ezequiel Birman

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

* Re: new exporter, conditional options according to backend
  2013-01-18 15:47 new exporter, conditional options according to backend Ezequiel Birman
@ 2013-01-19 22:48 ` Nicolas Goaziou
  2013-01-20  4:38   ` Ezequiel Birman
                     ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2013-01-19 22:48 UTC (permalink / raw)
  To: Ezequiel Birman; +Cc: emacs-orgmode

Hello,

Ezequiel Birman <stormwatch@espiga4.com.ar> writes:

> Is it possible to write something like this with the new exporter?
>
> #+OPTIONS: (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'e-beamer)) "H:1" "H:3")

There is no `org-export-current-backend' in the new exporter. Besides,
what you want is the default behaviour (see `org-e-beamer-frame-level'
variable).

> From what I read in org-export.el the backend is stored in a plist, not
> sure how to get it's value when exporting.
>
> Or, maybe I need to write a filter function to be run from
> org-export-before-process-hook?

Filters are different from hook. A function in a hook operates on an Org
buffer. A filter function operates either on a string in output syntax
or on the parse tree.

If, for some reason, you want to modify export options "on the fly", you
could create a filter function for parse tree, and modify options plist
from it:

#+begin_src emacs-lisp
(defun my-options-change-fun (tree backend info)
  (when (org-export-derived-backend-p backend 'e-beamer)
    (plist-put info :with-author nil))
  ;; Don't forget to return tree.
  tree)

(add-to-list 'org-export-filter-parse-tree-functions
             'my-options-change-fun)
#+end_src


Regards,

-- 
Nicolas Goaziou

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

* Re: new exporter, conditional options according to backend
  2013-01-19 22:48 ` Nicolas Goaziou
@ 2013-01-20  4:38   ` Ezequiel Birman
  2013-01-20  5:35   ` Jambunathan K
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Birman @ 2013-01-20  4:38 UTC (permalink / raw)
  To: emacs-orgmode

>>>>> "Nicolas" == Nicolas Goaziou <n.goaziou@gmail.com> writes:

    > Hello, Ezequiel Birman <stormwatch@espiga4.com.ar> writes:

    >> Is it possible to write something like this with the new
    >> exporter?
    >> 
    >> #+OPTIONS: (if (and (boundp 'org-export-current-backend) (eq
    >> org-export-current-backend 'e-beamer)) "H:1" "H:3")

    > There is no `org-export-current-backend' in the new
    > exporter. Besides, what you want is the default behaviour (see
    > `org-e-beamer-frame-level' variable).

    >> From what I read in org-export.el the backend is stored in a
    >> plist, not sure how to get it's value when exporting.
    >> 
    >> Or, maybe I need to write a filter function to be run from
    >> org-export-before-process-hook?

    > Filters are different from hook. A function in a hook operates on
    > an Org buffer. A filter function operates either on a string in
    > output syntax or on the parse tree.

    > If, for some reason, you want to modify export options "on the
    > fly", you could create a filter function for parse tree, and
    > modify options plist from it:

    > #+begin_src emacs-lisp (defun my-options-change-fun (tree backend
    > info) (when (org-export-derived-backend-p backend 'e-beamer)
    > (plist-put info :with-author nil)) ;; Don't forget to return tree.
    > tree)

    > (add-to-list 'org-export-filter-parse-tree-functions
    > 'my-options-change-fun) #+end_src


    > Regards,

    > -- Nicolas Goaziou

Thanks for the example and the clarificatons re filters versus hooks,
and for thinking of those sane defaults ahead too.

-- 
Ezequiel Birman

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

* Re: new exporter, conditional options according to backend
  2013-01-19 22:48 ` Nicolas Goaziou
  2013-01-20  4:38   ` Ezequiel Birman
@ 2013-01-20  5:35   ` Jambunathan K
  2013-01-20  9:28     ` Nicolas Goaziou
  2013-01-24 20:32   ` Andreas Leha
  2013-01-25 17:37   ` cberry
  3 siblings, 1 reply; 11+ messages in thread
From: Jambunathan K @ 2013-01-20  5:35 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Ezequiel Birman, emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> #+begin_src emacs-lisp
> (defun my-options-change-fun (tree backend info)
>   (when (org-export-derived-backend-p backend 'e-beamer)
>     (plist-put info :with-author nil))
>   ;; Don't forget to return tree.
>   tree)

CAVEAT: plist-put can return a different list, at times.

I don't know enough about implementation of `plist-put' to ascertain
when it would return a new list.

> (add-to-list 'org-export-filter-parse-tree-functions
>              'my-options-change-fun)

-- 

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

* Re: new exporter, conditional options according to backend
  2013-01-20  5:35   ` Jambunathan K
@ 2013-01-20  9:28     ` Nicolas Goaziou
  2013-01-20 16:22       ` Jambunathan K
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2013-01-20  9:28 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Ezequiel Birman, emacs-orgmode

Jambunathan K <kjambunathan@gmail.com> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> #+begin_src emacs-lisp
>> (defun my-options-change-fun (tree backend info)
>>   (when (org-export-derived-backend-p backend 'e-beamer)
>>     (plist-put info :with-author nil))
>>   ;; Don't forget to return tree.
>>   tree)
>
> CAVEAT: plist-put can return a different list, at times.
>
> I don't know enough about implementation of `plist-put' to ascertain
> when it would return a new list.

Since the OP wants to modify the values of _existing properties_ I'm
quite sure the change will happen in place.


Regards,

-- 
Nicolas Goaziou

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

* Re: new exporter, conditional options according to backend
  2013-01-20  9:28     ` Nicolas Goaziou
@ 2013-01-20 16:22       ` Jambunathan K
  2013-01-28  7:12         ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Jambunathan K @ 2013-01-20 16:22 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Ezequiel Birman, emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Jambunathan K <kjambunathan@gmail.com> writes:
>
>> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>>
>>> #+begin_src emacs-lisp
>>> (defun my-options-change-fun (tree backend info)
>>>   (when (org-export-derived-backend-p backend 'e-beamer)
>>>     (plist-put info :with-author nil))
>>>   ;; Don't forget to return tree.
>>>   tree)
>>
>> CAVEAT: plist-put can return a different list, at times.
>>
>> I don't know enough about implementation of `plist-put' to ascertain
>> when it would return a new list.
>
> Since the OP wants to modify the values of _existing properties_ I'm
> quite sure the change will happen in place.

Look at example in Elisp manual.  New members seem to get appended.  

List being destructive is explainable if new members were to be added to
the head.  Since this is not the case, I am curious what the
implementation could be ...


>
>
> Regards,

-- 

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

* Re: new exporter, conditional options according to backend
  2013-01-19 22:48 ` Nicolas Goaziou
  2013-01-20  4:38   ` Ezequiel Birman
  2013-01-20  5:35   ` Jambunathan K
@ 2013-01-24 20:32   ` Andreas Leha
  2013-01-25 13:23     ` Nicolas Goaziou
  2013-01-25 17:37   ` cberry
  3 siblings, 1 reply; 11+ messages in thread
From: Andreas Leha @ 2013-01-24 20:32 UTC (permalink / raw)
  To: emacs-orgmode

Hi Nicolas,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Ezequiel Birman <stormwatch@espiga4.com.ar> writes:
>
>> Is it possible to write something like this with the new exporter?
>>
>> #+OPTIONS: (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'e-beamer)) "H:1" "H:3")
>
> There is no `org-export-current-backend' in the new exporter. Besides,
> what you want is the default behaviour (see `org-e-beamer-frame-level'
> variable).
>
>> From what I read in org-export.el the backend is stored in a plist, not
>> sure how to get it's value when exporting.
>>
>> Or, maybe I need to write a filter function to be run from
>> org-export-before-process-hook?
>
> Filters are different from hook. A function in a hook operates on an Org
> buffer. A filter function operates either on a string in output syntax
> or on the parse tree.
>
> If, for some reason, you want to modify export options "on the fly", you
> could create a filter function for parse tree, and modify options plist
> from it:
>
> #+begin_src emacs-lisp
> (defun my-options-change-fun (tree backend info)
>   (when (org-export-derived-backend-p backend 'e-beamer)
>     (plist-put info :with-author nil))
>   ;; Don't forget to return tree.
>   tree)
>
> (add-to-list 'org-export-filter-parse-tree-functions
>              'my-options-change-fun)
> #+end_src
>
>
> Regards,

Sorry for hijacking this thread.  But I am also interested in backend
specific options.  Could you give an example of how to achieve something
like this with the new exporter:

#+begin_src R :results graphics :file (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'e-latex)) "foo.pdf" "foo.png")
  plot(1:10)
#+end_src

Thanks in advance,
Andreas

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

* Re: new exporter, conditional options according to backend
  2013-01-24 20:32   ` Andreas Leha
@ 2013-01-25 13:23     ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2013-01-25 13:23 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Hello,

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Sorry for hijacking this thread.  But I am also interested in backend
> specific options.  Could you give an example of how to achieve something
> like this with the new exporter:
>
> #+begin_src R :results graphics :file (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'e-latex)) "foo.pdf" "foo.png")
>   plot(1:10)
> #+end_src

You need to process the buffer being exported before Babel blocks are
expanded. You could use `org-export-before-processing-hook' for that.

For example, you could define a specific extension for :file values,
like "foo.xxx", process the buffer and and replace "xxx" with an
appropriate extension according to the current back-end (the argument of
the function).


Regards,

-- 
Nicolas Goaziou

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

* Re: new exporter, conditional options according to backend
  2013-01-19 22:48 ` Nicolas Goaziou
                     ` (2 preceding siblings ...)
  2013-01-24 20:32   ` Andreas Leha
@ 2013-01-25 17:37   ` cberry
  2013-01-25 17:50     ` Nicolas Goaziou
  3 siblings, 1 reply; 11+ messages in thread
From: cberry @ 2013-01-25 17:37 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Ezequiel Birman <stormwatch@espiga4.com.ar> writes:
>
>> Is it possible to write something like this with the new exporter?
>>
>> #+OPTIONS: (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'e-beamer)) "H:1" "H:3")
>
> There is no `org-export-current-backend' in the new exporter. Besides,
> what you want is the default behaviour (see `org-e-beamer-frame-level'
> variable).

'backend' is in the scope of transcoding functions like
inline-src-block.

I am currently taking advantage of this, but it is a shortcut rather
than a necessity. 

Is your advice "Don't do that" ?

Chuck
>
>> From what I read in org-export.el the backend is stored in a plist, not
>> sure how to get it's value when exporting.
>>
>> Or, maybe I need to write a filter function to be run from
>> org-export-before-process-hook?
>
> Filters are different from hook. A function in a hook operates on an Org
> buffer. A filter function operates either on a string in output syntax
> or on the parse tree.
>
> If, for some reason, you want to modify export options "on the fly", you
> could create a filter function for parse tree, and modify options plist
> from it:
>
> #+begin_src emacs-lisp
> (defun my-options-change-fun (tree backend info)
>   (when (org-export-derived-backend-p backend 'e-beamer)
>     (plist-put info :with-author nil))
>   ;; Don't forget to return tree.
>   tree)
>
> (add-to-list 'org-export-filter-parse-tree-functions
>              'my-options-change-fun)
> #+end_src
>
>
> Regards,

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

* Re: new exporter, conditional options according to backend
  2013-01-25 17:37   ` cberry
@ 2013-01-25 17:50     ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2013-01-25 17:50 UTC (permalink / raw)
  To: cberry; +Cc: emacs-orgmode

Hello,

cberry@tajo.ucsd.edu writes:

> 'backend' is in the scope of transcoding functions like
> inline-src-block.
>
> I am currently taking advantage of this, but it is a shortcut rather
> than a necessity. 
>
> Is your advice "Don't do that" ?

I would rather say "Don't do that in public code". There's no guarantee
this hack will always work.

As you probably know, the clean way to retrieve the back-end symbol from
a transcoding function is:

  (plist-get info :back-end)

INFO being the third argument passed to the function.


Regards,

-- 
Nicolas Goaziou

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

* Re: new exporter, conditional options according to backend
  2013-01-20 16:22       ` Jambunathan K
@ 2013-01-28  7:12         ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2013-01-28  7:12 UTC (permalink / raw)
  To: Jambunathan K; +Cc: Ezequiel Birman, emacs-orgmode

Hello,

Jambunathan K <kjambunathan@gmail.com> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> Jambunathan K <kjambunathan@gmail.com> writes:
>>
>>> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>>>
>>>> #+begin_src emacs-lisp
>>>> (defun my-options-change-fun (tree backend info)
>>>>   (when (org-export-derived-backend-p backend 'e-beamer)
>>>>     (plist-put info :with-author nil))
>>>>   ;; Don't forget to return tree.
>>>>   tree)
>>>
>>> CAVEAT: plist-put can return a different list, at times.
>>>
>>> I don't know enough about implementation of `plist-put' to ascertain
>>> when it would return a new list.
>>
>> Since the OP wants to modify the values of _existing properties_ I'm
>> quite sure the change will happen in place.
>
> Look at example in Elisp manual.  New members seem to get appended.  
>
> List being destructive is explainable if new members were to be added to
> the head.  Since this is not the case, I am curious what the
> implementation could be ...

I have added a filter for export options. The OP may want to use it
instead.

I guess it will be cleaner that way. Besides, the previous export
framework had one too.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2013-01-28  7:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-18 15:47 new exporter, conditional options according to backend Ezequiel Birman
2013-01-19 22:48 ` Nicolas Goaziou
2013-01-20  4:38   ` Ezequiel Birman
2013-01-20  5:35   ` Jambunathan K
2013-01-20  9:28     ` Nicolas Goaziou
2013-01-20 16:22       ` Jambunathan K
2013-01-28  7:12         ` Nicolas Goaziou
2013-01-24 20:32   ` Andreas Leha
2013-01-25 13:23     ` Nicolas Goaziou
2013-01-25 17:37   ` cberry
2013-01-25 17:50     ` Nicolas Goaziou

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