From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Trouble with autofill mode Date: Tue, 04 Aug 2015 10:10:34 -0400 Message-ID: References: <3F46BC12-38CA-47D9-8300-ED3D3B036E8A@agrarianresearch.org> <1302C604-839A-467A-A734-E49F1C440E66@agrarianresearch.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMcvR-0000n0-Sf for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 10:10:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMcvN-0001uk-Tb for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 10:10:41 -0400 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]:33770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMcvN-0001uF-Om for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 10:10:37 -0400 Received: by qged69 with SMTP id d69so7147337qge.0 for ; Tue, 04 Aug 2015 07:10:37 -0700 (PDT) In-reply-to: <1302C604-839A-467A-A734-E49F1C440E66@agrarianresearch.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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-begi= nning-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 ca= se. >> >> 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 "\inde= x{" and =E2=80=9C}" 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