emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: C indentation (problem)]


From: Thomas Christensen
Subject: Re: address@hidden: C indentation (problem)]
Date: Wed, 21 Mar 2007 00:45:39 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.96 (gnu/linux)

Hi

Alan Mackenzie <address@hidden> writes:

> On Mon, Mar 19, 2007 at 01:14:54AM -0400, Richard Stallman wrote:
>> Would someone please DTRT and ack?
>
> You wrote:
>> In the emacs pretest I have indentation problems running php-mode.
>
>> The indentation breaks if I put in a php opening tag, otherwise it
>> works fine.  I have tracked the source of the problem to the new c-mode
>> which php-mode inherits.
>
> Could you do a few things to help me diagnose this, please:
>
> (i) Tell me about this PHP Mode.  Where do I find the PHP Mode that you
> are using?  Who maintains it?  (Yourself, perhaps?)  It doesn't seem to
> be part of Emacs 22 itself.  The information you've posted says "Major
> mode: C/l", which isn't "PHP Mode".  How does php-mode work, here?
> [Note: I don't know PHP, so be gentle on me, please!]

The php-mode is from http://sourceforge.net/projects/php-mode/.

My brief studies of php-mode.el told me that it is cc-mode + some
syntax highlighting, so I tried to see if the issue was with the CC
Mode.

> (ii) You say:
>> The indentation breaks if I put in a php opening tag, otherwise it
>> works fine.  I have tracked the source of the problem to the new c-mode
>> which php-mode inherits.
>
> Could you be more specific about what you've found here, please.  What
> exactly have you found C Mode doing?  What version of CC Mode were you
> using before which seemed to work all right? 

Currently I use the CC Mode shipped with this pretest, and I find it
working with Emacs 21.4 and it's shipped CC Mode.

What I found was that in:

  <?php
  void foo () {
    bar ();
    }
  ?>

the closing bracket of the function definition aligns with the text in
the tag, and not with the start of the function declaration, whereas
in:

  <?php
  void foo ()
  {
    bar ();
  }
  ?>

it works right.

> (iii) Could you post a dump of CC Mode's configuration.  You get this
> with C-c C-b (or M-x c-submit-bug-report).

I will try to attach this.

Attachment: txtBC8z1tLRcY.txt
Description: C-c C-b

> You say:
>> This is the indentation in c-mode (it is the same in php-mode):
>>
>> <?   php
>> void foo() {
>>      bar();
>>      }
>> ?>
>
> In that little code snippet, could you please do C-u C-c C-s on each
> line, to dump CC Mode's idea of each line's syntax, then post the
> results.

Here it is:

  <?php                         /* ((topmost-intro 1)) */
  void foo () {                 /* ((topmost-intro-cont 1)) */
    bar ();                     /* ((defun-block-intro 1)) */
    }                           /* ((defun-close 3)) */
  ?>                            /* ((topmost-intro 125)) */

And the flawless one:

  <?php                         /* ((topmost-intro 1)) */
  void foo ()                   /* ((topmost-intro-cont 1)) */
  {                             /* ((defun-open 1)) */
    bar ();                     /* ((defun-block-intro 81)) */
  }                             /* ((defun-close 81)) */
  ?>                            /* ((topmost-intro 152)) */

>> I am not sure if it's a bug or the ancient php-mode just needs to
>> accommodate for the new emacs.
>
> "<" and ">" are nasty tokens in C-like languages.  They can appear as
> "i < 10", "#include <stdio.h>" and in C++ templates.  It could be that
> the PHP "<?" is getting confused with one of these other uses.

I think that sound reasonable.

> Looking forward to hearing from you again,

Glad if I can help.

        Thomas

reply via email to

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