emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Buffer-specific export filter?
@ 2013-08-20 11:45 James Harkins
  2013-08-20 13:02 ` Suvayu Ali
  0 siblings, 1 reply; 6+ messages in thread
From: James Harkins @ 2013-08-20 11:45 UTC (permalink / raw)
  To: orgmode

Is it possible to apply a specific filter during export for one org document, but not others?

Basically, a buffer-specific export filter.

It appears in the org manual that the hook needs to be added into e.g. org-export-filter-plain-text-functions, where it remains globally for the duration of the session. But I have a case here where I need a filter to work around a specific problem I'm having in one document, which isn't a problem in other documents, and I don't want the filter to interfere with the other documents.

Possible? I don't see any mention of it in the manual.

hjh

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

* Re: Buffer-specific export filter?
  2013-08-20 11:45 Buffer-specific export filter? James Harkins
@ 2013-08-20 13:02 ` Suvayu Ali
  2013-08-20 13:56   ` Eric Abrahamsen
  2013-08-21  1:27   ` James Harkins
  0 siblings, 2 replies; 6+ messages in thread
From: Suvayu Ali @ 2013-08-20 13:02 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Aug 20, 2013 at 07:45:11PM +0800, James Harkins wrote:
> Is it possible to apply a specific filter during export for one org document, but not others?
> 
> Basically, a buffer-specific export filter.
> 
> It appears in the org manual that the hook needs to be added into e.g. org-export-filter-plain-text-functions, where it remains globally for the duration of the session. But I have a case here where I need a filter to work around a specific problem I'm having in one document, which isn't a problem in other documents, and I don't want the filter to interfere with the other documents.
> 
> Possible? I don't see any mention of it in the manual.

Some thoughts:

1. Is it possible to set filters as buffer local?  Okay the help string
   says: "This variable may be risky if used as a file-local variable.",
   so I guess the answer is no.

2. Otherwise you could have used a lisp source block in the buffer.  You
   could still do that, just add a conditional that checks for the
   buffer name.  This way modifying a global filter would still affect
   current buffer export.

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Buffer-specific export filter?
  2013-08-20 13:02 ` Suvayu Ali
@ 2013-08-20 13:56   ` Eric Abrahamsen
  2013-08-21  1:27   ` James Harkins
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Abrahamsen @ 2013-08-20 13:56 UTC (permalink / raw)
  To: emacs-orgmode

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> On Tue, Aug 20, 2013 at 07:45:11PM +0800, James Harkins wrote:
>> Is it possible to apply a specific filter during export for one org document, but not others?
>> 
>> Basically, a buffer-specific export filter.
>> 
>> It appears in the org manual that the hook needs to be added into
>> e.g. org-export-filter-plain-text-functions, where it remains
>> globally for the duration of the session. But I have a case here
>> where I need a filter to work around a specific problem I'm having
>> in one document, which isn't a problem in other documents, and I
>> don't want the filter to interfere with the other documents.
>> 
>> Possible? I don't see any mention of it in the manual.
>
> Some thoughts:
>
> 1. Is it possible to set filters as buffer local?  Okay the help string
>    says: "This variable may be risky if used as a file-local variable.",
>    so I guess the answer is no.
>
> 2. Otherwise you could have used a lisp source block in the buffer.  You
>    could still do that, just add a conditional that checks for the
>    buffer name.  This way modifying a global filter would still affect
>    current buffer export.
>
> Hope this helps,

Two related thoughts I've had: 1) at some point it might be nice to
allow customization of the export options at the top of the export menu
(what currently allows for Body only/Visible only/etc), so that you
could add hooks or perhaps filters on a per-export basis. Also 2), it
could be nice to show, in the export dispatcher, which export hooks are
currently active. Filters, too, if that didn't turn out to be too much
real estate...

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

* Re: Buffer-specific export filter?
  2013-08-20 13:02 ` Suvayu Ali
  2013-08-20 13:56   ` Eric Abrahamsen
@ 2013-08-21  1:27   ` James Harkins
  2013-08-21  7:41     ` Nicolas Goaziou
  1 sibling, 1 reply; 6+ messages in thread
From: James Harkins @ 2013-08-21  1:27 UTC (permalink / raw)
  To: emacs-orgmode

Suvayu Ali <fatkasuvayu+linux <at> gmail.com> writes:

> 1. Is it possible to set filters as buffer local?  Okay the help string
>    says: "This variable may be risky if used as a file-local variable.",
>    so I guess the answer is no.
> 
> 2. Otherwise you could have used a lisp source block in the buffer.  You
>    could still do that, just add a conditional that checks for the
>    buffer name.  This way modifying a global filter would still affect
>    current buffer export.

I see... that seems awkward. Maybe a valid feature request.

But maybe there's a better solution for my specific case. The problem is
that I'm using the colloquial <<'em>> for "them." The preceding space causes
org to export this as `em. Normally a single quote after a space would
correctly be an opening single quote, but here it's for a contraction and
should be an apostrophe.

Possible solutions:

- Use a LaTeX \specialCharName, if it exists. I couldn't find anything like
this. All the LaTeX documentation says to use '.

- Hacky approach which I tried last night: Define a filter to turn "<>" into
a non-breaking space "~"; then org doesn't treat it as an opening single quote.

- Better approach which I just thought of: Define a filter recognizing
<<'em>> as a special case, which I could also extend for other special cases
later.

Related question: If I wanted to force a non-breaking space in LaTeX export,
how would I do that without a filter? ~ exports, reasonably, as \textasciitilde.

hjh

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

* Re: Buffer-specific export filter?
  2013-08-21  1:27   ` James Harkins
@ 2013-08-21  7:41     ` Nicolas Goaziou
  2013-08-21  9:45       ` James Harkins
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2013-08-21  7:41 UTC (permalink / raw)
  To: James Harkins; +Cc: emacs-orgmode

Hello,

James Harkins <jamshark70@gmail.com> writes:

> But maybe there's a better solution for my specific case. The problem is
> that I'm using the colloquial <<'em>> for "them." The preceding space causes
> org to export this as `em. Normally a single quote after a space would
> correctly be an opening single quote, but here it's for a contraction and
> should be an apostrophe.

In that case, you should disable smart quotes, which are not smart
enough for your use case. Note that they are not enabled by default.

> Related question: If I wanted to force a non-breaking space in LaTeX export,
> how would I do that without a filter? ~ exports, reasonably, as
> \textasciitilde.

Use \nbsp{} macro.


Regards,

-- 
Nicolas Goaziou

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

* Re: Buffer-specific export filter?
  2013-08-21  7:41     ` Nicolas Goaziou
@ 2013-08-21  9:45       ` James Harkins
  0 siblings, 0 replies; 6+ messages in thread
From: James Harkins @ 2013-08-21  9:45 UTC (permalink / raw)
  To: Nicolas Goaziou, Emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

On Aug 21, 2013 3:41 PM, "Nicolas Goaziou" <n.goaziou@gmail.com> wrote:
> In that case, you should disable smart quotes, which are not smart
> enough for your use case. Note that they are not enabled by default.

That's reasonable, but irritating while I'm still editing. I'm certain I'll
leave some ASCII double quotes in there by mistake. Should be easy enough
to handle as the last thing, using regexp replace.

> > Related question: If I wanted to force a non-breaking space in LaTeX
export,
> > how would I do that without a filter? ~ exports, reasonably, as
> > \textasciitilde.
>
> Use \nbsp{} macro.

Ok, thanks. And thanks also for the hint on the filter. I'm fairly new to
lisp (obviously). I know about functions' return values, just forgot here...

hjh

[-- Attachment #2: Type: text/html, Size: 982 bytes --]

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

end of thread, other threads:[~2013-08-21  9:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-20 11:45 Buffer-specific export filter? James Harkins
2013-08-20 13:02 ` Suvayu Ali
2013-08-20 13:56   ` Eric Abrahamsen
2013-08-21  1:27   ` James Harkins
2013-08-21  7:41     ` Nicolas Goaziou
2013-08-21  9:45       ` James Harkins

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