unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Andreas Röhler" <andreas.roehler@online.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Error with fill-paragraph in my own major mode
Date: Wed, 30 Jan 2008 22:15:42 +0100	[thread overview]
Message-ID: <200801302215.43903.andreas.roehler@online.de> (raw)
In-Reply-To: <85y7a7l0z3.fsf@usenet.my.skamphausen.de>

Am Mittwoch, 30. Januar 2008 17:41 schrieb Stefan Kamphausen:
> Hi,
>
> 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
>
> http://www.skamphausen.de/cgi-bin/ska/linmag-mode
>
> 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
>   .linmag
> * Open the file, the buffer should be in linmag-mode.
> * Move to the lorem ispum text
> * Hit M-q.
> * Voila.
>
>
>
> Regards,
> stefan
>
...


Seems a clash with your comment-start setting.

Error occurs if form in line 871 from
`fill-comment-paragraph'

         "[^" (substring commark -1) "]")

is called.

A comment there says

,----
| 
|  The specialized regexp only works for "normal" comment
|               ;; syntax, not for Texinfo's "@c" (w
`----



BTW, when substring's `from' was set to 0, filling
worked. However, didn't check the results further,
other nasty things may happen than.

Andreas Röhler

  reply	other threads:[~2008-01-30 21:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-30 16:41 Error with fill-paragraph in my own major mode Stefan Kamphausen
2008-01-30 21:15 ` Andreas Röhler [this message]
2008-01-30 21:49 ` Stefan Monnier
2008-01-31  8:36   ` Stefan Kamphausen
2008-01-31 15:25     ` Stefan Monnier
2008-01-31 15:58       ` Stefan Kamphausen
2008-01-31 19:57         ` Stefan Monnier

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.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=200801302215.43903.andreas.roehler@online.de \
    --to=andreas.roehler@online.de \
    --cc=help-gnu-emacs@gnu.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.
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).