emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Trouble with autofill mode
@ 2015-08-02 18:54 Vikas Rawal
  2015-08-02 20:18 ` Nicolas Goaziou
  0 siblings, 1 reply; 15+ messages in thread
From: Vikas Rawal @ 2015-08-02 18:54 UTC (permalink / raw)
  To: org-mode mailing list

I am inserting LaTeX \index{} commands in an org document to create an index. Almost everything works fine. But I am having trouble with auto-fill-mode. It often puts a line break in the middle of an index entry, and then it does not work. 

That is, \index{my name} is sometimes broken into \index{my
name}. This creates a problem for LaTeX.

I have disabled auto-fill-mode for now, but that is clearly a sub-optimal thing to do. Is there a way to tell it not to put line breaks in the middle of \index{} entries?

Vikas

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

* Re: Trouble with autofill mode
  2015-08-02 18:54 Vikas Rawal
@ 2015-08-02 20:18 ` Nicolas Goaziou
  2015-08-03  0:05   ` Vikas Rawal
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Goaziou @ 2015-08-02 20:18 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: org-mode mailing list

Hello,

Vikas Rawal <vikaslists@agrarianresearch.org> writes:

> I am inserting LaTeX \index{} commands in an org document to create an
> index. Almost everything works fine. But I am having trouble with
> auto-fill-mode. It often puts a line break in the middle of an index
> entry, and then it does not work.
>
> That is, \index{my name} is sometimes broken into \index{my
> name}. This creates a problem for LaTeX.
>
> I have disabled auto-fill-mode for now, but that is clearly
> a sub-optimal thing to do. Is there a way to tell it not to put line
> breaks in the middle of \index{} entries?

Have you tried

 #+INDEX: my name

Regards,

-- 
Nicolas Goaziou

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

* Re: Trouble with autofill mode
  2015-08-02 20:18 ` Nicolas Goaziou
@ 2015-08-03  0:05   ` Vikas Rawal
  2015-08-04  1:12     ` Nick Dokos
  0 siblings, 1 reply; 15+ messages in thread
From: Vikas Rawal @ 2015-08-03  0:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode mailing list

> 
>> I am inserting LaTeX \index{} commands in an org document to create an
>> index. Almost everything works fine. But I am having trouble with
>> auto-fill-mode. It often puts a line break in the middle of an index
>> entry, and then it does not work.
>> 
>> That is, \index{my name} is sometimes broken into \index{my
>> name}. This creates a problem for LaTeX.
>> 
>> I have disabled auto-fill-mode for now, but that is clearly
>> a sub-optimal thing to do. Is there a way to tell it not to put line
>> breaks in the middle of \index{} entries?
> 
> Have you tried
> 
> #+INDEX: my name
> 
> Regards,
> 


I am sorry for not being clear. \index{} may have to be used inline in a para since the index has to pick up the right page where a term appears. So you want to put it as close as possible to the keywords.

Vikas

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

* Re: Trouble with autofill mode
@ 2015-08-03  3:07 Vicente Vera
  2015-08-03  3:12 ` Vikas Rawal
  0 siblings, 1 reply; 15+ messages in thread
From: Vicente Vera @ 2015-08-03  3:07 UTC (permalink / raw)
  To: vikaslists; +Cc: emacs-orgmode

Hello,
This StackExchange question might help you out:
https://emacs.stackexchange.com/questions/12392/prevent-fill-paragraph-from-breaking-latex-citations-in-org-mode
(Only if I got your question right...)

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

* Re: Trouble with autofill mode
  2015-08-03  3:07 Trouble with autofill mode Vicente Vera
@ 2015-08-03  3:12 ` Vikas Rawal
  2015-08-04  1:04   ` Vikas Rawal
  0 siblings, 1 reply; 15+ messages in thread
From: Vikas Rawal @ 2015-08-03  3:12 UTC (permalink / raw)
  To: Vicente Vera; +Cc: org-mode mailing list


> On 03-Aug-2015, at 8:37 am, Vicente Vera <vicentemvp@gmail.com> wrote:
> 
> Hello,
> This StackExchange question might help you out:
> https://emacs.stackexchange.com/questions/12392/prevent-fill-paragraph-from-breaking-latex-citations-in-org-mode
> (Only if I got your question right...)

Thanks very much. This should work. Let me try to modify it to my use case.

Much appreciated.

Vikas

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

* Re: Trouble with autofill mode
  2015-08-03  3:12 ` Vikas Rawal
@ 2015-08-04  1:04   ` Vikas Rawal
  2015-08-04 14:10     ` John Kitchin
  0 siblings, 1 reply; 15+ messages in thread
From: Vikas Rawal @ 2015-08-04  1:04 UTC (permalink / raw)
  To: Vicente Vera; +Cc: org-mode mailing list

>> 
>> Hello,
>> This StackExchange question might help you out:
>> https://emacs.stackexchange.com/questions/12392/prevent-fill-paragraph-from-breaking-latex-citations-in-org-mode
>> (Only if I got your question right...)
> 
> Thanks very much. This should work. Let me try to modify it to my use case.
> 
> Much appreciated.
> 

This is turning out to be non-trivial for my limited knowledge of regex. We need a regex that would return true for all white spaces between  "\index{" and “}" in a string like

\index{this is an index} and then some text \index(and then another index}

And then add-hook it to 'fill-nobreak-predicate.

Various things that I have tried since yesterday did not get me anywhere.

Vikas

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

* Re: Trouble with autofill mode
  2015-08-03  0:05   ` Vikas Rawal
@ 2015-08-04  1:12     ` Nick Dokos
  2015-08-04  3:11       ` Vikas Rawal
  0 siblings, 1 reply; 15+ messages in thread
From: Nick Dokos @ 2015-08-04  1:12 UTC (permalink / raw)
  To: emacs-orgmode

Vikas Rawal <vikaslists@agrarianresearch.org> writes:

>> 
>>> I am inserting LaTeX \index{} commands in an org document to create an
>>> index. Almost everything works fine. But I am having trouble with
>>> auto-fill-mode. It often puts a line break in the middle of an index
>>> entry, and then it does not work.
>>> 
>>> That is, \index{my name} is sometimes broken into \index{my
>>> name}. This creates a problem for LaTeX.
>>> 
>>> I have disabled auto-fill-mode for now, but that is clearly
>>> a sub-optimal thing to do. Is there a way to tell it not to put line
>>> breaks in the middle of \index{} entries?
>> 
>> Have you tried
>> 
>> #+INDEX: my name
>> 
>> Regards,
>> 
>
>
> I am sorry for not being clear. \index{} may have to be used inline in
> a para since the index has to pick up the right page where a term
> appears. So you want to put it as close as possible to the keywords.
>

So put it as close as possible to the keywords:

--8<---------------cut here---------------start------------->8---
This section needs to index some
#+INDEX: multi word term
multi word terms.
--8<---------------cut here---------------end--------------->8---

-- 
Nick

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

* Re: Trouble with autofill mode
  2015-08-04  1:12     ` Nick Dokos
@ 2015-08-04  3:11       ` Vikas Rawal
  2015-08-04  3:39         ` Ken Mankoff
  0 siblings, 1 reply; 15+ messages in thread
From: Vikas Rawal @ 2015-08-04  3:11 UTC (permalink / raw)
  To: Nick Dokos; +Cc: org-mode mailing list

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

>> 
>> 
>> I am sorry for not being clear. \index{} may have to be used inline in
>> a para since the index has to pick up the right page where a term
>> appears. So you want to put it as close as possible to the keywords.
>> 
> 
> So put it as close as possible to the keywords:
> 
> --8<---------------cut here---------------start------------->8---
> This section needs to index some
> #+INDEX: multi word term
> multi word terms.
> --8<---------------cut here---------------end--------------->8—
> 

Yes, I did not think one could put them in the middle of text like this. This should be fine except that having lots of these in the middle of paragraphs would make the text much more difficult to read. But I guess one has to have some compromise somewhere :)

Thanks and cheers.

Vikas



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

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

* Re: Trouble with autofill mode
  2015-08-04  3:11       ` Vikas Rawal
@ 2015-08-04  3:39         ` Ken Mankoff
  2015-08-04  4:22           ` Vikas Rawal
  0 siblings, 1 reply; 15+ messages in thread
From: Ken Mankoff @ 2015-08-04  3:39 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: Nick Dokos, org-mode mailing list


On 2015-08-03 at 23:11, Vikas Rawal <vikaslists@agrarianresearch.org> wrote:
> But I guess one has to have some compromise somewhere :)

Another compromise would be to stop using autofill mode and use visual-line-mode or something else. I recently made the switch after many years of auto-fill. It takes a bit of getting used to, but it works well.

  -k.

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

* Re: Trouble with autofill mode
  2015-08-04  3:39         ` Ken Mankoff
@ 2015-08-04  4:22           ` Vikas Rawal
  2015-08-04 12:47             ` John Kitchin
  2015-08-04 14:08             ` Eric S Fraga
  0 siblings, 2 replies; 15+ messages in thread
From: Vikas Rawal @ 2015-08-04  4:22 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Nick Dokos, org-mode mailing list

> 
> 
> On 2015-08-03 at 23:11, Vikas Rawal <vikaslists@agrarianresearch.org> wrote:
>> But I guess one has to have some compromise somewhere :)
> 
> Another compromise would be to stop using autofill mode and use visual-line-mode or something else. I recently made the switch after many years of auto-fill. It takes a bit of getting used to, but it works well.
> 
>  

Yes, I have been thinking about this too. visual-line-mode with each sentence in a separate line would have many other advantages too. It would perhaps be better for git-like version control of documents written in orgmode. Isn’t it?

Do others have an experience to share about this?

Vikas

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

* Re: Trouble with autofill mode
  2015-08-04  4:22           ` Vikas Rawal
@ 2015-08-04 12:47             ` John Kitchin
  2015-08-04 14:08             ` Eric S Fraga
  1 sibling, 0 replies; 15+ messages in thread
From: John Kitchin @ 2015-08-04 12:47 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: Nick Dokos, org-mode mailing list, Ken Mankoff

I turned off auto-fill everywhere many years ago (it messed up my code
blocks in org-mode too much. I usually write them in org-mode, not the
programming mode). I use (global-visual-line-mode 1)

I cannot think of any issues that causes. I even have an
unfill-paragraph to fix what my students do ;) I cannot say I seen many
advantages with git with this, but we usually have one paragraph on a
line.  One day I just need to learn how to do word-based diffs/merge for
text, instead of line-based.

The only exception to auto-fill i can think of is in mu4e, where emails to get filled
so they fit in about an 80 character field.

Vikas Rawal writes:

>>
>>
>> On 2015-08-03 at 23:11, Vikas Rawal <vikaslists@agrarianresearch.org> wrote:
>>> But I guess one has to have some compromise somewhere :)
>>
>> Another compromise would be to stop using autofill mode and use visual-line-mode or something else. I recently made the switch after many years of auto-fill. It takes a bit of getting used to, but it works well.
>>
>>
>
> Yes, I have been thinking about this too. visual-line-mode with each sentence in a separate line would have many other advantages too. It would perhaps be better for git-like version control of documents written in orgmode. Isn’t it?
>
> Do others have an experience to share about this?
>
> Vikas

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Trouble with autofill mode
  2015-08-04  4:22           ` Vikas Rawal
  2015-08-04 12:47             ` John Kitchin
@ 2015-08-04 14:08             ` Eric S Fraga
  2015-08-05  8:17               ` Sebastien Vauban
  1 sibling, 1 reply; 15+ messages in thread
From: Eric S Fraga @ 2015-08-04 14:08 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: org-mode mailing list

On Tuesday,  4 Aug 2015 at 09:52, Vikas Rawal wrote:

[...]

> Yes, I have been thinking about this too. visual-line-mode with each
> sentence in a separate line would have many other advantages too. It
> would perhaps be better for git-like version control of documents
> written in orgmode. Isn’t it?
>
> Do others have an experience to share about this?

For org documents, I switched to visual-line-mode and org-indent mode a
while back now after *years* using auto-fill.  Visual-line-mode without
org-indent is less æsthetically pleasing, I find.

I typically have one paragraph per line and this works well.  It may be
less efficient with respect to revision control, e.g. git, but the
efficiency loss is minimal in my opinion.

For LaTeX directives that I used to always put in #+latex: lines when I
needed these within a paragraph, I now increasingly use @@latex:...@@.

The only issue is working with wide tables.  For this, I do have a key
binding to toggle visual-line-mode on and off to make it easier to work
with tables.  It would be nice if somehow org knew not to allow
visual-line-mode to wrap tables but I would imagine this would be
difficult if not impossible.

For emails, I continue to use auto-fill-mode however.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3beta-1315-ga3b2b7

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

* Re: Trouble with autofill mode
  2015-08-04  1:04   ` Vikas Rawal
@ 2015-08-04 14:10     ` John Kitchin
  0 siblings, 0 replies; 15+ messages in thread
From: John Kitchin @ 2015-08-04 14:10 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: org-mode mailing list, Vicente Vera

I would have thought something like this would work:
(defun nobreak-p ()
  (interactive)
  (let ((result (if (and (looking-at " ")
                         (save-excursion
                           (re-search-forward "[^{]*}" (line-end-position) 'end))
                         (save-excursion
                           (re-search-backward "[^}]*\\\\index{" (line-beginning-position) 'end)))
                    t
                  nil)))
    (message "%s" result)
    result))

(add-hook 'fill-nobreak-predicate #'nobreak-p)

at least, from what I can see it returns true everywhere it should not
break, but I still get breaks where I do not want them. maybe it could
give you an idea though.

Vikas Rawal writes:

>>>
>>> Hello,
>>> This StackExchange question might help you out:
>>> https://emacs.stackexchange.com/questions/12392/prevent-fill-paragraph-from-breaking-latex-citations-in-org-mode
>>> (Only if I got your question right...)
>>
>> Thanks very much. This should work. Let me try to modify it to my use case.
>>
>> Much appreciated.
>>
>
> This is turning out to be non-trivial for my limited knowledge of regex. We need a regex that would return true for all white spaces between  "\index{" and “}" in a string like
>
> \index{this is an index} and then some text \index(and then another index}
>
> And then add-hook it to 'fill-nobreak-predicate.
>
> Various things that I have tried since yesterday did not get me anywhere.
>
> Vikas

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: Trouble with autofill mode
  2015-08-04 14:08             ` Eric S Fraga
@ 2015-08-05  8:17               ` Sebastien Vauban
  2015-08-05  9:31                 ` Eric S Fraga
  0 siblings, 1 reply; 15+ messages in thread
From: Sebastien Vauban @ 2015-08-05  8:17 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Eric S Fraga <e.fraga-hclig2XLE9Zaa/9Udqfwiw@public.gmane.org> writes:
> For LaTeX directives that I used to always put in #+latex: lines when
> I needed these within a paragraph, I now increasingly use
> @@latex:...@@.

FYI, you could make it smelt to just @@l:...@@ with:

--8<---------------cut here---------------start------------->8---
    (add-to-list 'org-export-snippet-translation-alist
                 '("l" . "latex"))
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Trouble with autofill mode
  2015-08-05  8:17               ` Sebastien Vauban
@ 2015-08-05  9:31                 ` Eric S Fraga
  0 siblings, 0 replies; 15+ messages in thread
From: Eric S Fraga @ 2015-08-05  9:31 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

On Wednesday,  5 Aug 2015 at 10:17, Sebastien Vauban wrote:
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>> For LaTeX directives that I used to always put in #+latex: lines when
>> I needed these within a paragraph, I now increasingly use
>> @@latex:...@@.
>
> FYI, you could make it smelt to just @@l:...@@ with:
>
>     (add-to-list 'org-export-snippet-translation-alist
>                  '("l" . "latex"))

Cute!  Org has something for everything. :-)  Thanks.

(mind you, pabbrev means that typing @@l TAB usually gives me what I want!)
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3beta-1315-ga3b2b7

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

end of thread, other threads:[~2015-08-05  9:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-03  3:07 Trouble with autofill mode Vicente Vera
2015-08-03  3:12 ` Vikas Rawal
2015-08-04  1:04   ` Vikas Rawal
2015-08-04 14:10     ` John Kitchin
  -- strict thread matches above, loose matches on Subject: below --
2015-08-02 18:54 Vikas Rawal
2015-08-02 20:18 ` Nicolas Goaziou
2015-08-03  0:05   ` Vikas Rawal
2015-08-04  1:12     ` Nick Dokos
2015-08-04  3:11       ` Vikas Rawal
2015-08-04  3:39         ` Ken Mankoff
2015-08-04  4:22           ` Vikas Rawal
2015-08-04 12:47             ` John Kitchin
2015-08-04 14:08             ` Eric S Fraga
2015-08-05  8:17               ` Sebastien Vauban
2015-08-05  9:31                 ` Eric S Fraga

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