emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Vikas Rawal <vikaslists@agrarianresearch.org>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>,
	Vicente Vera <vicentemvp@gmail.com>
Subject: Re: Trouble with autofill mode
Date: Tue, 04 Aug 2015 10:10:34 -0400	[thread overview]
Message-ID: <m2lhdr6t5x.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <1302C604-839A-467A-A734-E49F1C440E66@agrarianresearch.org>

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

  reply	other threads:[~2015-08-04 14:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
  -- 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2lhdr6t5x.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=vicentemvp@gmail.com \
    --cc=vikaslists@agrarianresearch.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).