From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Zhou Ping" Newsgroups: gmane.emacs.help Subject: RE: Graying out the code in "#if 0/#endif" brace? Date: Wed, 30 Jun 2004 09:00:32 +0800 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <16601.10875.227184.423243@mail.eng.it> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1088557819 4722 80.91.224.253 (30 Jun 2004 01:10:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 30 Jun 2004 01:10:19 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 30 03:10:11 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BfTc2-0006b4-00 for ; Wed, 30 Jun 2004 03:10:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BfTdj-0003gF-F4 for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Jun 2004 21:11:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BfTdR-0003dR-Vs for help-gnu-emacs@gnu.org; Tue, 29 Jun 2004 21:11:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BfTdL-0003b3-1G for help-gnu-emacs@gnu.org; Tue, 29 Jun 2004 21:11:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BfTdK-0003XE-Pp for help-gnu-emacs@gnu.org; Tue, 29 Jun 2004 21:11:30 -0400 Original-Received: from [65.54.169.56] (helo=hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BfTSk-0003rv-P9 for help-gnu-emacs@gnu.org; Tue, 29 Jun 2004 21:00:35 -0400 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 29 Jun 2004 18:00:33 -0700 Original-Received: from 202.101.8.194 by bay3-dav26.bay3.hotmail.com with DAV; Wed, 30 Jun 2004 01:00:33 +0000 X-Originating-IP: [202.101.8.194] X-Originating-Email: [zhouping_jay@msn.com] X-Sender: zhouping_jay@msn.com Original-To: X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcRY7/TCWuYv/3jmS2OXhWJeRWlDdwFTVt9g In-Reply-To: <16601.10875.227184.423243@mail.eng.it> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-OriginalArrivalTime: 30 Jun 2004 01:00:33.0710 (UTC) FILETIME=[A592E4E0:01C45E3D] X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:19364 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19364 Thanks! I'm a beginner to emacs and do not understand this code well. Do = you know how to use this code? Best regards, Zhou Ping. -----Original Message----- From: Gian Uberto Lauri [mailto:GianUberto.Lauri@eng.it]=20 Sent: 2004=C4=EA6=D4=C223=C8=D5 15:00 To: Zhou Ping Cc: help-gnu-emacs@gnu.org Subject: Re: Graying out the code in "#if 0/#endif" brace? >>>>> "ZP" =3D=3D Zhou Ping writes: ZP> Thank you! I'm not familiar with emacs/LISP programming, do you know = any ZP> sample code for reference? Take a look to the CVS version of the TeX mode or look at this=20 (broken) code: (defvar html-helper-font-lock-syntactic-keywords `(("<\\([%?]\\|[a-zA-Z][^>]\\|[!/][a-zA-Z]\\|!--\\)" 1 "\<"))) ;; ("\\([%?a-zA-Z]\\-\\)>" 2 "\>"))) (defun html-helper-font-lock-unfontify-region (beg end) (font-lock-default-unfontify-region beg end) (while (< beg end) (let ((next (next-single-property-change beg 'display nil end)) (prop (get-text-property beg 'display))) (if (and (eq (car-safe prop) 'raise) (member (car-safe (cdr prop)) '(-0.3 +0.3)) (null (cddr prop))) (put-text-property beg next 'display nil)) (setq beg next)))) (defun html-helper-font-lock-last-char-helper () (when (eq (char-syntax (preceding-char)) ?/) (put-text-property (1- (point)) (point) 'syntax-table '(1))) (unless (eobp) (put-text-property (point) (1+ (point)) 'syntax-table '(12)))) (defun html-helper-skip-to-regexp (regexp) "Goes past the regexp or to point-max (used by html-helper-font-lock-syntactic-face-function" (if (re-search-forward regexp nil t) (backward-char 2) (goto-char (point-max)))) (defun html-helper-font-lock-syntactic-face-function (state) (let ((char (nth 3 state))) (cond ;; char =A8=A8 nil (char font-lock-string-face) (t (set 'char (char-before (point))) (cond ((string-match "[a-zA-Z/]" (char-to-string char)) ;; This is an HTML tag ; (put-text-property (- (point) 2) 'syntax-table '(11)) (save-excursion (cond ((char-equal ?> (char-after (point))) (put-text-property (point) (1+ (point)) 'syntax-table '(12))) (t (html-helper-skip-to-regexp "[^?%]>") (html-helper-font-lock-last-char-helper)))) html-helper-tag-face) ((string-match "[%?]" (char-to-string char)) ;; This is a server script block ; (put-text-property (- (point) 2) 'syntax-table '(11)) (save-excursion (html-helper-skip-to-regexp "[%?]>") (html-helper-font-lock-last-char-helper)) html-helper-server-script-face) ((char-equal ?! char) ;; This is an HTML tag (if (char-equal ?- (following-char)) ; (put-text-property (- (point) 2) 'syntax-table '(11)) (progn (save-excursion (html-helper-skip-to-regexp "-->") (html-helper-font-lock-last-char-helper)) font-lock-comment-face) (progn (save-excursion (html-helper-skip-to-regexp "[^%?]>") (html-helper-font-lock-last-char-helper)) html-helper-tag-face))) (t ;; This is a comment... nil)))))) (defun html-helper-mark-sexp () (interactive) (let ((here (point)) (point-open (1+ (point))) (point-close (1- (point)))) (if (not (=3D 0 (skip-chars-backward "^<"))) (set 'point-open (1- (point)))) (if (not (=3D 0 (skip-chars-forward "^>"))) (set 'point-close (1+ (point)))) (goto-char point-open) (if (and (<=3D point-open here) (<=3D here point-close)) (mark-defun) (push-mark here) (goto-char here)))) (defun html-helper-tag-beginning-position (&optional inizio) "finds the begin of a tag" (save-excursion (if (not (=3D 0 (+ (skip-chars-backward "^<") (skip-chars-backward "<")))) (point) (line-beginning-position inizio)))) --=20 /\ ___ /___/\__|_|\_|__|___Gian Uberto Lauri_____________________ //--\ | | \| | Integralista GNUslamico e fancazzista=20 \/