emacs-devel
[Top][All Lists]
Advanced

[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: Sat, 07 Oct 2006 12:22:49 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> *** newcomment.el.~1.96.~     Mon Aug 21 14:35:24 2006
> --- newcomment.el     Fri Oct  6 19:49:14 2006
> ***************
> *** 1182,1187 ****
> --- 1182,1202 ----
>        ;; If there's an adaptive prefix, use it unless we're inside
>        ;; a comment and the prefix is not a comment starter.
>        ((and fill-prefix
> +            ;; Don't use the adaptive prefix if we are not in a comment and
> +            ;; the adaptive prefix matches `comment-start'.
> +            (or compos (null comment-start)
> +                (not (string-match
> +                      (regexp-quote comment-start) fill-prefix)))

Why not use comment-start-skip instead?

> +            ;; Don't use the adaptive prefix if we are in an end-of-line
> +            ;; comment that doesn't start at the left margin or whose start
> +            ;; sequence doesn't match the prefix.
> +            (or (not compos) (not (string-equal comment-end ""))
> +                (and (<= compos
> +                         (+ (line-beginning-position 0)
> +                            (if (numberp left-margin) left-margin 0)))
> +                     (save-excursion
> +                       (goto-char compos)
> +                       (looking-at (regexp-quote fill-prefix)))))

I disagree with the "at left margin" thingy.  I'm not 100% sure what it's
trying to fix, tho, so please explain which scenario it fixes.

As for the rest of the code above, please merge it with the two subsequent
lines which already do something like that.  I.e. move the code to
comment-valid-prefix-p.

>              (or (not compos)
>                  (comment-valid-prefix-p fill-prefix compos)))

And finally, rather than having

   (and foo
        (or bar ...)
        (or (null bar) ...))

better use

   (and foo
        (if bar
            ...
          ...))

Also, please add a note that this is mostly trying to work around a bug in
auto-fill-mode where (for|back)ward-paragraph (used to find the relevant
boundaries of the paragraph, then used to find the adaptive prefix) doesn't
pay attention to comments.


        Stefan




reply via email to

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