unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A bad indentation made by C
@ 2007-04-22 11:28 Lennart Borgman (gmail)
  2007-04-22 12:02 ` Alan Mackenzie
  0 siblings, 1 reply; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-22 11:28 UTC (permalink / raw)
  To: Emacs Devel; +Cc: Eric Lilja

but for php-mode.el. The php-mode I am using/distributing is derived 
from c-mode. It uses c-indent-line. That works in many circumstances but 
not all.

A rather annoying indentation is the following

   for (;;) {
    }

This happens only if the for-loop is on top level, but that happens all 
the time in PHP. Maybe that little thing could be changed in 
c-indent-line? Or maybe someone can help me a bit to fix this in 
php-mode.el?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-22 11:28 A bad indentation made by C Lennart Borgman (gmail)
@ 2007-04-22 12:02 ` Alan Mackenzie
  2007-04-22 12:42   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2007-04-22 12:02 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Eric Lilja, Emacs Devel

Hi, Lennart!

On Sun, Apr 22, 2007 at 01:28:25PM +0200, Lennart Borgman (gmail) wrote:
> but for php-mode.el. The php-mode I am using/distributing is derived 
> from c-mode. It uses c-indent-line. That works in many circumstances but 
> not all.

Just as an aside, your bug report could have been a little more
detailed and helpful, for example by saying where you got php-mode.el
from (it isn't part of Emacs 22), and being a bit more precise about the
indentation (you've pictured the "for" starting at column 2 despite
having said "on top level").  It could have been MUCH more helpful by
dumping CC Mode's configuration (C-c C-b).  :-)

However, assuming that the "for" is really at column 0, and that
php-mode.el came from <http://php-mode.sourceforge.net/>

> A rather annoying indentation is the following
> 
>   for (;;) {
>    }

> This happens only if the for-loop is on top level, but that happens
> all the time in PHP. Maybe that little thing could be changed in
> c-indent-line? Or maybe someone can help me a bit to fix this in
> php-mode.el?

As a pure guess, the indentation of the "}" to column 1 probably comes
from `c-gnu-impose-minimum' which is installed on c-special-indent-hook
for the style "gnu".  If you set a different style (e.g. by C-c .), this
problem might go away.  Or remove it from c-special-indent-hook in
php-mode-hook or one of CC Mode's hooks.

The php-mode.el at SourceForge, when I last looked at it, didn't look
like it was being actively maintained.  The latest release was from
2003, and it didn't appear to have been updated for CC Mode 5.30 (which
superseded 5.28 in summer 2003).

I think that php-mode.el needs a serious amount of work done on it to
bring it up to date with the current CC Mode.  It would probably be
better to wait till after the release to do this.  ;-)

-- 
Alan Mackenzie (Ittersbach, Germany)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-22 12:02 ` Alan Mackenzie
@ 2007-04-22 12:42   ` Lennart Borgman (gmail)
  2007-04-22 14:17     ` Alan Mackenzie
  0 siblings, 1 reply; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-22 12:42 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Eric Lilja, Emacs Devel

Alan Mackenzie wrote:
> Hi, Lennart!

Hi, Alan!

> On Sun, Apr 22, 2007 at 01:28:25PM +0200, Lennart Borgman (gmail) wrote:
>> but for php-mode.el. The php-mode I am using/distributing is derived 
>> from c-mode. It uses c-indent-line. That works in many circumstances but 
>> not all.
> 
> Just as an aside, your bug report could have been a little more
> detailed and helpful, for example by saying where you got php-mode.el
> from (it isn't part of Emacs 22), and being a bit more precise about the
> indentation (you've pictured the "for" starting at column 2 despite
> having said "on top level").  It could have been MUCH more helpful by
> dumping CC Mode's configuration (C-c C-b).  :-)

Well everyone knows my bug reporting skills ;-)

Yes, you are right, but I actually hoped that you should guess the right 
things.


> However, assuming that the "for" is really at column 0, and that
> php-mode.el came from <http://php-mode.sourceforge.net/>
> 
>> A rather annoying indentation is the following
>>
>>   for (;;) {
>>    }
> 
>> This happens only if the for-loop is on top level, but that happens
>> all the time in PHP. Maybe that little thing could be changed in
>> c-indent-line? Or maybe someone can help me a bit to fix this in
>> php-mode.el?
> 
> As a pure guess, the indentation of the "}" to column 1 probably comes
> from `c-gnu-impose-minimum' which is installed on c-special-indent-hook
> for the style "gnu".  If you set a different style (e.g. by C-c .), this
> problem might go away.  Or remove it from c-special-indent-hook in
> php-mode-hook or one of CC Mode's hooks.

Thanks, that helped. But now I have one of my favourite questions I 
seldom ask: How do I make a local hook so much nil so that the global 
hook is not run?


> The php-mode.el at SourceForge, when I last looked at it, didn't look
> like it was being actively maintained.  The latest release was from
> 2003, and it didn't appear to have been updated for CC Mode 5.30 (which
> superseded 5.28 in summer 2003).

I have tried to contact the author, Turadg, but he has not replied (yet).


> I think that php-mode.el needs a serious amount of work done on it to
> bring it up to date with the current CC Mode.  It would probably be
> better to wait till after the release to do this.  ;-)

I have done a bit of work on it, but not very much since I do not 
understand most of it.

I have uploaded the slightly changed version here:

   http://ourcomments.org/Emacs/DL/elisp/

Otherwise it is part of nXhtml. There are some problem with my webhost 
right now so it may be difficult to retrieve it. Mail me if you want it.

If you want to have a look at it it would be nice. I think that there 
can be some interest in it again, especially when used in nXhtml (or 
something similar perhaps).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-22 12:42   ` Lennart Borgman (gmail)
@ 2007-04-22 14:17     ` Alan Mackenzie
  2007-04-22 14:50       ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2007-04-22 14:17 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Eric Lilja, Emacs Devel

Hallo again, Lennart!

On Sun, Apr 22, 2007 at 02:42:00PM +0200, Lennart Borgman (gmail) wrote:

> Hi, Alan!

> >On Sun, Apr 22, 2007 at 01:28:25PM +0200, Lennart Borgman (gmail)
> >wrote:
> >>but for php-mode.el. The php-mode I am using/distributing is derived
> >>from c-mode. It uses c-indent-line. That works in many circumstances
> >>but not all.

> >>A rather annoying indentation is the following

> >>  for (;;) {
> >>   }

> >>This happens only if the for-loop is on top level, but that happens
> >>all the time in PHP. Maybe that little thing could be changed in
> >>c-indent-line? Or maybe someone can help me a bit to fix this in
> >>php-mode.el?

> >As a pure guess, the indentation of the "}" to column 1 probably comes
> >from `c-gnu-impose-minimum' which is installed on
> >c-special-indent-hook for the style "gnu".  If you set a different
> >style (e.g. by C-c .), this problem might go away.  Or remove it from
> >c-special-indent-hook in php-mode-hook or one of CC Mode's hooks.

> Thanks, that helped. But now I have one of my favourite questions I
> seldom ask: How do I make a local hook so much nil so that the global
> hook is not run?

Sorry, I can't parse that (but I do understand about writing foreign
languages).  Which local hook, which global hook?  When do you not wan't
which global hook to run?

> >The php-mode.el at SourceForge, when I last looked at it, didn't look
> >like it was being actively maintained.  The latest release was from
> >2003, and it didn't appear to have been updated for CC Mode 5.30
> >(which superseded 5.28 in summer 2003).

> I have tried to contact the author, Turadg, but he has not replied (yet).

It might well me that he (?she) has simply lost interest and given up on
the project.  I hope you get an answer sometime, though.

> >I think that php-mode.el needs a serious amount of work done on it to
> >bring it up to date with the current CC Mode.  It would probably be
> >better to wait till after the release to do this.  ;-)

> I have done a bit of work on it, but not very much since I do not 
> understand most of it.

Where's that little word "yet"?  ;-)

> I have uploaded the slightly changed version here:

[ .... ]

> If you want to have a look at it it would be nice. I think that there 
> can be some interest in it again, especially when used in nXhtml (or 
> something similar perhaps).

Well, I'm struggling a bit to keep up with everything on CC Mode, so I'm
not really in a position to take on anything extra.

-- 
Alan.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-22 14:17     ` Alan Mackenzie
@ 2007-04-22 14:50       ` Lennart Borgman (gmail)
  2007-04-22 17:50         ` Alan Mackenzie
  2007-04-23  4:49         ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-22 14:50 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Eric Lilja, Emacs Devel

Alan Mackenzie wrote:
>>> As a pure guess, the indentation of the "}" to column 1 probably comes
>> >from `c-gnu-impose-minimum' which is installed on
>>> c-special-indent-hook for the style "gnu".  If you set a different
>>> style (e.g. by C-c .), this problem might go away.  Or remove it from
>>> c-special-indent-hook in php-mode-hook or one of CC Mode's hooks.
> 
>> Thanks, that helped. But now I have one of my favourite questions I
>> seldom ask: How do I make a local hook so much nil so that the global
>> hook is not run?
> 
> Sorry, I can't parse that (but I do understand about writing foreign
> languages).  Which local hook, which global hook?  When do you not wan't
> which global hook to run?

I want to set c-special-indent-hook to nil locally in the buffer and I 
do not want to run the global hook then. Is the global hook still run 
when I set the local hook to nil? I believe it is not run, but I am not 
sure.


> Well, I'm struggling a bit to keep up with everything on CC Mode, so I'm
> not really in a position to take on anything extra.

Ok, thanks, I see. You have already helped a lot by telling about the 
c-special-indentation-hook and the different styles.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-22 14:50       ` Lennart Borgman (gmail)
@ 2007-04-22 17:50         ` Alan Mackenzie
  2007-04-23  4:49         ` Stefan Monnier
  1 sibling, 0 replies; 8+ messages in thread
From: Alan Mackenzie @ 2007-04-22 17:50 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Emacs Devel

Good evening!

On Sun, Apr 22, 2007 at 04:50:14PM +0200, Lennart Borgman (gmail) wrote:
> Alan Mackenzie wrote:
> >>>As a pure guess, the indentation of the "}" to column 1 probably comes
> >>>from `c-gnu-impose-minimum' which is installed on
> >>>c-special-indent-hook for the style "gnu".  If you set a different
> >>>style (e.g. by C-c .), this problem might go away.  Or remove it from
> >>>c-special-indent-hook in php-mode-hook or one of CC Mode's hooks.

> >>Thanks, that helped. But now I have one of my favourite questions I
> >>seldom ask: How do I make a local hook so much nil so that the global
> >>hook is not run?

> >Sorry, I can't parse that (but I do understand about writing foreign
> >languages).  Which local hook, which global hook?  When do you not
> >wan't which global hook to run?

> I want to set c-special-indent-hook to nil locally in the buffer and I 
> do not want to run the global hook then. Is the global hook still run 
> when I set the local hook to nil? I believe it is not run, but I am not 
> sure.

Ah, right!

c-special-indent-hook is already buffer local - try doing C-h v on it in
a CC Mode buffer.  Hmm.  The CC Mode manual should perhaps say this on
the page "Other Special Indentations".  [But after the release. :-]  Just
as a matter of interest, the only function CC Mode itself puts on this
hook is c-gnu-impose-minimum, and that only for "gnu" style.

For other hooks which aren't buffer local, I suppose you could do
something like this:
(make-local-variable 'foo-mode-hook)
(remove-hook 'foo-mode-hook 'bar)

-- 
Alan.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-22 14:50       ` Lennart Borgman (gmail)
  2007-04-22 17:50         ` Alan Mackenzie
@ 2007-04-23  4:49         ` Stefan Monnier
  2007-04-23  5:29           ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2007-04-23  4:49 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Alan Mackenzie, Emacs Devel, Eric Lilja

> I want to set c-special-indent-hook to nil locally in the buffer and I do
> not want to run the global hook then.  Is the global hook still run when
> I set the local hook to nil?  I believe it is not run, but I am not sure.

Read the Elisp manual's section about Hooks.
The local hook contains a special entry t which means "run the global hook".
So if you remove the t, the local hook will ignore the global hook.
E.g. if you set the local value to nil, nothing is run.


        Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: A bad indentation made by C
  2007-04-23  4:49         ` Stefan Monnier
@ 2007-04-23  5:29           ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 8+ messages in thread
From: Lennart Borgman (gmail) @ 2007-04-23  5:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Devel

Stefan Monnier wrote:
>> I want to set c-special-indent-hook to nil locally in the buffer and I do
>> not want to run the global hook then.  Is the global hook still run when
>> I set the local hook to nil?  I believe it is not run, but I am not sure.
> 
> Read the Elisp manual's section about Hooks.
> The local hook contains a special entry t which means "run the global hook".
> So if you remove the t, the local hook will ignore the global hook.
> E.g. if you set the local value to nil, nothing is run.


Ah, thanks. That was what I was looking for.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-04-23  5:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-22 11:28 A bad indentation made by C Lennart Borgman (gmail)
2007-04-22 12:02 ` Alan Mackenzie
2007-04-22 12:42   ` Lennart Borgman (gmail)
2007-04-22 14:17     ` Alan Mackenzie
2007-04-22 14:50       ` Lennart Borgman (gmail)
2007-04-22 17:50         ` Alan Mackenzie
2007-04-23  4:49         ` Stefan Monnier
2007-04-23  5:29           ` Lennart Borgman (gmail)

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).