emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* fill-paragraph: wrong behaviour after latex-environments
@ 2012-05-03 12:57 Benjamin Motz
  2012-05-03 15:05 ` Albert Z. Wang
  2012-05-05  6:39 ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Motz @ 2012-05-03 12:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

invoking fill-paragraph on the following org-code will delete the
newline after \end{equation}:

The relation
\begin{equation}
E=mc^2
\end{equation}
won't be further discussed here.

This behaviour is undesirable because it makes the org-text less
readable. Also, when adding '%' after \end{equation}, newline is still
being deleted by fill-paragraph (and the text after '%' won't be
exported e.g. by latex-export).

Is there a workaround or can someone point me to the location where I
can fix/change this behaviour?

Thanks, Benjamin

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

* Re: fill-paragraph: wrong behaviour after latex-environments
  2012-05-03 12:57 fill-paragraph: wrong behaviour after latex-environments Benjamin Motz
@ 2012-05-03 15:05 ` Albert Z. Wang
  2012-05-03 15:23   ` Benjamin Motz
  2012-05-05  6:39 ` Bastien
  1 sibling, 1 reply; 5+ messages in thread
From: Albert Z. Wang @ 2012-05-03 15:05 UTC (permalink / raw)
  To: emacs-orgmode

Benjamin Motz <b.motz@uni-muenster.de> writes:

> Hi,
>
> invoking fill-paragraph on the following org-code will delete the
> newline after \end{equation}:
>
> The relation
> \begin{equation}
> E=mc^2
> \end{equation}
> won't be further discussed here.
>
> This behaviour is undesirable because it makes the org-text less
> readable. Also, when adding '%' after \end{equation}, newline is still
> being deleted by fill-paragraph (and the text after '%' won't be
> exported e.g. by latex-export).
>
> Is there a workaround or can someone point me to the location where I
> can fix/change this behaviour?
>
> Thanks, Benjamin

I had the same issue; fixed it by adding the following org-mode-hook:

(add-hook 'org-mode-hook 
	  (lambda ()
	    ;; don't rewrap display equations into paragraphs
	    (setq paragraph-separate 
		  (concat "[\\f \\t]*\\(\\\\begin{\\|\\\\end{\\|\\\\\\[\\|\\\\\\]\\)\\|"
			  paragraph-separate))
	    ))))

This sets several new paragraph boundary markers to prevent wrapping
them into paragraphs: \begin{, \end{, and the unnumbered display
equation shortcut \[, \].

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

* Re: fill-paragraph: wrong behaviour after latex-environments
  2012-05-03 15:05 ` Albert Z. Wang
@ 2012-05-03 15:23   ` Benjamin Motz
  0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Motz @ 2012-05-03 15:23 UTC (permalink / raw)
  To: emacs-orgmode

azw@fastmail.fm (Albert Z. Wang) writes:

[...]
> This sets several new paragraph boundary markers to prevent wrapping
> them into paragraphs: \begin{, \end{, and the unnumbered display
> equation shortcut \[, \].

Thank you, that did the trick!

Shouldn't that be the default behaviour, i.e. should this be
considered a bug?

Benjamin

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

* Re: fill-paragraph: wrong behaviour after latex-environments
  2012-05-03 12:57 fill-paragraph: wrong behaviour after latex-environments Benjamin Motz
  2012-05-03 15:05 ` Albert Z. Wang
@ 2012-05-05  6:39 ` Bastien
  2012-05-05 16:13   ` Nicolas Goaziou
  1 sibling, 1 reply; 5+ messages in thread
From: Bastien @ 2012-05-05  6:39 UTC (permalink / raw)
  To: Benjamin Motz; +Cc: n.goaziou, emacs-orgmode

Hi Benjamin,

Benjamin Motz <b.motz@uni-muenster.de> writes:

> invoking fill-paragraph on the following org-code will delete the
> newline after \end{equation}:
>
> The relation
> \begin{equation}
> E=mc^2
> \end{equation}
> won't be further discussed here.
>
> This behaviour is undesirable because it makes the org-text less
> readable. Also, when adding '%' after \end{equation}, newline is still
> being deleted by fill-paragraph (and the text after '%' won't be
> exported e.g. by latex-export).

There is `org-element-paragraph-separate', which already uses a 
better `paragraph-separate' value than the one currently in Org.

Nicolas, do you think the default value for `paragraph-separate' 
in Org could use ̀org-element-paragraph-separate' in a way?

How does org-element.el handles inline LaTeX code like the one 
Benjamin showed?

Thanks,

-- 
 Bastien

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

* Re: fill-paragraph: wrong behaviour after latex-environments
  2012-05-05  6:39 ` Bastien
@ 2012-05-05 16:13   ` Nicolas Goaziou
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2012-05-05 16:13 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Benjamin Motz

Hello,

Bastien <bzg@gnu.org> writes:

> Benjamin Motz <b.motz@uni-muenster.de> writes:
>
>> invoking fill-paragraph on the following org-code will delete the
>> newline after \end{equation}:
>>
>> The relation
>> \begin{equation}
>> E=mc^2
>> \end{equation}
>> won't be further discussed here.
>>
>> This behaviour is undesirable because it makes the org-text less
>> readable. Also, when adding '%' after \end{equation}, newline is still
>> being deleted by fill-paragraph (and the text after '%' won't be
>> exported e.g. by latex-export).
>
> There is `org-element-paragraph-separate', which already uses a 
> better `paragraph-separate' value than the one currently in Org.
>
> Nicolas, do you think the default value for `paragraph-separate' 
> in Org could use ̀org-element-paragraph-separate' in a way?
>
> How does org-element.el handles inline LaTeX code like the one 
> Benjamin showed?

org-element now provides a filling function for elements
(org-element-fill-paragraph) which doesn't rely on `paragraph-separate'
value. It needs testing, but it should do the right thing in most, if
not all, cases.

You can still use `org-element-paragraph-separate' as a value for
`paragraph-separate' (provided all carets are removed first), but
I don't think that would be useful.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2012-05-05 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-03 12:57 fill-paragraph: wrong behaviour after latex-environments Benjamin Motz
2012-05-03 15:05 ` Albert Z. Wang
2012-05-03 15:23   ` Benjamin Motz
2012-05-05  6:39 ` Bastien
2012-05-05 16:13   ` 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).