* verbatim/code text and line breaks with auto fill mode
@ 2014-03-07 10:45 Alan Schmitt
2014-03-07 20:50 ` Nick Dokos
0 siblings, 1 reply; 13+ messages in thread
From: Alan Schmitt @ 2014-03-07 10:45 UTC (permalink / raw)
To: emacs-orgmode
Hello,
Is there a way to disable line breaks inside verbatim or code text when
using auto fill? For instance, if I type the following:
--8<---------------cut here---------------start------------->8---
This is an example of a long line when some stuff is code: ~1 + 2 + 3 =
6~.
--8<---------------cut here---------------end--------------->8---
The problem is that when exporting to latex, I get something that is not
correct (I'm only putting the relevant part of the exported file):
--8<---------------cut here---------------start------------->8---
This is an example of a long line when some stuff is code: \verb~1 + 2 + 3 =
6~.
--8<---------------cut here---------------end--------------->8---
Indeed compilation fails:
,----
| ! LaTeX Error: \verb ended by end of line.
|
| See the LaTeX manual or LaTeX Companion for explanation.
| Type H <return> for immediate help.
| ...
|
| l.31 ...when some stuff is code: \verb~1 + 2 + 3 =
`----
Thanks,
Alan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-07 10:45 verbatim/code text and line breaks with auto fill mode Alan Schmitt
@ 2014-03-07 20:50 ` Nick Dokos
2014-03-08 7:58 ` Alan Schmitt
2014-03-08 12:12 ` Alan Schmitt
0 siblings, 2 replies; 13+ messages in thread
From: Nick Dokos @ 2014-03-07 20:50 UTC (permalink / raw)
To: emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hello,
>
> Is there a way to disable line breaks inside verbatim or code text when
> using auto fill? For instance, if I type the following:
>
> This is an example of a long line when some stuff is code: ~1 + 2 + 3 =
> 6~.
>
Untested, but you might be able to do something with
auto-fill-inhibit-regexp.
Nick
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-07 20:50 ` Nick Dokos
@ 2014-03-08 7:58 ` Alan Schmitt
2014-03-08 12:12 ` Alan Schmitt
1 sibling, 0 replies; 13+ messages in thread
From: Alan Schmitt @ 2014-03-08 7:58 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
Nick Dokos <ndokos@gmail.com> writes:
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Hello,
>>
>> Is there a way to disable line breaks inside verbatim or code text when
>> using auto fill? For instance, if I type the following:
>>
>> This is an example of a long line when some stuff is code: ~1 + 2 + 3 =
>> 6~.
>>
>
> Untested, but you might be able to do something with
> auto-fill-inhibit-regexp.
Ah, thanks for the suggestion, I'll give it a try.
Alan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-07 20:50 ` Nick Dokos
2014-03-08 7:58 ` Alan Schmitt
@ 2014-03-08 12:12 ` Alan Schmitt
2014-03-10 11:09 ` Sebastien Vauban
2014-03-18 22:35 ` R. Michael Weylandt <michael.weylandt@gmail.com>
1 sibling, 2 replies; 13+ messages in thread
From: Alan Schmitt @ 2014-03-08 12:12 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
Nick Dokos <ndokos@gmail.com> writes:
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Hello,
>>
>> Is there a way to disable line breaks inside verbatim or code text when
>> using auto fill? For instance, if I type the following:
>>
>> This is an example of a long line when some stuff is code: ~1 + 2 + 3 =
>> 6~.
>>
>
> Untested, but you might be able to do something with
> auto-fill-inhibit-regexp.
I've continued looking into this, and it seems that what I want is use
`fill-nobreak-predicate'. This is what I ended up doing:
#+begin_src emacs-lisp
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'fill-nobreak-predicate 'org-in-verbatim-emphasis)))
#+end_src
All the pieces were already there, it just took me a while to put them
together ;-)
Best,
Alan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-08 12:12 ` Alan Schmitt
@ 2014-03-10 11:09 ` Sebastien Vauban
2014-03-10 12:13 ` Nicolas Goaziou
2014-03-18 22:35 ` R. Michael Weylandt <michael.weylandt@gmail.com>
1 sibling, 1 reply; 13+ messages in thread
From: Sebastien Vauban @ 2014-03-10 11:09 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Alan Schmitt wrote:
> I've continued looking into this, and it seems that what I want is use
> `fill-nobreak-predicate'. This is what I ended up doing:
>
> #+begin_src emacs-lisp
> (add-hook 'org-mode-hook
> (lambda ()
> (add-hook 'fill-nobreak-predicate 'org-in-verbatim-emphasis)))
> #+end_src
>
> All the pieces were already there, it just took me a while to put them
> together ;-)
Shouldn't this be standard in Org, as it breaks LaTeX compilation otherwise?
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-10 11:09 ` Sebastien Vauban
@ 2014-03-10 12:13 ` Nicolas Goaziou
2014-03-13 13:54 ` Bastien
0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2014-03-10 12:13 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ
Hello,
Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:
> Alan Schmitt wrote:
>> I've continued looking into this, and it seems that what I want is use
>> `fill-nobreak-predicate'. This is what I ended up doing:
>>
>> #+begin_src emacs-lisp
>> (add-hook 'org-mode-hook
>> (lambda ()
>> (add-hook 'fill-nobreak-predicate 'org-in-verbatim-emphasis)))
>> #+end_src
>>
>> All the pieces were already there, it just took me a while to put them
>> together ;-)
>
> Shouldn't this be standard in Org, as it breaks LaTeX compilation
> otherwise?
This is not an Org problem, as verbatim objects can span over lines.
OTOH, `latex' back-end could remove newline characters from verbatim and
code contents.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-10 12:13 ` Nicolas Goaziou
@ 2014-03-13 13:54 ` Bastien
2014-03-13 23:02 ` Nicolas Goaziou
0 siblings, 1 reply; 13+ messages in thread
From: Bastien @ 2014-03-13 13:54 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: public-emacs-orgmode-mXXj517/zsQ, Sebastien Vauban
Hi Nicolas,
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> OTOH, `latex' back-end could remove newline characters from verbatim and
> code contents.
Is it only for the LaTeX backend?
Or something we can add to `org-export-before-processing-hook'.
In any case, yes, would be great if you could fix this somehow.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-13 13:54 ` Bastien
@ 2014-03-13 23:02 ` Nicolas Goaziou
[not found] ` <m2vbvhng0o.fsf@polytechnique.org>
2014-03-21 8:57 ` Bastien
0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2014-03-13 23:02 UTC (permalink / raw)
To: Bastien; +Cc: public-emacs-orgmode-mXXj517/zsQ, Sebastien Vauban
Hello,
Bastien <bzg@gnu.org> writes:
> Hi Nicolas,
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> OTOH, `latex' back-end could remove newline characters from verbatim and
>> code contents.
>
> Is it only for the LaTeX backend?
No idea.
> Or something we can add to `org-export-before-processing-hook'.
Hook are usually for user consumption. There is probably a better way to
handle it.
> In any case, yes, would be great if you could fix this somehow.
We first need to know what is the problem. Does Org allow newline
characters in verbatim objects? If it does, what backends do not support
it?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <m2vbvhng0o.fsf@polytechnique.org>]
* Re: verbatim/code text and line breaks with auto fill mode
[not found] ` <m2vbvhng0o.fsf@polytechnique.org>
@ 2014-03-14 12:19 ` Alan Schmitt
0 siblings, 0 replies; 13+ messages in thread
From: Alan Schmitt @ 2014-03-14 12:19 UTC (permalink / raw)
To: emacs-orgmode
I'm resending this to the list (somehow it was addressed to gmane
instead of the list.)
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> Does Org allow newline characters in verbatim objects?
>
> If I understand org-emphasis-regexp-components correctly, it explicitly
> allows newlines (the default seems to be 1):
>
> "newline The maximum number of newlines allowed in an emphasis exp."
>
> Moreover, my understanding of verbatim objects is an emphasis object
> that starts with '=' or '~' (if I read the code for `org-set-emph-re'
> correctly).
>
>> If it does, what backends do not support it?
>
> I only know of LaTeX.
>
>
> Alan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-13 23:02 ` Nicolas Goaziou
[not found] ` <m2vbvhng0o.fsf@polytechnique.org>
@ 2014-03-21 8:57 ` Bastien
[not found] ` <m2k3bnvp8p.fsf@polytechnique.org>
1 sibling, 1 reply; 13+ messages in thread
From: Bastien @ 2014-03-21 8:57 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: public-emacs-orgmode-mXXj517/zsQ, Sebastien Vauban
Hi Nicolas and Alan,
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> We first need to know what is the problem. Does Org allow newline
> characters in verbatim objects?
I'd say it should, yes. Otherwise it creates an exception that is
hard to justify, since this exception is linked to only one export
backend.
> If it does, what backends do not support it?
Only the LaTeX backend.
I fixed this by replacing newlines characters with whitespace
characters in \verb constructs for the LaTeX backend.
--
Bastien
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-08 12:12 ` Alan Schmitt
2014-03-10 11:09 ` Sebastien Vauban
@ 2014-03-18 22:35 ` R. Michael Weylandt <michael.weylandt@gmail.com>
2014-03-24 20:47 ` Michael Weylandt
1 sibling, 1 reply; 13+ messages in thread
From: R. Michael Weylandt <michael.weylandt@gmail.com> @ 2014-03-18 22:35 UTC (permalink / raw)
To: Alan Schmitt; +Cc: Nick Dokos, emacs-orgmode@gnu.org
On Mar 8, 2014, at 7:12, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
> Nick Dokos <ndokos@gmail.com> writes:
>
>> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>>
>>> Hello,
>>>
>>> Is there a way to disable line breaks inside verbatim or code text when
>>> using auto fill? For instance, if I type the following:
>>>
>>> This is an example of a long line when some stuff is code: ~1 + 2 + 3 =
>>> 6~.
>>
>> Untested, but you might be able to do something with
>> auto-fill-inhibit-regexp.
>
> I've continued looking into this, and it seems that what I want is use
> `fill-nobreak-predicate'. This is what I ended up doing:
>
> #+begin_src emacs-lisp
> (add-hook 'org-mode-hook
> (lambda ()
> (add-hook 'fill-nobreak-predicate 'org-in-verbatim-emphasis)))
> #+end_src
>
Is there an analogue like org-in-inline-src-p? I find the auto-fill breaks inline (src_python{.......}) blocks.
E.g.,
src_python{ 1 + 2 + 3 }
works (is recognized as evaluate-able code) while
src_python{1 + 2
+3}
doesn't.
Michael
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: verbatim/code text and line breaks with auto fill mode
2014-03-18 22:35 ` R. Michael Weylandt <michael.weylandt@gmail.com>
@ 2014-03-24 20:47 ` Michael Weylandt
0 siblings, 0 replies; 13+ messages in thread
From: Michael Weylandt @ 2014-03-24 20:47 UTC (permalink / raw)
To: emacs-orgmode
On Mar 18, 2014, at 18:35, "Michael Weylandt" <michael.weylandt@gmail.com> wrote:
>
> On Mar 8, 2014, at 7:12, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
>>
>> I've continued looking into this, and it seems that what I want is use
>> `fill-nobreak-predicate'. This is what I ended up doing:
>>
>> #+begin_src emacs-lisp
>> (add-hook 'org-mode-hook
>> (lambda ()
>> (add-hook 'fill-nobreak-predicate 'org-in-verbatim-emphasis)))
>> #+end_src
>
> Is there an analogue like org-in-inline-src-p? I find the auto-fill breaks inline (src_python{.......})
There doesn't appear to be a native org version, but I've used
(defun org-in-inline-src-p ()
(org-in-regexp org-babel-inline-src-block-regexp))
(add-hook 'org-mode-hook
(lambda () (add-hook 'fill-nobreak-predicate 'org-in-inline-src-p)))
And it seems to give a better auto-fill experience.
Michael
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-03-24 20:48 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 10:45 verbatim/code text and line breaks with auto fill mode Alan Schmitt
2014-03-07 20:50 ` Nick Dokos
2014-03-08 7:58 ` Alan Schmitt
2014-03-08 12:12 ` Alan Schmitt
2014-03-10 11:09 ` Sebastien Vauban
2014-03-10 12:13 ` Nicolas Goaziou
2014-03-13 13:54 ` Bastien
2014-03-13 23:02 ` Nicolas Goaziou
[not found] ` <m2vbvhng0o.fsf@polytechnique.org>
2014-03-14 12:19 ` Alan Schmitt
2014-03-21 8:57 ` Bastien
[not found] ` <m2k3bnvp8p.fsf@polytechnique.org>
2014-03-21 10:57 ` Alan Schmitt
2014-03-18 22:35 ` R. Michael Weylandt <michael.weylandt@gmail.com>
2014-03-24 20:47 ` Michael Weylandt
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).