[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Trouble with autofill mode
From: |
John Kitchin |
Subject: |
Re: [O] Trouble with autofill mode |
Date: |
Tue, 04 Aug 2015 10:10:34 -0400 |
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
- Re: [O] Trouble with autofill mode, (continued)
- Re: [O] Trouble with autofill mode, Vikas Rawal, 2015/08/03
- Re: [O] Trouble with autofill mode, Ken Mankoff, 2015/08/03
- Re: [O] Trouble with autofill mode, Vikas Rawal, 2015/08/04
- Re: [O] Trouble with autofill mode, John Kitchin, 2015/08/04
- Re: [O] Trouble with autofill mode, Eric S Fraga, 2015/08/04
- Re: [O] Trouble with autofill mode, Sebastien Vauban, 2015/08/05
- Re: [O] Trouble with autofill mode, Eric S Fraga, 2015/08/05
Re: [O] Trouble with autofill mode, Vicente Vera, 2015/08/02