bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

classic Classic list List threaded Threaded
37 messages Options
12
Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Bob-336

As I work with text in C++ mode the indentation begins to deteriorate. For example, TAB on the class line wrongly indents it:

 

    template<class _Enum>

      class Build<TL::End,_Enum>

 

I work-around the problem by writing the buffer, killing the buffer, then visiting the file and re-indenting with TAB on the class line to get the expected indentation:

 

    template<class _Enum>

    class Build<TL::End,_Enum>

 

Same thing happens with ESC C-q.

 

My impression is there is internal state which doesn't get cleared as I work the text toward a syntax correct unit, causing incorrect indentation.  The bad state is ultimately cleared by re-visiting the file.

 

Sorry I can't come up with something reproducible.  

 

Has anyone else seen this issue?

 

 

     

Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

seewhydee
Hi Alan,

Looks like this is related to Bug#5490.  WDYT?


"Bob" <[hidden email]> writes:

> As I work with text in C++ mode the indentation begins to deteriorate. For
> example, TAB on the class line wrongly indents it:
>
>     template<class _Enum>
>       class Build<TL::End,_Enum>
>
> I work-around the problem by writing the buffer, killing the buffer, then
> visiting the file and re-indenting with TAB on the class line to get the
> expected indentation:
>
>     template<class _Enum>
>     class Build<TL::End,_Enum>
>
> Same thing happens with ESC C-q.
>
> My impression is there is internal state which doesn't get cleared as I work
> the text toward a syntax correct unit, causing incorrect indentation.  The bad
> state is ultimately cleared by re-visiting the file.
>
> Sorry I can't come up with something reproducible.
>
> Has anyone else seen this issue?




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

seewhydee
Forwarding an email with pertinent info to the bug tracker, and to Alan
the CC-mode maintainer:


"Bob" <[hidden email]> writes:

> Yes, it does look related to 5490. I can respond to:
>
>> (i) Have you ever noticed this bug happening on earlier Emacsen, in
>>  particular Emacs 23.1?
>
> Yes, it happened in 23.1 also.
>
>> (ii) Does this bug happen every time you use Emacs this long, or only
>>  sometimes?
>
> For me it happens within minutes of use. My C++ files are HEAVILY templated
> and the issue appears to be related to '<' and '>' of template args, e.g.
>
> typedef IF<
>  MemberOf<a,b>::value,
>  IF<
>    Length<c,d>::value,
>    true,
>     false
>  >::Result,
>  false
>   >::Result  Result;
>
> I will have several of these, one after the other, and be editing
> them. By accident I'll leave out a ',' or a '>' or kill & yank lines
> with similar error. After minutes of such editing, the indentation
> gets wacked. Sometimes by TAB indentation on a prior line the problem
> corrects. Sometimes I have to write the buffer and re-visit it.
>
>>(iv) Are all C(++) buffers in this state, or only some?  Any correlation
>>  with how many edits have been done on a buffer, or how long it's been
>>  loaded?
>
> Just the buffer with the '<' and '>' in it.




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Alan Mackenzie
Hi, Bob and Yidong,

On Sun, Feb 14, 2010 at 12:09:39AM -0500, Chong Yidong wrote:
> Forwarding an email with pertinent info to the bug tracker, and to Alan
> the CC-mode maintainer:


> "Bob" <[hidden email]> writes:

> > Yes, it does look related to 5490. I can respond to:

I have the horrible suspicion that this is different from 5490.  :-(

> >> (i) Have you ever noticed this bug happening on earlier Emacsen, in
> >> particular Emacs 23.1?

> > Yes, it happened in 23.1 also.

> >> (ii) Does this bug happen every time you use Emacs this long, or
> >> only sometimes?

> > For me it happens within minutes of use. My C++ files are HEAVILY
> > templated and the issue appears to be related to '<' and '>' of
> > template args, e.g.

> > typedef IF<
> >  MemberOf<a,b>::value,
> >  IF<
> >    Length<c,d>::value,
> >    true,
> >     false
> >  >::Result,
> >  false
> >   >::Result  Result;

OK, template brackets are difficult, because they're so difficult to
distinguish from less/greater than.

Bob, seeing as how the bug hits you "withing minutes", is there any
chance you could try and get it reproducible?  Using a dribble file might
be useful (see the page "Checklist" in the Emacs manual; you'd use this
with something like '(open-dribble-file "~/dribble")' at the beginning of
your Emacs session).

If you manage to get it reproducible, could you send me the C++ file
(which I will regard as confidential if needed) together with the
sequence of commands (e.g. the dribble file) which triggers the bug.
Also appreciated would be a dump of your CC Mode configuration, generated
by C-c C-b.

> > I will have several of these, one after the other, and be editing
> > them. By accident I'll leave out a ',' or a '>' or kill & yank lines
> > with similar error. After minutes of such editing, the indentation
> > gets wacked. Sometimes by TAB indentation on a prior line the problem
> > corrects. Sometimes I have to write the buffer and re-visit it.

One other thing.  Would you please try M-: (c-state-cache-init) when in
this state, and tell me if it resolves the badness.  Thanks!

> >>(iv) Are all C(++) buffers in this state, or only some?  Any correlation
> >>  with how many edits have been done on a buffer, or how long it's been
> >>  loaded?

> > Just the buffer with the '<' and '>' in it.

--
Alan Mackenzie (Nuremberg, Germany).




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Bob-336
More stuff:

With the emacs I've had going since last week I have several buffers where
the
indentation is incorrect. I validate by writing the buffer, then in a fresh
emacs,
visit the file, go to the lines with incorrect indentation, apply TAB and
the
result is the correct indentation. Ok, nothing new there.

This is new: After applying TAB in the 2nd emacs to correct the indentation
I write the file, then go back to the original buffer and re-visit the file
with "C-x C-f" "ESC-n".
Emacs confirms the file has changed, I reply "yes" and the visible buffer
becomes truncated
at the line where I TAB'ed to reformat:

The saved file is:

    template<
      class _TypeKind,
      class _EStore = typename ScalarVectorSelector<_TypeKind>::Result
      bool  _fixed  = TL::MemberOf<
        DataTypeTrait<GetDataType<_TypeKind>::Result>::TAbout,
        EnumDTP::FixedPacked
        >::value
      >

The re-visited buffer now shows:

    template<
      class _TypeKind,
      class _EStore = typename ScalarVectorSelector<_TypeKind>::Result
      bool  _fixed  = TL::MemberOf<
           
EOF  <--------------- NO MORE TEXT!

The original incorrect indentation was something like this (it got lost when
I revisited):

    template<
      class _TypeKind,
      class _EStore = typename ScalarVectorSelector<_TypeKind>::Result
      bool  _fixed  = TL::MemberOf<
                DataTypeTrait<GetDataType<_TypeKind>::Result>::TAbout,
                              EnumDTP::FixedPacked
                              >::value
              >

Now, I kill the truncated buffer, re-visit (the original emacs) and I see
correct indentation of the saved file, so I can continue work :) in the
original emacs.


-----Original Message-----
From: Alan Mackenzie [mailto:[hidden email]]
Sent: Sunday, February 14, 2010 12:10 PM
To: Chong Yidong
Cc: Bob; [hidden email]
Subject: Re: bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting
issue.

Hi, Bob and Yidong,

On Sun, Feb 14, 2010 at 12:09:39AM -0500, Chong Yidong wrote:
> Forwarding an email with pertinent info to the bug tracker, and to Alan
> the CC-mode maintainer:


> "Bob" <[hidden email]> writes:

> > Yes, it does look related to 5490. I can respond to:

I have the horrible suspicion that this is different from 5490.  :-(

> >> (i) Have you ever noticed this bug happening on earlier Emacsen, in
> >> particular Emacs 23.1?

> > Yes, it happened in 23.1 also.

> >> (ii) Does this bug happen every time you use Emacs this long, or
> >> only sometimes?

> > For me it happens within minutes of use. My C++ files are HEAVILY
> > templated and the issue appears to be related to '<' and '>' of
> > template args, e.g.

> > typedef IF<
> >  MemberOf<a,b>::value,
> >  IF<
> >    Length<c,d>::value,
> >    true,
> >     false
> >  >::Result,
> >  false
> >   >::Result  Result;

OK, template brackets are difficult, because they're so difficult to
distinguish from less/greater than.

Bob, seeing as how the bug hits you "withing minutes", is there any
chance you could try and get it reproducible?  Using a dribble file might
be useful (see the page "Checklist" in the Emacs manual; you'd use this
with something like '(open-dribble-file "~/dribble")' at the beginning of
your Emacs session).

If you manage to get it reproducible, could you send me the C++ file
(which I will regard as confidential if needed) together with the
sequence of commands (e.g. the dribble file) which triggers the bug.
Also appreciated would be a dump of your CC Mode configuration, generated
by C-c C-b.

> > I will have several of these, one after the other, and be editing
> > them. By accident I'll leave out a ',' or a '>' or kill & yank lines
> > with similar error. After minutes of such editing, the indentation
> > gets wacked. Sometimes by TAB indentation on a prior line the problem
> > corrects. Sometimes I have to write the buffer and re-visit it.

One other thing.  Would you please try M-: (c-state-cache-init) when in
this state, and tell me if it resolves the badness.  Thanks!

> >>(iv) Are all C(++) buffers in this state, or only some?  Any correlation
> >>  with how many edits have been done on a buffer, or how long it's been
> >>  loaded?

> > Just the buffer with the '<' and '>' in it.

--
Alan Mackenzie (Nuremberg, Germany).





Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Alan Mackenzie
In reply to this post by Alan Mackenzie
Hi, Bob,

On Mon, Feb 15, 2010 at 09:14:52AM -0800, Bob wrote:
> Alan,

> I am now running two emacs 23.1.91.1, one I started last week with many
> files open in which I "work" etc., and one I just started with dribbling
> "on" to edit a file I have seen the issue in. After half-hours editing in
> this one, nothing bad has happened. I temporarily jumped back to the "work"
> session to add a few needed lines and wammy! the problem appeared after
> adding 7 lines:

Could you be a little bit more exact in exactly what you did here.  I
have just fired up emacs 23.1.91, typed in

    namespace foo
    {

(in column 0), then typed in the the lines that you've identified as
causing the error:

>   template<class _DataType>
>   struct SelectInternalConvertableToVectorType
>   {
>     typedef typename DataTypeTrait<_DataType>::TAbout TAbout;
>
>     typedef TL::IF<TL::MemberOf<TAbout,EnumDTP::Internal>::value>
> TInternal;
>     typedef TL::IF<
> TL::MemberOf<TAbout,EnumDTP::HasVectorType>::value
> >   TConvertableToVectorType;
>
>     typedef TL::IF<
>       (TInternal::value &&
> TConvertableToVectorType::value),_DataType,TL::False
>       >::Result Result;
> };   <------------------------ Appears in column 1

However, that "};" for me appeared in the correct column, not in column
0.

> I wrote the buffer, started a 3rd emacs, went to the line, hit TAB and the
> indentation
> corrected:

That, at least, is refreshing.

>   };   <------------------------ Correct.

> Back in the original session TAB still places the '{' in column 1.

It doesn't for me.  But I _have_ seen this error happening.

So, could you please try and give me a precise recipe for how to
reproduce the error, down at the level of what the buffer should look
like before inserting these lines, and which keys to press to insert
them.  Was I correct in guessing that you typed in the lines when you
said you "added" them, as opposed to, say, C-y?

> I am now attempting to try your c-state-cache-init and find this is not
> defined.

That's exactly

    M-: (c-state-cache-init)

, including the parens round the word.  Are you certain you typed it
correctly?  It should be there in Emacs 23.1.91.

> Please advise what to do. I've attached "describe-bindings" if that helps.

> Thanks,
> Bob

> PS "C-c C-b" runs "c-submit-bug-report" - is that what you expect?

Yes.  It produces a dump of CC Mode's config as part of a mail buffer.
Cut and paste it into your own mail client.

--
Alan Mackenzie (Nuremberg, Germany).




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Bob-336
Alan,

>> I am now attempting to try your c-state-cache-init and find this is not
>> defined.
>
>That's exactly
>
>    M-: (c-state-cache-init)

Ahh, typed it in wrong.  I have been saving the buffer where the "
SelectInternalConvertableToVectorType" snippet is with the problematic '{'
in column 0.

So I am now able to eval your "(c-state-cache-init)" in the buffer.

The result is no difference, '{' still appears in column 0 when I TAB.
*Messages*
contains "1 (#o1, #x1)" after running it, if that means anything to you.

With regard to being more specific about what I type, that's going to be
really difficult.
Typically, I do a lot of kill - yanks, keyboard entry, and often return to
text to post-insert missing ','s or '>'s and then TAB or C-q C-j.  That's
when I discover a bad indentation case. Sometimes, by TAB-ing on previous
lines then returning to the problematic line, the indentation corrects. I
have done what you did with the snippet also - put it into a separate file,
start a separate emacs session. Each time I do that, the indentation
corrects ('{' is not in col 0) and doesn't get out of whack as I fiddle in
it. Makes me think the problem occurs with more than 1 file visited.

I am preserving the emacs session with the bad '{' indentation (col 0). Is
there any way we can narrow the issue by probing the buffer, such as with
your (c-state-cache-init) ?

Attached is the "c-submit-bug-report" run from the problematic buffer.

Bob

-----Original Message-----
From: Alan Mackenzie [mailto:[hidden email]]
Sent: Tuesday, February 16, 2010 8:39 AM
To: Bob
Cc: 'Chong Yidong'; [hidden email]
Subject: Re: bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting
issue.

Hi, Bob,

On Mon, Feb 15, 2010 at 09:14:52AM -0800, Bob wrote:
> Alan,

> I am now running two emacs 23.1.91.1, one I started last week with many
> files open in which I "work" etc., and one I just started with dribbling
> "on" to edit a file I have seen the issue in. After half-hours editing in
> this one, nothing bad has happened. I temporarily jumped back to the
"work"
> session to add a few needed lines and wammy! the problem appeared after
> adding 7 lines:

Could you be a little bit more exact in exactly what you did here.  I
have just fired up emacs 23.1.91, typed in

    namespace foo
    {

(in column 0), then typed in the the lines that you've identified as
causing the error:

>   template<class _DataType>
>   struct SelectInternalConvertableToVectorType
>   {
>     typedef typename DataTypeTrait<_DataType>::TAbout TAbout;
>
>     typedef TL::IF<TL::MemberOf<TAbout,EnumDTP::Internal>::value>
> TInternal;
>     typedef TL::IF<
> TL::MemberOf<TAbout,EnumDTP::HasVectorType>::value
> >   TConvertableToVectorType;
>
>     typedef TL::IF<
>       (TInternal::value &&
> TConvertableToVectorType::value),_DataType,TL::False
>       >::Result Result;
> };   <------------------------ Appears in column 1
However, that "};" for me appeared in the correct column, not in column
0.

> I wrote the buffer, started a 3rd emacs, went to the line, hit TAB and the
> indentation
> corrected:

That, at least, is refreshing.

>   };   <------------------------ Correct.

> Back in the original session TAB still places the '{' in column 1.

It doesn't for me.  But I _have_ seen this error happening.

So, could you please try and give me a precise recipe for how to
reproduce the error, down at the level of what the buffer should look
like before inserting these lines, and which keys to press to insert
them.  Was I correct in guessing that you typed in the lines when you
said you "added" them, as opposed to, say, C-y?

> I am now attempting to try your c-state-cache-init and find this is not
> defined.

That's exactly

    M-: (c-state-cache-init)

, including the parens round the word.  Are you certain you typed it
correctly?  It should be there in Emacs 23.1.91.

> Please advise what to do. I've attached "describe-bindings" if that helps.


> Thanks,
> Bob

> PS "C-c C-b" runs "c-submit-bug-report" - is that what you expect?

Yes.  It produces a dump of CC Mode's config as part of a mail buffer.
Cut and paste it into your own mail client.

--
Alan Mackenzie (Nuremberg, Germany).
Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Alan Mackenzie
Hi, Bob,

On Tue, Feb 16, 2010 at 10:35:37AM -0800, Bob wrote:
> Alan,

> >> I am now attempting to try your c-state-cache-init and find this is not
> >> defined.

> >That's exactly

> >    M-: (c-state-cache-init)

> Ahh, typed it in wrong.  I have been saving the buffer where the "
> SelectInternalConvertableToVectorType" snippet is with the problematic '{'
> in column 0.

> So I am now able to eval your "(c-state-cache-init)" in the buffer.

> The result is no difference, '{' still appears in column 0 when I TAB.
> *Messages*
> contains "1 (#o1, #x1)" after running it, if that means anything to you.

Yes, thanks.  The "1 .." is just random noise.  The fact that
`c-state-cache-init' fixes nothing tells me that the bug's not to do with
a massive overhaul of the "state cache" (a cache of brace/paren/bracket
positions) I committed several months ago.

> With regard to being more specific about what I type, that's going to be
> really difficult.

OK, I understand that.

> Typically, I do a lot of kill - yanks, keyboard entry, and often return
> to text to post-insert missing ','s or '>'s and then TAB or C-q C-j.
> That's when I discover a bad indentation case. Sometimes, by TAB-ing on
> previous lines then returning to the problematic line, the indentation
> corrects. I have done what you did with the snippet also - put it into
> a separate file, start a separate emacs session. Each time I do that,
> the indentation corrects ('{' is not in col 0) and doesn't get out of
> whack as I fiddle in it. Makes me think the problem occurs with more
> than 1 file visited.

I have a hyptothesis: noramlly, when you type in a < or > which "looks
like" a template delimiter, CC Mode marks it as an openining/closing
parenthesis.  These can, and do, get confused with "proper" parens, { } (
) [ ], sometimes.  It seems likely that on certain deletions, these
marked <s and >s become unbalanced, and this confuses the indentation.

I committed a fix for this on 2010-02-04, barely 2 weeks ago.  This fix
ensures that these marks only get applied to < and > in balanced pairs,
and when stuff is deleted does the Right Thing.  The fix hasn't yet found
its way into a pretest.  If you test on the bzr head, could you try it
out, please.  Otherwise, please be patient and try it out on the NEXT
pretest version, when that gets released.

> I am preserving the emacs session with the bad '{' indentation (col 0).
> Is there any way we can narrow the issue by probing the buffer, such as
> with your (c-state-cache-init) ?

Could you perhaps test the above hypothesis, please?  Turn on
`show-paren-mode'.  When you next hit this bad state in a buffer, place
point on a < or >, and see if it mismatches with a proper paren/brace.

> Attached is the "c-submit-bug-report" run from the problematic buffer.

Much appreciated.

> Bob

--
Alan Mackenzie (Nuremberg, Germany).




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Bob-336
Alan,

Attached is "Foo.cpp" and "dribble" (if I did it correctly, dribble recorded
what I typed).

It illustrates a case where indentation is one level deeper than it should
be. (The other case we've been working on is one level shallower than it
should be). Maybe they are related?

visit-file "Foo.cpp", note indentation for "class Bar" is too deep. Now, TAB
on the "class Bar" line the indentation corrects. If you reconstruct the
file from "dribble" you should see TAB on the "class Bar" line incorrectly
indents too deep.

My ".emacs" file sets indentation to 2 spaces. I would guess there is an
issue where
the default (I think 4 spaces) is being used instead of my setting.

I've also attached my ".emacs" file as "emacs_init" (Outlook doesn't attach
files without a file-name). Please excuse the accumulation of junk in it
from many years of emacs use and
recommendations obtained from internet sites.

Bob

Foo.cpp:
----------------------------------------
template<
    class Bar,
    int _depth = -1
    >
class Foo;

template<
  int _depth = -1
  >
class Foo
{
};
-----------------------------------------

dribble (704 bytes) Download Attachment
Foo.cpp (130 bytes) Download Attachment
emacs_init (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Alan Mackenzie
Hi, Bob,

On Wed, Feb 17, 2010 at 08:40:36AM -0800, Bob wrote:
> Alan,

> Attached is "Foo.cpp" and "dribble" (if I did it correctly, dribble recorded
> what I typed).

> It illustrates a case where indentation is one level deeper than it should
> be. (The other case we've been working on is one level shallower than it
> should be). Maybe they are related?

I suspect not, but who knows?  :-(

However, I can reproduce this bug; the dribble file and your CC Mode
configuration file were utterly essential to my doing so.  Thanks!

> visit-file "Foo.cpp", note indentation for "class Bar" is too deep. Now, TAB
> on the "class Bar" line the indentation corrects. If you reconstruct the
> file from "dribble" you should see TAB on the "class Bar" line incorrectly
> indents too deep.

Yes.

> My ".emacs" file sets indentation to 2 spaces. I would guess there is an
> issue where
> the default (I think 4 spaces) is being used instead of my setting.

No, that's not it.  In the course of creating this file, as per your
dribble, some "text properties" (deep in the bowels of CC Mode) are being
spuriously applied to certain characters in the buffer.  I'll track down
exactly which keystroke provoked this, and hopefully be able to fix it
sometime soonish.

Thanks for taking all this trouble to help me reproduce the bug.

> Bob

--
Alan Mackenzie (Nuremberg, Germany).




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Bob-336
Alan,

That's good news! Please let me know when you get it fixed and I'd like to
try it out.

BTW, the indenting and paren matching is a world better than 21.2, esp. with
regard to template '<' and '>' characters. Good job!

Bob

-----Original Message-----
From: Alan Mackenzie [mailto:[hidden email]]
Sent: Thursday, February 18, 2010 7:13 AM
To: Bob
Cc: 'Chong Yidong'; [hidden email]
Subject: Re: bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting
issue.

Hi, Bob,

On Wed, Feb 17, 2010 at 08:40:36AM -0800, Bob wrote:
> Alan,

> Attached is "Foo.cpp" and "dribble" (if I did it correctly, dribble
recorded
> what I typed).

> It illustrates a case where indentation is one level deeper than it should
> be. (The other case we've been working on is one level shallower than it
> should be). Maybe they are related?

I suspect not, but who knows?  :-(

However, I can reproduce this bug; the dribble file and your CC Mode
configuration file were utterly essential to my doing so.  Thanks!

> visit-file "Foo.cpp", note indentation for "class Bar" is too deep. Now,
TAB
> on the "class Bar" line the indentation corrects. If you reconstruct the
> file from "dribble" you should see TAB on the "class Bar" line incorrectly
> indents too deep.

Yes.

> My ".emacs" file sets indentation to 2 spaces. I would guess there is an
> issue where
> the default (I think 4 spaces) is being used instead of my setting.

No, that's not it.  In the course of creating this file, as per your
dribble, some "text properties" (deep in the bowels of CC Mode) are being
spuriously applied to certain characters in the buffer.  I'll track down
exactly which keystroke provoked this, and hopefully be able to fix it
sometime soonish.

Thanks for taking all this trouble to help me reproduce the bug.

> Bob

--
Alan Mackenzie (Nuremberg, Germany).





Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Alan Mackenzie
Hi, Bob,

I think I've got the problem nailed.  And I now think you were right
when you suggested it's related to the other indentation problems.

Would you please apply this patch to cc-mode.el, and tell me if the
problem's been fixed.

Thanks!


*** orig/cc-mode.el 2010-02-18 16:29:49.000000000 +0000
--- cc-mode.el 2010-02-19 20:15:14.630249504 +0000
***************
*** 635,641 ****
      (save-excursion
        (if c-get-state-before-change-functions
   (mapc (lambda (fn)
!  (funcall fn beg end))
  c-get-state-before-change-functions))
        (if c-before-font-lock-function
   (funcall c-before-font-lock-function (point-min) (point-max)
--- 635,641 ----
      (save-excursion
        (if c-get-state-before-change-functions
   (mapc (lambda (fn)
!  (funcall fn (point-min) (point-max)))
  c-get-state-before-change-functions))
        (if c-before-font-lock-function
   (funcall c-before-font-lock-function (point-min) (point-max)
***************
*** 1031,1036 ****
--- 1031,1044 ----
   (when (> beg end)
     (setq beg end)))
 
+ ;; C-y is capable of spuriously converting category properties
+ ;; c-</>-as-paren-syntax into hard syntax-table properties.  Remove
+ ;; these when it happens.
+ (c-clear-char-property-with-value beg end 'syntax-table
+  c-<-as-paren-syntax)
+ (c-clear-char-property-with-value beg end 'syntax-table
+  c->-as-paren-syntax)
+
  (c-trim-found-types beg end old-len) ; maybe we don't need all of these.
  (c-invalidate-sws-region-after beg end)
  (c-invalidate-state-cache beg)

On Thu, Feb 18, 2010 at 07:53:34AM -0800, Bob wrote:
> Alan,
>
> That's good news! Please let me know when you get it fixed and I'd like to
> try it out.
>
> BTW, the indenting and paren matching is a world better than 21.2, esp. with
> regard to template '<' and '>' characters. Good job!
>
> Bob

--
Alan Mackenzie (Nuremberg, Germany).




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Paul Pogonyshev
In reply to this post by Bob-336
Severity: important

> Has anyone else seen this issue?

I see it so often it is not fun.  I'm currently compiling an older
Emacs version because indentation's becoming broken every second line
is unbearable.

Paul




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Alan Mackenzie
Hi, Paul,

On Sat, Feb 20, 2010 at 03:41:02PM +0200, Paul Pogonyshev wrote:
> Severity: important

> > Has anyone else seen this issue?

> I see it so often it is not fun.  I'm currently compiling an older
> Emacs version because indentation's becoming broken every second line
> is unbearable.

Apologies.  Please bear with me on this.  It should become stable well
before the release of Emacs 23.2.

Is there any chance you could say the sort of editing you've been doing
which provokes this mis-indentation?  Do you use C-y a lot?  Is it only
in C++ Mode, or are other modes (C, Java, ....) affected?

Any chance you might try the head versions in the bzr repository?

> Paul

--
Alan Mackenzie (Nuremberg, Germany).




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Paul Pogonyshev
Alan Mackenzie wrote:

> On Sat, Feb 20, 2010 at 03:41:02PM +0200, Paul Pogonyshev wrote:
> > Severity: important
>
> > > Has anyone else seen this issue?
>
> > I see it so often it is not fun.  I'm currently compiling an older
> > Emacs version because indentation's becoming broken every second line
> > is unbearable.
>
> Apologies.  Please bear with me on this.  It should become stable well
> before the release of Emacs 23.2.
>
> Is there any chance you could say the sort of editing you've been doing
> which provokes this mis-indentation?  Do you use C-y a lot?  Is it only
> in C++ Mode, or are other modes (C, Java, ....) affected?

Mostly in C++ Mode, with usually with quite complicated code
(templates), but not only.  E.g. I lost patience with it on a file
without templates where only more or less non-common thing was a local
namespace.  It looks basically like this (using my preferred
indentation style, might be important):

namespace
{
  class Foo : public Bar
  {
  public:

    virtual  void
    bla_bla (some_type& x, const string& y)
    {
      ...
    }

    ...
  };
}

It used to break heavily in such functions (there are many similar)
inside a local class.  Function names were becoming colored with
'font-lock-variable-name-face' and as such indented wrongly.

> Any chance you might try the head versions in the bzr repository?

OK, but a bit later.  I guess it is of little help, but currently I
use revision 98816 (just chose one at random) and cc-mode works fine.

Paul




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

seewhydee
Paul Pogonyshev <[hidden email]> writes:

>> Any chance you might try the head versions in the bzr repository?
>
> OK, but a bit later.  I guess it is of little help, but currently I
> use revision 98816 (just chose one at random) and cc-mode works fine.

It would be nice if you could test the patch Alan posted at

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5570#40

since "Bob" has not responded to the request to test it.




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Paul Pogonyshev
Chong Yidong wrote:

> Paul Pogonyshev <[hidden email]> writes:
>
> >> Any chance you might try the head versions in the bzr repository?
> >
> > OK, but a bit later.  I guess it is of little help, but currently I
> > use revision 98816 (just chose one at random) and cc-mode works fine.
>
> It would be nice if you could test the patch Alan posted at
>
>   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5570#40
>
> since "Bob" has not responded to the request to test it.

It doesn't apply to trunk and I'd prefer not to guess how to merge.
Can you rediff it?

Paul




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

seewhydee
Paul Pogonyshev <[hidden email]> writes:

> Chong Yidong wrote:
>> Paul Pogonyshev <[hidden email]> writes:
>>
>> >> Any chance you might try the head versions in the bzr repository?
>> >
>> > OK, but a bit later.  I guess it is of little help, but currently I
>> > use revision 98816 (just chose one at random) and cc-mode works fine.
>>
>> It would be nice if you could test the patch Alan posted at
>>
>>   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5570#40
>>
>> since "Bob" has not responded to the request to test it.
>
> It doesn't apply to trunk and I'd prefer not to guess how to merge.
> Can you rediff it?

Here, try this:

*** lisp/progmodes/cc-mode.el 2010-02-06 13:01:43 +0000
--- lisp/progmodes/cc-mode.el 2010-02-21 22:05:23 +0000
***************
*** 642,652 ****
      (widen)
      (save-excursion
        (if c-get-state-before-change-functions
!  (let ((beg (point-min))
! (end (point-max)))
!    (mapc (lambda (fn)
!    (funcall fn beg end))
!  c-get-state-before-change-functions)))
        (if c-before-font-lock-function
   (funcall c-before-font-lock-function (point-min) (point-max)
    (- (point-max) (point-min))))))
--- 642,650 ----
      (widen)
      (save-excursion
        (if c-get-state-before-change-functions
!  (mapc (lambda (fn)
!  (funcall fn (point-min) (point-max)))
! c-get-state-before-change-functions))
        (if c-before-font-lock-function
   (funcall c-before-font-lock-function (point-min) (point-max)
    (- (point-max) (point-min))))))
***************
*** 1042,1047 ****
--- 1040,1053 ----
   (when (> beg end)
     (setq beg end)))
 
+ ;; C-y is capable of spuriously converting category properties
+ ;; c-</>-as-paren-syntax into hard syntax-table properties.  Remove
+ ;; these when it happens.
+ (c-clear-char-property-with-value beg end 'syntax-table
+  c-<-as-paren-syntax)
+ (c-clear-char-property-with-value beg end 'syntax-table
+  c->-as-paren-syntax)
+
  (c-trim-found-types beg end old-len) ; maybe we don't need all of these.
  (c-invalidate-sws-region-after beg end)
  (c-invalidate-state-cache beg)




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Paul Pogonyshev
Chong Yidong wrote:

> Paul Pogonyshev <[hidden email]> writes:
>
> > Chong Yidong wrote:
> >> Paul Pogonyshev <[hidden email]> writes:
> >>
> >> >> Any chance you might try the head versions in the bzr repository?
> >> >
> >> > OK, but a bit later.  I guess it is of little help, but currently I
> >> > use revision 98816 (just chose one at random) and cc-mode works fine.
> >>
> >> It would be nice if you could test the patch Alan posted at
> >>
> >>   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5570#40
> >>
> >> since "Bob" has not responded to the request to test it.
> >
> > It doesn't apply to trunk and I'd prefer not to guess how to merge.
> > Can you rediff it?
>
> Here, try this: [...]

Thanks, indentation problems seem to be gone.  Or at least don't
happen nearly that often.

Paul




Reply | Threaded
Open this post in threaded view
|

bug#5570: Emacs 23.1.91.1 C++ mode "ESC C-q" and TAB indenting issue.

Paul Pogonyshev
I wrote:
> Thanks, indentation problems seem to be gone.  Or at least don't
> happen nearly that often.

Still happens, though much more rarely than before.  No sure way to
reproduce, but in this short source code file:

#include "engine/strategy/evaluation/material.hpp"

#include <utility>


using namespace engine;

using namespace std;


int
MaterialEvaluationFunction::do_evaluate_material (Board::PackedMaterialData material)
{
  const int  score            = _algorithm->evaluate (material);
  const int  normalized_score = ((score * get_first_rabbit_value ())
                                 / _algorithm->get_first_rabbit_value ());

_cache.insert (make_pair (material, normalized_score));
}

I'm getting wrongly indented '_cache.insert ...' line.  C-c C-s on it
also shows 'topmost-intro'.  I guess this heavily depends on the order
in which code is typed.

After I killed the buffer and reopened it, indentation is back to
normal and C-c C-s on that line correctly shows 'statement'.

Paul




12