[Top][All Lists]

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

Re: adaptive-fill-mode and auto-fill-mode

From: Stefan Monnier
Subject: Re: adaptive-fill-mode and auto-fill-mode
Date: Mon, 09 Oct 2006 20:32:40 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>>> !            (save-excursion
>>> !              (goto-char compos)
>>> !              ;; The comstart marker is the same.
>>> !              (and (looking-at comment-start-skip)
>>> !             (string-equal
>>> !              prefix-comstart
>>> !              (comment-string-strip (match-string 0) nil t))
>> AFAICT this is the only spot

> I also added arguments to the `string-match's, please check 'em.

I can't find any difference: I see 3 calls to string-match and they seem to
all be unchanged.  Oh I see, you meant match-string.  Thanks.

>> where you changed my suggested code.
>> What was the scenario where this change is needed?

> Scenarios where the stripped comment-start sequence is longer than the
> prefix.  Otherwise, with

> ;; x
> ;; x
> ;;; xxxxxx .....

> breaking the third comment would give something like

> ;; x
> ;; x
> ;;; xxxxxx .....
> ;; xxx

> and breaking the third comment in

> ;; x
> ;;; x
> ;;; xxxxxx .....

> something like

> ;; x
> ;;; x
> ;;; xxxxxx .....
> ;;xxxxxx

How serious are these?

>> BTW comment-start-skip can't be used like that in `looking-at' because it
>> may need to match some chars *before* the actual comment start.  This is
>> typically the case when it starts with
>> "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)" as in elisp.  So you need to
>> either narrow so as to pretend that compos is at BOL, or match from BOL and
>> prepend something like ".*".  Instead I just did (looking-at (regexp-quote
>> prefix-comstart)) which I thought should work just as well.

> The `looking-at' is a preparatory kludge to (a) make sure that we really
> are at a valid comment-start and (b) produce the match-string for the
> next conjunct.

I understand, but what I mean is that it may not do what you expect: e.g. it
may fail to match, even though you are indeed looking at a comment-starter.
The main problem with it, is that in modes where it fails, it'll tend to
fail every time :-(.
E.g. in elisp, go to the semi-colon in:

     (foo bar) ; Comment

and type M-: (looking-at-comment-start-skip) RET and you'll that it fails.
Luckily, the match succeeds (by accident) when you double the semi-colon.

> The real test is obviously the following `string-equal'
> (where I `comment-string-strip' trailing whitespace - newcomment.el is a
> pocketful of miracles).  I don't care about leading whitespace because
> compos is beyond that already.  Maybe you find a better solution.

Well, I prefer my (looking-at (regexp-quote prefix-comstart)), because even
though it's suboptimal, I believe that annoyance is small.  And it has the
benefit of being a lot simpler.

I installed the change.  Thanks for all your help,


reply via email to

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