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: Sun, 08 Oct 2006 00:29:28 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>> 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.
> I agree with your disagreement.

I'm not sure what you mean: isn't the test still present in your
latest patch?

> BTW is the fill.el change harmless?  In my opinion the
> `fill-nobreak-predicate' stuff was broken.  Did anyone ever use that?

I think it doesn't matter either way.

> !   (if compos
> !       (and
> !        (or
> !     ;; Accept any prefix if the current comment is not EOL-terminated.
> !     (save-excursion (goto-char compos) (comment-forward) (not (bolp)))
> !     ;; Accept any prefix that starts with a comment-start marker.
> !     (string-match (concat "\\`[ \t]*\\(?:" comment-start-skip "\\)")
> !                   prefix))

OK.

> !        ;; Don't accept a prefix in an end-of-line comment that doesn't 
> start at
> !        ;; line beginning or whose start sequence doesn't match the prefix.
> !        ;; This should work around a bug where `do-auto-fill' determines the
> !        ;; prefix from the beginning of the paragraph but doesn't pay 
> attention
> !        ;; to comments.
> !        (or (not (string-equal comment-end ""))
> !        (and (<= compos (line-beginning-position 0))
> !             (save-excursion
> !               (goto-char compos)
> !               (looking-at (regexp-quote prefix))))))

I don't quite understand this.  I feel like this block repeats the previous
one.  I.e. the first part (comment-end check) seems like an inferior
alternative to the "comment-forward + not bolp" check above, and the second
part seems to be a stricter form of the second part above (it checks not
just that prefix matches comment-start-skip but that it specifically
matches the prefix used in the current comment).

Note that the stricter match is sometimes too strict.  I often have comments
where the adaptive-prefix correctly includes extra chars compared to the
initial comment start.  E.g.

        ;; - here is the beginning of the paragraph
        ;;   where the fill-prefix will include 3 spaces after ";;"
        ;;   even though the first line doesn't match it.

It could even be things like

        ;; foo wrote:
        ;; > where the fill-prefix will include 3 spaces after ";;"
        ;; > even though the first line doesn't match it.

I.e. we should probably use `comment-start-skip' on `prefix' to extract the
comment-marker part of the prefix, then strip whitespace, then check that
the same match&strip at compos returns the same thing.

> +   (set (make-local-variable 'fill-nobreak-predicate)
> +        ;; Try to avoid that auto-fill breaks strings.
> +        (lambda ()
> +      (and (eq (get-text-property (point) 'face)
> +               'font-lock-string-face)
> +           (or (= (point) (point-min))
> +               (eq (get-text-property (1- (point)) 'face)
> +                   'font-lock-string-face)))))

Do we really want that?  It seems at best to be a personal preference.


        Stefan




reply via email to

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