[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error with fill-paragraph in my own major mode

From: Stefan Kamphausen
Subject: Error with fill-paragraph in my own major mode
Date: Wed, 30 Jan 2008 17:41:52 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)


a good while back (actually I started this in 2004) I wrote a major
mode to write articles for the (German) linux magazin ([1]).  This
major mode can be found on my website at

Today it has been brought to my attention that there is an error when
one tries to fill a paragraph (M-q) using that major mode in Gnu Emacs
22.  Back then I wrote that mode in XEmacs, today I seem to be a Gnu
Emacs user so I'd like to fix that issue.

Hitting M-q leads to an error
Args out of range: "", -1, 0

Using debug-on-error and edebug I could track that error down to the
following code in function fill-comment-paragraph in fill.el:

  (if (string-match comment-start-skip (concat "\0" commark "a"))
      (concat "[ \t]*" (regexp-quote commark)
              ;; Make sure we only match comments that
              ;; use the exact same comment marker.
              "[^" (substring commark -1) "]")

I tried to understand the workings there but to no avail and I would
appreciate any pointers to what I may be doing wrong in my major mode.

To reproduce:

* emacs -q
* Load linmag-mode.el (M-x load-file)
* Save the sample article from below ([2]) in a file with suffix
* Open the file, the buffer should be in linmag-mode.
* Move to the lorem ispum text
* Hit M-q.
* Voila.


     The format is described (in German) on

[2]  Sample article text:
@#: ==================================================================
@#: ==                              HEAD                            ==
@#: ==================================================================
@R:Sample Rubric

@T:This is the Title

@V: This is the lead text, kind of a teaser.
@A: The Author

@#: ==================================================================
@#:                                TEXT                             ==
@#: ==================================================================

@L: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris
non eros. Phasellus mattis. Nunc libero enim, condimentum non, mollis
vitae, facilisis in, urna. Vivamus sit amet sem vitae est tempor
imperdiet. Cras quam odio, fermentum condimentum, sodales ac,
facilisis quis, odio. Etiam cursus sem ac lacus. Vestibulum lobortis,
nulla id pellentesque pharetra, sapien nunc commodo leo, eget
fermentum odio orci non leo. Sed dictum, nisi sit amet mattis
ullamcorper, eros elit lobortis purus, ut blandit tortor lacus ut
orci. Mauris tincidunt metus at purus. Quisque commodo. Aliquam magna
sapien, rutrum sit amet, interdum ut, vehicula id, orci. 

Stefan Kamphausen ---
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.

reply via email to

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