From: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel@gnu.org
Subject: Re: adaptive-fill-mode and auto-fill-mode
Date: Sun, 08 Oct 2006 12:29:23 +0200 [thread overview]
Message-ID: <4528D303.3080903@gmx.at> (raw)
In-Reply-To: <jwvr6xjqwnf.fsf-monnier+emacs@gnu.org>
>>>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?
I removed the "at left margin" thingy. If you refer to the
(<= compos (line-beginning-position 0)
thingy then I need that to avoid the `indent-to-left-margin' in
`comment-indent-new-line' as in bug(2) of my first mail. If we agree to
use `indent-according-to-mode' here, that check is not needed. Note
that bug(2) is quite nasty since with longer defuns you usually won't
guess why it happened in the first place. And defuns preceded by two
";; " comment lines are quite frequent in the Elisp source.
>>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.
Suppose you write a long Elisp regexp that you don't want to break
before you finished writing. Auto fill will break it without mercy.
>>! ;; 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,
Indeed. The reason is that I don't want to affect multiline comment
environments when the comment starting at compos is a single line
comment. Hence I check whether this is a "single line environment" -
exemplified by `comment-end' equalling the empty string - and proceed
only in that case. If you think that multiline comment modes may be
affected as well ...
> 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.
Do you think my patch would be responsible for not handling these (at
line-beginning)? If the prefix passed to `comment-valid-prefix-p'
matches the string at compos there shouldn't be any problems. I think
the second example doesn't work because `fill-common-string-prefix'
determines the common prefix of ";; " and ";; > " as ";; " long before
I lay my hands at this.
> 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.
I don't quite follow you here. Where do you want to strip whitespace,
before the comment marker, between comment marker and body? Would it be
reliable to do that?
>>+ (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.
Personally, I don't care at all. My auto-fill-function uses syntax-ppss
and doesn't fill normal strings. But, as stated above, I don't think
that auto-fill should be allowed to break non-doc-strings in Elisp.
next prev parent reply other threads:[~2006-10-08 10:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-07 10:00 adaptive-fill-mode and auto-fill-mode martin rudalics
2006-10-07 16:22 ` Stefan Monnier
2006-10-07 18:43 ` martin rudalics
2006-10-08 4:29 ` Stefan Monnier
2006-10-08 10:29 ` martin rudalics [this message]
2006-10-08 16:21 ` Stefan Monnier
2006-10-08 19:03 ` martin rudalics
2006-10-09 1:37 ` Stefan Monnier
2006-10-09 12:35 ` martin rudalics
2006-10-09 16:45 ` Stefan Monnier
2006-10-09 21:04 ` martin rudalics
2006-10-10 0:32 ` Stefan Monnier
2006-10-08 4:30 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4528D303.3080903@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.