all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* PHP mode in Emacs?
@ 2006-04-30 14:30 Lars Magne Ingebrigtsen
  2006-04-30 14:37 ` Nic
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-30 14:30 UTC (permalink / raw)


This is probably something that's been asked a lot, but I can't seem
to find the answer.

Are there any plans to include a PHP mode in Emacs?  Googling around
finds a couple of these modes, one of which is based on mmm-mode.  I
can't find any recent developments, though.

mmm-mode is something that allows you to run several major modes in
one buffer, apparently.  Languages like PHP are tricky to write major
modes for, because they mix HTML and PHP in the same buffer.

So what's up?  If none of the existing modes are appropriate for
inclusion, I might be tempted to have a go at it.  

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

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

* Re: PHP mode in Emacs?
  2006-04-30 14:30 PHP mode in Emacs? Lars Magne Ingebrigtsen
@ 2006-04-30 14:37 ` Nic
  2006-04-30 14:49   ` Lars Magne Ingebrigtsen
  2006-04-30 15:04 ` Stefan Monnier
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 18+ messages in thread
From: Nic @ 2006-04-30 14:37 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> This is probably something that's been asked a lot, but I can't seem
> to find the answer.
>
> Are there any plans to include a PHP mode in Emacs?  Googling around
> finds a couple of these modes, one of which is based on mmm-mode.  I
> can't find any recent developments, though.
>
> mmm-mode is something that allows you to run several major modes in
> one buffer, apparently.  Languages like PHP are tricky to write major
> modes for, because they mix HTML and PHP in the same buffer.
>
> So what's up?  If none of the existing modes are appropriate for
> inclusion, I might be tempted to have a go at it.  

It is a *really* difficult task because it's not just mixing PHP code
and HTML. PHP can also be used to generate other content types.

For example, generating XML is quite trivial. So it's not just a case
of making a mode that has PHP syntax support _and_ HTML support.



Nic

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

* Re: PHP mode in Emacs?
  2006-04-30 14:37 ` Nic
@ 2006-04-30 14:49   ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-30 14:49 UTC (permalink / raw)


Nic <nferrier@tapsellferrier.co.uk> writes:

> It is a *really* difficult task because it's not just mixing PHP code
> and HTML. PHP can also be used to generate other content types.

Like CSS and Javascript.  

> For example, generating XML is quite trivial. So it's not just a case
> of making a mode that has PHP syntax support _and_ HTML support.

No, it's a more general problem -- file formats that mix many types of
languages.

mmm-mode does this, and has been around for ages, but it's not
included in either Emacs or XEmacs.  Has mmm-mode been considered, but
found wanting, or is there something else wrong with the idea?

(I haven't acually looked at the mmm code.)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

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

* Re: PHP mode in Emacs?
  2006-04-30 14:30 PHP mode in Emacs? Lars Magne Ingebrigtsen
  2006-04-30 14:37 ` Nic
@ 2006-04-30 15:04 ` Stefan Monnier
  2006-04-30 15:14   ` Lars Magne Ingebrigtsen
  2006-04-30 20:54 ` Richard Stallman
  2006-05-01 17:29 ` Edward O'Connor
  3 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2006-04-30 15:04 UTC (permalink / raw)


> Are there any plans to include a PHP mode in Emacs?  Googling around
> finds a couple of these modes, one of which is based on mmm-mode.  I
> can't find any recent developments, though.

I don't have any experience with any php mode (or with php for that matter),
but I just want to mention that I think it'd be good to include mmm-mode
in Emacs.

There are other ways to handle the situation where you want to use different
major modes for different parts of a buffer and I don't claim that mmm-mode
is the ultimate answer, but I think it's a good solution.

Also I think other solutions should not be seen as competing: the choice
between them is probably going to come down to user preferences and to usage
patterns, so choosing one should not rule out the others.  Hopefully the
various approaches can share some things (e.g. the syntax of the special
elements that indicate the need for a mode switch).


        Stefan

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

* Re: PHP mode in Emacs?
  2006-04-30 15:04 ` Stefan Monnier
@ 2006-04-30 15:14   ` Lars Magne Ingebrigtsen
  2006-04-30 15:47     ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-30 15:14 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Also I think other solutions should not be seen as competing: the choice
> between them is probably going to come down to user preferences and to usage
> patterns, so choosing one should not rule out the others.  Hopefully the
> various approaches can share some things (e.g. the syntax of the special
> elements that indicate the need for a mode switch).

Are there other solutions?  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

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

* Re: PHP mode in Emacs?
  2006-04-30 15:14   ` Lars Magne Ingebrigtsen
@ 2006-04-30 15:47     ` Stefan Monnier
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2006-04-30 15:47 UTC (permalink / raw)


>> Also I think other solutions should not be seen as competing: the choice
>> between them is probably going to come down to user preferences and to usage
>> patterns, so choosing one should not rule out the others.  Hopefully the
>> various approaches can share some things (e.g. the syntax of the special
>> elements that indicate the need for a mode switch).

> Are there other solutions?  :-)

Yes, IIRC Dave Love has package that uses a different approach based on
indirect buffers.  And I seem to remember yet some other approach based
on narrowing.


        Stefan

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

* Re: PHP mode in Emacs?
  2006-04-30 14:30 PHP mode in Emacs? Lars Magne Ingebrigtsen
  2006-04-30 14:37 ` Nic
  2006-04-30 15:04 ` Stefan Monnier
@ 2006-04-30 20:54 ` Richard Stallman
  2006-05-01 11:42   ` Lars Magne Ingebrigtsen
  2006-05-01 17:29 ` Edward O'Connor
  3 siblings, 1 reply; 18+ messages in thread
From: Richard Stallman @ 2006-04-30 20:54 UTC (permalink / raw)
  Cc: emacs-devel

I do not know PHP.  All I can say is that I would welcome addition of
a good PHP mode.

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

* Re: PHP mode in Emacs?
  2006-04-30 20:54 ` Richard Stallman
@ 2006-05-01 11:42   ` Lars Magne Ingebrigtsen
  2006-05-01 14:58     ` Lennart Borgman
  2006-05-02  2:04     ` Richard Stallman
  0 siblings, 2 replies; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-05-01 11:42 UTC (permalink / raw)


Richard Stallman <rms@gnu.org> writes:

> I do not know PHP.  All I can say is that I would welcome addition of
> a good PHP mode.

Has the inclusion of mmm-mode (written by Michael Shulman and others)
been discussed previously?  It looks like the approach taken to this
problem (multi-mode programming languages) is promising. 

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

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

* Re: PHP mode in Emacs?
  2006-05-01 11:42   ` Lars Magne Ingebrigtsen
@ 2006-05-01 14:58     ` Lennart Borgman
  2006-05-01 16:17       ` Stefan Monnier
  2006-05-02  2:04     ` Richard Stallman
  1 sibling, 1 reply; 18+ messages in thread
From: Lennart Borgman @ 2006-05-01 14:58 UTC (permalink / raw)
  Cc: Lars Magne Ingebrigtsen, Peter Heslin

Lars Magne Ingebrigtsen wrote:
> Richard Stallman <rms@gnu.org> writes:
>
>   
>> I do not know PHP.  All I can say is that I would welcome addition of
>> a good PHP mode.
>>     
>
> Has the inclusion of mmm-mode (written by Michael Shulman and others)
> been discussed previously?  It looks like the approach taken to this
> problem (multi-mode programming languages) is promising. 
>   
I do not know whether it has been discussed, but it seems to me there 
are currently unfortunately problems with this approach. I believe a 
number of things have to be addressed in Emacs before something like 
mm-mode can work for all modes. But I am not sure, it is quite complex. 
Below are however my thoughts about it.

I think the idea of having different modes in different regions in a 
buffer is very good. So I tried it with nxml-mode (actually 
nxhtml-mode), but without any real success. Dean Scarff says he had some 
success, but still problems with that nxml-mode re-fontifies region that 
has another submode (see 
http://www.emacswiki.org/cgi-bin/wiki/NxmlModeForXHTML). This is also 
what I found.

I can really see no way to stop different modes from stomping at each 
other with mmm-mode. And I can not see that it is possible to do that 
with Emacs (even the CVS version) today. To do that there must be some 
way to tell a mode only to care about a region or a list of regions and 
I can not see how to do that now. (Maybe some more things are required, 
but this is a minimum.)

For the moment I would therefore suggest either html-script.el or 
html-inlined.el. They use narrowing and changes the buffers major mode 
temporarily during narrowing.

For the future I would sugges investigating ways to do what mm-mode 
tries to do.

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

* Re: PHP mode in Emacs?
  2006-05-01 14:58     ` Lennart Borgman
@ 2006-05-01 16:17       ` Stefan Monnier
  2006-05-01 16:36         ` Lennart Borgman
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2006-05-01 16:17 UTC (permalink / raw)
  Cc: Lars Magne Ingebrigtsen, Peter Heslin, emacs-devel

> I do not know whether it has been discussed, but it seems to me there are
> currently unfortunately problems with this approach.  I believe a number
> of things have to be addressed in Emacs before something like mmm-mode can
> work for all modes.  But I am not sure, it is quite complex.  Below are
> however my thoughts about it.

Making it work for all modes in not even a goal for me.  I know there are
some undesired interactions between mmm-mode and various major modes.
We can fix them one by one.  The problem of mmm-mode as it currently stands
is that it tries to solve the problem only on its side, whereas in several
cases it would be better to say "it's a bug in the major mode".  But that's
exactly what we could do if it were integrated in Emacs.

> I can really see no way to stop different modes from stomping at each other
> with mmm-mode.

That's a failure of imagination; you seem to assume major modes are free to
do whatever they want, but that's not the case: they can technically do what
they want, but it can lead to various problems which are then considered
as bugs in the major mode.

So all we need to do is to come up with a kind of convention for how the
major modes should be written such that they cooperate well with mmm-mode.


        Stefan

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

* Re: PHP mode in Emacs?
  2006-05-01 16:17       ` Stefan Monnier
@ 2006-05-01 16:36         ` Lennart Borgman
  2006-05-01 16:51           ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 18+ messages in thread
From: Lennart Borgman @ 2006-05-01 16:36 UTC (permalink / raw)
  Cc: Lars Magne Ingebrigtsen, emacs-devel, Peter Heslin

Stefan Monnier wrote:
>> I can really see no way to stop different modes from stomping at each other
>> with mmm-mode.
>>     
>
> That's a failure of imagination; you seem to assume major modes are free to
> do whatever they want, but that's not the case: they can technically do what
> they want, but it can lead to various problems which are then considered
> as bugs in the major mode.
>
> So all we need to do is to come up with a kind of convention for how the
> major modes should be written such that they cooperate well with mmm-mode.
>
>
>         Stefan
>   
Yes, you are right. I thought I was suggesting something like that when 
I wrote about regions or list of regions for a major mode. Maybe we 
could suggest an interface for telling the major modes (or minor modes) 
where to apply themselves? That would be a minimum I guess.

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

* Re: PHP mode in Emacs?
  2006-05-01 16:36         ` Lennart Borgman
@ 2006-05-01 16:51           ` Lars Magne Ingebrigtsen
  2006-05-01 17:38             ` Stefan Monnier
  2006-05-02  6:48             ` Gian Uberto Lauri
  0 siblings, 2 replies; 18+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-05-01 16:51 UTC (permalink / raw)


Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Yes, you are right. I thought I was suggesting something like that
> when I wrote about regions or list of regions for a major mode. Maybe
> we could suggest an interface for telling the major modes (or minor
> modes) where to apply themselves? That would be a minimum I guess.

Well, major modes have basically two major areas of interest: key maps
and syntax highlighting.  Key maps are trivial to do on regions -- you
just use key map text properties.  Syntax highlighting is also pretty
easy to deal with using text props.  

Now, of course you're going to find major modes that will misbehave,
and act on text way outside where you're editing, but I think those
functions are actually pretty rare (in the wider scheme of things),
and can be fixed.  Looking over the mmm code, it seems to be solving
most of what we want, although it is somewhat invasive as it stands.
As Stefan says, the major modes should be fixed to work in an
mmm-ified atmosphere; not the other way around.

For that to happen, we need mmm (or something like it) in Emacs.

But it's starting to sound like nobody has actually been in touch with
the mmm people.  Perhaps I should drop them an email and ask their
opinion on the matter?

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

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

* Re: PHP mode in Emacs?
  2006-04-30 14:30 PHP mode in Emacs? Lars Magne Ingebrigtsen
                   ` (2 preceding siblings ...)
  2006-04-30 20:54 ` Richard Stallman
@ 2006-05-01 17:29 ` Edward O'Connor
  2006-05-01 18:52   ` Stefan Monnier
  3 siblings, 1 reply; 18+ messages in thread
From: Edward O'Connor @ 2006-05-01 17:29 UTC (permalink / raw)


Lars Magne Ingebrigtsen wrote:

> Languages like PHP are tricky to write major modes for, because they
> mix HTML and PHP in the same buffer.

I think a PHP major mode should specifically only handle PHP code; the
issue of multiple-modes-in-the-same-buffer is orthogonal. Also, I think
the generally-accepted best practice in PHP-land has been to have
only-PHP-files, plus some templating system (such as Smarty), so perhaps
this issue will be come less important as time goes on.

-- 
Edward O'Connor
hober0@gmail.com

Ense petit placidam sub libertate quietem.

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

* Re: PHP mode in Emacs?
  2006-05-01 16:51           ` Lars Magne Ingebrigtsen
@ 2006-05-01 17:38             ` Stefan Monnier
  2006-05-01 20:22               ` Lennart Borgman
  2006-05-02  6:48             ` Gian Uberto Lauri
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2006-05-01 17:38 UTC (permalink / raw)


> Well, major modes have basically two major areas of interest: key maps
> and syntax highlighting.

You forget a big one: indentation.

> But it's starting to sound like nobody has actually been in touch with
> the mmm people.

Indeed, there hasn't been much contact ;-)

> Perhaps I should drop them an email and ask their opinion on the matter?

Please do,


        Stefan

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

* Re: PHP mode in Emacs?
  2006-05-01 17:29 ` Edward O'Connor
@ 2006-05-01 18:52   ` Stefan Monnier
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2006-05-01 18:52 UTC (permalink / raw)
  Cc: emacs-devel

> I think a PHP major mode should specifically only handle PHP code; the
> issue of multiple-modes-in-the-same-buffer is orthogonal.

Agreed.  Although it's admittedly more important to make sure that php-mode
interacts well with things like mmm-mode,


        Stefan

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

* Re: PHP mode in Emacs?
  2006-05-01 17:38             ` Stefan Monnier
@ 2006-05-01 20:22               ` Lennart Borgman
  0 siblings, 0 replies; 18+ messages in thread
From: Lennart Borgman @ 2006-05-01 20:22 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:
>> Well, major modes have basically two major areas of interest: key maps
>> and syntax highlighting.
>>     
>
> You forget a big one: indentation.
>   
nxml-mode also checks the document against the DTD as you type in your 
text. And I believe that it also does syntax highlighting in a different 
way than other modes. Here is the explanation form nxml-mode.el:

;; The font locking here is independent of font-lock.el.  We want to
;; do more sophisticated handling of changes and we want to use the
;; same xmltok rather than regexps for parsing so that we parse
;; consistently and correctly.

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

* Re: PHP mode in Emacs?
  2006-05-01 11:42   ` Lars Magne Ingebrigtsen
  2006-05-01 14:58     ` Lennart Borgman
@ 2006-05-02  2:04     ` Richard Stallman
  1 sibling, 0 replies; 18+ messages in thread
From: Richard Stallman @ 2006-05-02  2:04 UTC (permalink / raw)
  Cc: emacs-devel

    Has the inclusion of mmm-mode (written by Michael Shulman and others)
    been discussed previously?  It looks like the approach taken to this
    problem (multi-mode programming languages) is promising. 

I think we considered it several years ago, but I don't remember the
outcome.  It would be useful for someone to evaluate it again
(or else find the previous conclusions).

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

* Re: PHP mode in Emacs?
  2006-05-01 16:51           ` Lars Magne Ingebrigtsen
  2006-05-01 17:38             ` Stefan Monnier
@ 2006-05-02  6:48             ` Gian Uberto Lauri
  1 sibling, 0 replies; 18+ messages in thread
From: Gian Uberto Lauri @ 2006-05-02  6:48 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> "LMI" == Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

LMI> Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>> Yes, you are right. I thought I was suggesting something like that
>> when I wrote about regions or list of regions for a major
>> mode. Maybe we could suggest an interface for telling the major
>> modes (or minor modes) where to apply themselves? That would be a
>> minimum I guess.

LMI> Well, major modes have basically two major areas of interest: key
LMI> maps and syntax highlighting.  Key maps are trivial to do on
LMI> regions -- you just use key map text properties.  Syntax
LMI> highlighting is also pretty easy to deal with using text props.

Hmmm, I  would consider indentation too  (and that's why  I don't like
this much all those "mix html with something" tools).

-- 
 /\           ___
/___/\_|_|\_|__|___Gian Uberto Lauri_____
  //--\| | \|  |   Integralista GNUslamico
\/                 e coltivatore diretto di Software

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

end of thread, other threads:[~2006-05-02  6:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-30 14:30 PHP mode in Emacs? Lars Magne Ingebrigtsen
2006-04-30 14:37 ` Nic
2006-04-30 14:49   ` Lars Magne Ingebrigtsen
2006-04-30 15:04 ` Stefan Monnier
2006-04-30 15:14   ` Lars Magne Ingebrigtsen
2006-04-30 15:47     ` Stefan Monnier
2006-04-30 20:54 ` Richard Stallman
2006-05-01 11:42   ` Lars Magne Ingebrigtsen
2006-05-01 14:58     ` Lennart Borgman
2006-05-01 16:17       ` Stefan Monnier
2006-05-01 16:36         ` Lennart Borgman
2006-05-01 16:51           ` Lars Magne Ingebrigtsen
2006-05-01 17:38             ` Stefan Monnier
2006-05-01 20:22               ` Lennart Borgman
2006-05-02  6:48             ` Gian Uberto Lauri
2006-05-02  2:04     ` Richard Stallman
2006-05-01 17:29 ` Edward O'Connor
2006-05-01 18:52   ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.