Subject: bug#1756: awk-mode: An empty line is not a paragraph separator (should be)

From: Alan Mackenzie <[email-masked]>
Date: Tue, 6 Jan 2009 16:15:41 +0000

Hi, Teemu!

On Mon, Jan 05, 2009 at 08:38:05PM +0200, Teemu Likonen wrote:
> Alan Mackenzie (2009-01-05 18:35 +0000) wrote:

> > Can you give me precise recipe to reproduce this, please.  It worked OK
> > for me when I tried it.  When I did the following:
> >
> > (i) M-: (setcdr (cadr c-comment-prefix-regexp) "#*") ; Changes the entry
> >           ; from (awk . "#+") to (awk . "#*")
> > (ii) C-c . <CR> awk  ; from within an AWK buffer
>
> I have your previous patch applied so there is this additional
> subexpression level "\(...\)?" too. >
> > , M-: paragraph-start gave me "[ \t]*\\(#*\\)[ \t]*$\\|^\f"
> >                                         ^^
> > which has incorporated the new value from c-comment-prefix-regexp.

> I can reproduce it by setting c-comment-prefix-regexp through the
> customize system:

>     M-x customize-option RET c-comment-prefix-regexp RET

> Select "Override style settings" and "Mode-specific regexps". Type #* to
> the AWK string and save the settings. Now, when I do "M-x awk-mode" I
> get this paragraph-start:

>     "[ \t]*\\(#*\\)[ \t]*$\\|^\f"
                ^^

Which is expected and correct - the awk bit of the global value of
c-comment-prefix-regexp, "#*", has been incorporated into
paragraph-start.

> After "C-c . awk RET" it changes to this:

>     "[ \t]*\\(\\(#+\\)[ \t]*\\)?$\\|^\f"
                   ^^

> Even though I chose to override the style settings "#*" changes to "#+".

I don't think this is a bug.  You asked for "awk" style to be set on the
buffer, and this is exactly what you got.  Customizing
c-comment-prefix-regexp has set the global value of this variable (which
was previously the symbol 'set-from-style); it hasn't changed the value
in any style.

I agree this is confusing, very confusing, and would very much like to
make it less confusing.  I am guessing that the cause is in the fine CC
Mode manual, page "Config Basics", in this bit:

    If you make conflicting settings in several of these ways, the way
    that takes precedence is the one that appears latest in this list:

        Style
        Top-level command or "customization interface"
        Hook
        File Style

This sentence only applies when initialising the mode, so perhaps it
would be better if amended something like this:

    When you initialize the buffer, the settings are made in the
    following order.  So if you make conflicting settings in several of
    these ways, the way that takes precedence is the one that appears
    latest in the list(2):

        Style
        Top-level command or "customization interface"
        Hook
        File Style

    ....
    ....

    ---------- Footnotes ----------
    (2) If you later call `c-set-style' (C-c .), all the style variables
    will get set to the style you select.
 
What do you think?

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).