[Top][All Lists]

[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 ()
  (let ((result (if (and (looking-at " ")
                           (re-search-forward "[^{]*}" (line-end-position) 
                           (re-search-backward "[^}]*\\\\index{" 
(line-beginning-position) 'end)))
    (message "%s" 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]