help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Changing font-lock for combined HTML and PHP code??


From: William Case
Subject: Re: Changing font-lock for combined HTML and PHP code??
Date: Mon, 16 Apr 2007 15:55:21 -0400

Hi Eric;

Since I am just starting on this HTML/PHP journey I may misspeak but ...

On Mon, 2007-04-16 at 12:13 -0700, Eric Lilja wrote:
> On 16 Apr, 20:22, William Case <billli...@rogers.com> wrote:
> > Hi;
> >
> > I am working on web site made up of files that combine HTML and PHP.  My
> > main interest is in the PHP coding.  Is there a relatively easy way to
> > set the font-lock colors for the tags (constants) that distinguishes
> > between a HTML tag and a PHP tag when I am in php-mode.
> 
> I would like to find a good way to handle these kinds of files too,
> with both html code and php code.
> What I'm experimenting with just now is adding a keyboard setting for
> the html-mode to go to php mode and keyboard setting for php mode to
> go to html mode. Not ideal but better than what I had before which was
> treating php-files like html-files, hehe. I like emacs' html mode. I
> downloaded php mode from a third party.
> 

Since all the HTML tags are in the form <x> </x> i.e. double angle
brackets, it seems to me I should be able to add a definition somewhere
(where ?) that gets added to a php-mode font-lock mode and assigns a
special meaning and colour to expressions with double angle brackets.

At the moment I am using the global font-locks, so I would have to
create (or edit)
a php-mode font-lock using an amended global font-lock as my template.  

(Easy to say.  Doing is another thing.)

On second thought, it doesn't matter if HTML constants are always shown
in readable yellow while PHP show up in Orange in a global setting.

> The code is simply:
> 
> (require 'php-mode)
> 
> ; php-mode actually runs this hook, maybe there's a better place to
> put this...
> (defun my-c-mode-common-hook ()
>   (define-key c-mode-base-map "\C-c\C-h" 'html-mode)
> )
> (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
> 
> 
> (defun my-html-mode-hook ()
>   (define-key html-mode-map "\C-c\C-p" 'php-mode)
> )
> (add-hook 'html-mode-hook 'my-html-mode-hook)
> 
> The php-mode will actually font lock the html code but I don't like
> the way it indents it at all. Thus I switch between the modes with
> these keyboard bindings depending on if I'm editing a html part of the
> file or a php part. As I said, not ideal, but better than my earlier
> approach.
> 

As I say, my concentration is on the PHP so I only need to differentiate
between PHP and the beginning and ending of a block of HTML.  I don't
need a full different set of syntatical font-locks for HTML.

> - Eric
> 
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
-- 
Regards Bill





reply via email to

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