From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: William Case Newsgroups: gmane.emacs.help Subject: Re: Changing font-lock for combined HTML and PHP code?? Date: Mon, 16 Apr 2007 15:55:21 -0400 Message-ID: <1176753321.3057.37.camel@CASE> References: <1176750795.320403.140590@y80g2000hsf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1176753513 19805 80.91.229.12 (16 Apr 2007 19:58:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Apr 2007 19:58:33 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Eric Lilja Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 16 21:58:27 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HdXLF-0004fw-D5 for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Apr 2007 21:58:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdXPs-0003r8-V6 for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Apr 2007 16:03:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HdXPe-0003qx-4V for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 16:02:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HdXPc-0003qk-Vt for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 16:02:57 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdXPc-0003qh-RQ for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 16:02:56 -0400 Original-Received: from smtp106.rog.mail.re2.yahoo.com ([68.142.225.204]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HdXKy-0008OU-Fm for help-gnu-emacs@gnu.org; Mon, 16 Apr 2007 15:58:08 -0400 Original-Received: (qmail 35874 invoked from network); 16 Apr 2007 19:58:04 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=rogers.com; h=Received:X-YMail-OSG:Subject:From:To:Cc:In-Reply-To:References:Content-Type:Date:Message-Id:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=cTWvvv+bEOAawvr4FghgfNiSRo9qQKg/SzjtNZk6Idrp/o2g6Stg1zoeONp48AcTdUr3hJXntq1k3b5/uVRzEaEcAdC41NYjqa+jlGqcQd6HEOvwX67IU0vmZ86iG0t8XKJfk9CMAPWOnREv0449IY691MiB3T9+84KBJVRg6Ls= ; Original-Received: from unknown (HELO ?192.168.1.3?) (billlinux@rogers.com@74.104.51.86 with plain) by smtp106.rog.mail.re2.yahoo.com with SMTP; 16 Apr 2007 19:58:04 -0000 X-YMail-OSG: 2aLGaIYVM1kret4I8tvbSPZozc.KmaFYShZ4Dq1eQTl52.2EQu50TmOKs3N07Po5XQ-- In-Reply-To: <1176750795.320403.140590@y80g2000hsf.googlegroups.com> X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) X-detected-kernel: Genre and OS details not recognized. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42737 Archived-At: 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 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 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