* new LaTeX exporter hook
@ 2012-05-23 8:33 Andreas Leha
2012-05-23 11:30 ` Jambunathan K
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Leha @ 2012-05-23 8:33 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
the new LaTeX exporter does not seem to "run" the
org-export-latex-final-hook. Is there an equivalent?
Cheers,
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: new LaTeX exporter hook
2012-05-23 8:33 new LaTeX exporter hook Andreas Leha
@ 2012-05-23 11:30 ` Jambunathan K
2012-05-23 12:32 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Jambunathan K @ 2012-05-23 11:30 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Hi all,
>
> the new LaTeX exporter does not seem to "run" the
> org-export-latex-final-hook. Is there an equivalent?
You are looking for `:filter-final-output' within
`org-export-filters-alist'.
I have defcustom that runs indent-region on final html output. Here is
the relevant sections from org-e-html together with it's final section.
Adopt this example to e-latex case.
(defconst org-e-html-filters-alist
'((:filter-final-output . org-e-html-final-function))
"Alist between filters keywords and back-end specific filters.
See `org-export-filters-alist' for more information.")
(defun org-e-html-final-function (contents backend info)
(if (not org-e-html-pretty-output) contents
(with-temp-buffer
(nxml-mode)
(insert contents)
(indent-region (point-min) (point-max))
(buffer-substring-no-properties (point-min) (point-max)))))
(defcustom org-e-html-pretty-output nil
"Enable this to generate pretty HTML."
:group 'org-export-e-html
:type 'boolean)
> Cheers,
> Andreas
>
>
>
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: new LaTeX exporter hook
2012-05-23 11:30 ` Jambunathan K
@ 2012-05-23 12:32 ` Nicolas Goaziou
2012-05-23 21:36 ` Andreas Leha
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2012-05-23 12:32 UTC (permalink / raw)
To: Jambunathan K; +Cc: Andreas Leha, emacs-orgmode
Hello,
Jambunathan K <kjambunathan@gmail.com> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> the new LaTeX exporter does not seem to "run" the
>> org-export-latex-final-hook. Is there an equivalent?
>
> You are looking for `:filter-final-output' within
> `org-export-filters-alist'.
>
> I have defcustom that runs indent-region on final html output. Here is
> the relevant sections from org-e-html together with it's final section.
>
> Adopt this example to e-latex case.
>
> (defconst org-e-html-filters-alist
> '((:filter-final-output . org-e-html-final-function))
> "Alist between filters keywords and back-end specific filters.
> See `org-export-filters-alist' for more information.")
>
> (defun org-e-html-final-function (contents backend info)
> (if (not org-e-html-pretty-output) contents
> (with-temp-buffer
> (nxml-mode)
> (insert contents)
> (indent-region (point-min) (point-max))
> (buffer-substring-no-properties (point-min) (point-max)))))
>
> (defcustom org-e-html-pretty-output nil
> "Enable this to generate pretty HTML."
> :group 'org-export-e-html
> :type 'boolean)
Jambunathan is right. Though, for completeness, I'll add that, as an
end-user, you shouldn't mess with `org-e-html-filters-alist'. You can
add your filter to `org-export-filter-final-output-functions' instead.
Since this variable is back-end agnostic, your filter will probably have
to check the back-end first. Also, remember this is the functional
counterpart of hooks: the return value of your function will be used as
the new output. Thus, be sure it doesn't return nil.
Example follows:
#+begin_src emacs-lisp
(defun my-e-latex-final-filter (contents backend info)
(if (not (eq backend 'e-latex)) contents
...
modify contents
...
new-contents))
#+end_src
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: new LaTeX exporter hook
2012-05-23 12:32 ` Nicolas Goaziou
@ 2012-05-23 21:36 ` Andreas Leha
2012-07-06 8:01 ` Bastien
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Leha @ 2012-05-23 21:36 UTC (permalink / raw)
To: emacs-orgmode
Hi Jambunathan and Nicolas,
>>> the new LaTeX exporter does not seem to "run" the
>>> org-export-latex-final-hook. Is there an equivalent?
>>
>> You are looking for `:filter-final-output' within
>> `org-export-filters-alist'.
>>
[...]
>
> Example follows:
>
> #+begin_src emacs-lisp
> (defun my-e-latex-final-filter (contents backend info)
> (if (not (eq backend 'e-latex)) contents
> ...
> modify contents
> ...
> new-contents))
> #+end_src
>
Thank you for your input!
Works nicely now (even if the hook system was slightly easier to
use...).
Cheers,
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: new LaTeX exporter hook
2012-05-23 21:36 ` Andreas Leha
@ 2012-07-06 8:01 ` Bastien
2012-07-06 11:41 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2012-07-06 8:01 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Hi Jambunathan and Nicolas,
>
>
>>>> the new LaTeX exporter does not seem to "run" the
>>>> org-export-latex-final-hook. Is there an equivalent?
>>>
>>> You are looking for `:filter-final-output' within
>>> `org-export-filters-alist'.
Would that be useful to let the filters fall back on existing
value for ̀org-export-BACKEND-final-hook' and other hooks?
Thus people won't have to change their configuration, plus hooks
are more familiar to Emacsers.
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: new LaTeX exporter hook
2012-07-06 8:01 ` Bastien
@ 2012-07-06 11:41 ` Nicolas Goaziou
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2012-07-06 11:41 UTC (permalink / raw)
To: Bastien; +Cc: Andreas Leha, emacs-orgmode
Hello,
Bastien <bzg@gnu.org> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Jambunathan and Nicolas,
>>
>>
>>>>> the new LaTeX exporter does not seem to "run" the
>>>>> org-export-latex-final-hook. Is there an equivalent?
>>>>
>>>> You are looking for `:filter-final-output' within
>>>> `org-export-filters-alist'.
>
> Would that be useful to let the filters fall back on existing
> value for ̀org-export-BACKEND-final-hook' and other hooks?
I'm not sure to understand. There is no such hook. Also, there are
differences between filters and current export hooks:
- filters are applied on a string, current export hooks on a buffer;
- filters provide the back-end called, current export hooks rely on
a global variable that has been removed;
- While run with arguments, filters are not equivalent to
`run-hook-with-args' since they heavily rely on value returned;
- filters from users and from developers are clearly separated, which
allows the latter to always be executed before the former.
Now, as an exception, final output filters could be executed on a buffer
in a hook (by writing the string output to a temp buffer), but since
filters are so common in the new export engine, that extra step is
needed.
> Thus people won't have to change their configuration, plus hooks
> are more familiar to Emacsers.
(add-to-list 'org-export-filter-final-output-functions 'my-function)
vs
(org-add-hook 'org-export-final-output-hook 'my-function)
I'm not sure the difference is worth the hassle.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-07-06 11:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-23 8:33 new LaTeX exporter hook Andreas Leha
2012-05-23 11:30 ` Jambunathan K
2012-05-23 12:32 ` Nicolas Goaziou
2012-05-23 21:36 ` Andreas Leha
2012-07-06 8:01 ` Bastien
2012-07-06 11:41 ` 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).