emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: [patch][ox-latex] context-aware subscript
Date: Sat, 31 Aug 2013 16:46:14 +0200	[thread overview]
Message-ID: <87y57hncjt.fsf@gmail.com> (raw)
In-Reply-To: <87ioymj705.fsf@gmx.us> (rasmus@gmx.us's message of "Sat, 31 Aug 2013 15:59:38 +0200")

Rasmus <rasmus@gmx.us> writes:

> What I do in the patch is that I apply the filters within the
> function

Why is that? `org-export-data' already takes care of filters. These
calls are redundant.

> Also, filters using a regexp with "\text{whatever}" wouldn't work.

I don't get it.

>>> +	(scripts '(subscript superscript)))
>>> +    (if (not (org-element-property :latex-math-p entity)) ent
>>> +      (concat
>>> +       (if (and no-pre-blanks-p
>>> +		(memq (org-element-type prev) scripts)
>>> +		(not (eq (org-export-data prev info) "")))
>>> +	   "" "$")
>>> +       ent
>>> +       (if (and no-post-blanks-p
>>> +		(memq (org-element-type next) scripts)
>>> +		(not (eq (org-export-data next info) "")))
>>> +	   "" "$")))))
>>
>> I think this is problematic: if an entity needs to export both the
>> previous and the next object, what happens when we have two consecutive
>> entities? An infloop?
>
> I agree, but I haven't been able to cause any nasty behavior. I've
> probably neglected some case.  These works fine
>
>   1. \alpha\beta_t : \alpha is not a subscript
>   2. \alpha\beta_\xi\nu : runs OK recursively.

There's still some infloop smell around this code. Perhaps with
something like the following (untested):

  A_b^c

> On 2.: on my system I've tried with many entities (around 500).  It
> works, but obviously it's slow due to the recursiveness.This is very
> nasty.  I don't know if some other mechanism can be derived, tho. . .

`org-export-data' caches its results, so calling it more than once on
the same object/element isn't really costly.

> +  (let* ((ent (org-element-property :latex entity))
> +	 (prev (org-export-get-previous-element entity info))
> +	 (next (org-export-get-next-element entity info))
> +	 (no-post-blanks-p (= (or (org-element-property :post-blank entity) 0) 0))

aka `zerop' (slightly easier to read).

> +	 (no-pre-blanks-p (= (or (org-element-property :post-blank prev) 0) 0))


Ditto.

> +	 (scripts '(subscript superscript)))
> +
> +    (if (not (org-element-property :latex-math-p entity)) ent
> +      (concat
> +       (if (and no-pre-blanks-p
> +		(memq (org-element-type prev) scripts)
> +		;; check if nil
> +		(org-export-data prev info))
> +	   "" "$")
> +       ent
> +       (if (and no-post-blanks-p
> +		(memq (org-element-type next) scripts)
> +		;; check if nil
> +		(org-export-data next info))

You don't need to check for nil. `org-export-data' returns nil when the
element or object is ignored. But `org-export-get-previous-element'
never returns ignored objects or elements.

> +	   (let ((out (or (org-export-filter-apply-functions
> +			   org-export-filter-subscript-functions
> +			   (org-export-data obj info)
> +			   info) "")))

See above.

Thanks again.


Regards,

-- 
Nicolas Goaziou

      reply	other threads:[~2013-08-31 14:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-18  1:29 [patch][ox-latex] context-aware subscript Rasmus
2013-08-19  8:26 ` Nicolas Goaziou
2013-08-28 11:55   ` Rasmus
2013-08-28 13:38     ` Nicolas Goaziou
2013-08-28 13:46       ` Rasmus
2013-08-28 19:21         ` Nicolas Goaziou
2013-08-29 10:50           ` Rasmus
2013-08-31  8:11             ` Nicolas Goaziou
2013-08-31 13:59               ` Rasmus
2013-08-31 14:46                 ` Nicolas Goaziou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y57hncjt.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).