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: martin rudalics
Subject: Re: adaptive-fill-mode and auto-fill-mode
Date: Mon, 09 Oct 2006 23:04:18 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

>>>>I fail to understand you here.  If the comment at compos doesn't match
>>>>the prefix why should I want to insert the prefix on the next line?
>>>
>>>Why not?
>
>
>>Your own patch might impede you.  If you manually change the
>>comment-start sequence at compos or the whitespace preceding it, the
>>prefix won't match the comment at compos any more and hence won't be
>>used.
>
>
> I'm not sure what you're referring to.  Of course, if the comment-start is
> different, I want to reject the prefix, and if the leading whitespace is of
> different length, I also want to reject it.  Both of these are pretty clear
> signs that the prefix was built from some other unrelated comment.
> Of course, one can never be sure, but one has to guess.

You said it all here.  If the stripped comment-start doesn't match the
prefix it will be rejected, as in your patch.

>>!            (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.

> 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

> 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.  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.





reply via email to

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