Using elisp within gnu emacs, I'd like to be able to fill all text in the buffer except for text that is indicated with special identifiers. The identifers can be just about anything, but for the sake of this question, let's just assume that it's any text that falls between [nofill] and [/nofill] tags.
For example, assume that my buffer looks like this:
Now is the time
for all good
men to come to the aid
of their party. Now is
the time for all good
men to come to the aid
of their party.
[nofill]
The quick
brown fox
jumped over the
lazy sleeping dog
[/nofill]
When in the course of
human events, it becomes
it becomes necessary for one
people to dissolve the
political bands
[nofill]
baa-baa
black sheep,
have you
any wool
[/nofill]
After the kind of filling I'm looking for, I want the buffer to appear as follows:
Now is the time for all good men to come to the aid of their
party. Now is the time for all good me to come to the aid of
their party
[nofill]
The quick
brown fox
jumped over the
lazy sleeping dog
[/nofill]
When in the course of human events, it becomes it becomes
necessary for one people to dissolve the political bands
[nofill]
baa-baa
black sheep,
have you
any wool
[/nofill]
I know elisp and I could write something which does this. However, before I attempt to "reinvent the wheel", I'm wondering if anyone knows of any existing elisp modules which might already provide this functionality.
Thank you in advance.
You can just justify everything between [/nofill]
and [nofill]
(or possibly beginning/end of buffer).
(defun fill-special () "fill special"
(interactive)
(goto-char (point-min))
(while (< (point) (point-max))
(let ((start (point)))
(if (search-forward "[nofill]" nil 1)
(forward-line -1))
(fill-region start (point) 'left)
(if (search-forward "[/nofill]" nil 1)
(forward-line 1)))))