From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Hegbloom Newsgroups: gmane.emacs.help Subject: Re: Changing font-lock for combined HTML and PHP code?? Date: Tue, 17 Apr 2007 12:49:15 -0600 Message-ID: <1176835755.14001.52.camel@oaktree.lan> References: <1176747727.3057.13.camel@CASE> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-ng/xj7gxHkqcjGF9U3xI" X-Trace: sea.gmane.org 1176835792 6038 80.91.229.12 (17 Apr 2007 18:49:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 17 Apr 2007 18:49:52 +0000 (UTC) Cc: EMACS List To: William Case Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 17 20:49:45 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 1HdskJ-0006U5-H6 for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Apr 2007 20:49:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hdsp3-0002QM-KZ for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Apr 2007 14:54:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hdsok-0002NG-64 for help-gnu-emacs@gnu.org; Tue, 17 Apr 2007 14:54:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hdsoi-0002L3-98 for help-gnu-emacs@gnu.org; Tue, 17 Apr 2007 14:54:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hdsoi-0002Kp-3n for help-gnu-emacs@gnu.org; Tue, 17 Apr 2007 14:54:16 -0400 Original-Received: from wr-out-0506.google.com ([64.233.184.229]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hdsjw-0006aL-T7 for help-gnu-emacs@gnu.org; Tue, 17 Apr 2007 14:49:21 -0400 Original-Received: by wr-out-0506.google.com with SMTP id i23so1869158wra for ; Tue, 17 Apr 2007 11:49:18 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=tkpJhUhIgX3O/y0G8I9/GjGn2K5Pht5076LNaK+9laS+j8wgoJhV/W2bLHcZgF3u29ORE5ORuvIm3HacnAWaiUix86CxtS2Rjcs5/28uzWRoMrVjAClSKOwjf6bY/VQ5ewcE3GSi7pe3p6A+jH9ZLz9ffJy4qxA71x7/zdQEXWw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=lQtyCz4kfFJTj30dTier0W71XDuNGC7LcvIcon41GeU8ZkVrfveahYXUjd3j0Hp+ssWqsx1lvateJgVX0RA4tcRAMuH9fQ90YYysQLfOS4E4C1zFOj7LQmgLrW+fcUgWa9c1koGlHwBLDiOggx/hY+3vWzFvcAEqOce4Fqe05x4= Original-Received: by 10.114.195.19 with SMTP id s19mr1450113waf.1176835757638; Tue, 17 Apr 2007 11:49:17 -0700 (PDT) Original-Received: from ?192.168.1.64? ( [67.166.69.81]) by mx.google.com with ESMTP id m29sm1763859poh.2007.04.17.11.49.16; Tue, 17 Apr 2007 11:49:16 -0700 (PDT) In-Reply-To: <1176747727.3057.13.camel@CASE> X-Mailer: Evolution 2.10.1 X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) 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:42759 Archived-At: --=-ng/xj7gxHkqcjGF9U3xI Content-Type: text/plain Content-Transfer-Encoding: 7bit On Mon, 2007-04-16 at 14:22 -0400, William Case wrote: > 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. > > In case I am misusing terminology, by tag I mean expressions like >

...

in HTML; in PHP. The attached elisp file uses mmm-mode, psgml html mode, and php-mode (which I obtained from Debian or via a google search) to make it do what you want. I have not used the php stuff in there very much, so it will probably need a small amount of work. --=-ng/xj7gxHkqcjGF9U3xI Content-Description: Content-Disposition: inline; filename=mmm-html-ext.el Content-Type: text/x-emacs-lisp; charset=utf-8 Content-Transfer-Encoding: 7bit ;;; mmm-html-ext.el ;;; (require 'css-mode) (mmm-add-classes '((embedded-css :submode css-mode :face mmm-declaration-submode-face :front "]*>" :back ""))) (require 'generic-x) (mmm-add-classes '((embedded-javascript :submode javascript-generic-mode :face mmm-code-submode-face :front "" :back ""))) ;;; At the top of a mason component written in the style that I like ;;; to use is: ;;; ;;; ;;; ;;; ;;; The thing is that those should not appear mid-document in the ;;; generated output. It's computationaly cheaper to comment them off ;;; than to filter them out with a <%filter> section. This next block ;;; of code sets things up so that the XML and DOCTYPE declarations ;;; are automatically commented off in the file saved to disk, but not ;;; commented off in the editor buffer, so that the normal mmm-mode ;;; and PSGML mode DTD parsing can take place. ;;; ;;; Copyright (c) 2005 ;;; Karl Hegbloom ;;; GPL ;;; (defun mason-comment-decls (arg) (interactive "p") (save-excursion (save-restriction (widen) (goto-char (point-min)) (cond ((and (< arg 0) (looking-at "%#")) (progn (delete-char 2) (forward-line 1) (beginning-of-line) (delete-char 2))) ((and (>= arg 0) (not (looking-at "%#"))) (progn (insert "%#") (forward-line 1) (beginning-of-line) (insert "%#"))))))) (defvar mason-comment-decls nil) (make-variable-buffer-local 'mason-comment-decls) (defun %mason-file-hook (arg) (when (and mmm-mode mason-comment-decls) (mason-comment-decls arg))) (defun mason-find-file-hook () (%mason-file-hook -1) (set-buffer-modified-p nil)) (defun mason-write-file-hook () (%mason-file-hook 1)) (defun mason-after-save-hook () (mason-find-file-hook)) (add-hook 'find-file-hooks #'mason-find-file-hook) (add-hook 'write-file-hooks #'mason-write-file-hook) (add-hook 'after-save-hook #'mason-after-save-hook) (require 'php-mode) (setq auto-mode-alist (remove-if #'(lambda (elt) (eq (cdr elt) 'php-mode)) auto-mode-alist)) (let ((ext '("\\.php[345]?\\'" "\\.phtml\\'"))) (while ext (add-to-list 'auto-mode-alist (cons (car ext) 'html-mode)) (add-to-list 'mmm-mode-ext-classes-alist (list 'html-mode (car ext) 'php)) (setq ext (cdr ext)))) (mmm-add-group 'php '((php-xml-processing-directive :submode php-mode :face mmm-code-submode-face :front "<[?]php" :back "[?]>" :insert ((?p php nil @ "" @)) ) (php-inline= :submode php-mode :face mmm-output-submode-face :front "<[?]=" :back "[?]>" :insert ((?= php nil @ "" @)) ) (php-inline :submode php-mode :face mmm-output-submode-face :front "<[?]" :back "[?]>" :insert ((?\? php nil @ "" @)) ) (php-inline-asp= :submode php-mode :face mmm-output-submode-face :front "<%=" :back "%>" ) (php-inline-asp :submode php-mode :face mmm-output-submode-face :front "<%" :back "%>" ) (php-script :submode php-mode :face mmm-code-submode-face :front "" ) )) (mmm-add-group 'HTML::Template '((html-template-tag :submode text-mode :face mmm-special-submode-face :front "" :include-back t :insert ((?t HTML::Template nil @ @ "" @ @)) ))) (provide 'mmm-html-ext) --=-ng/xj7gxHkqcjGF9U3xI Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --=-ng/xj7gxHkqcjGF9U3xI--