From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: GianUberto.Lauri@eng.it (Gian Uberto Lauri) Newsgroups: gmane.emacs.help Subject: Re: Graying out the code in "#if 0/#endif" brace? Date: Wed, 23 Jun 2004 09:00:11 +0200 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <16601.10875.227184.423243@mail.eng.it> References: Reply-To: saint@eng.it NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1087974055 9646 80.91.224.253 (23 Jun 2004 07:00:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 23 Jun 2004 07:00:55 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 23 09:00:47 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 1Bd1kV-0004y4-00 for ; Wed, 23 Jun 2004 09:00:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bd1lq-0004fL-KE for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Jun 2004 03:02:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bd1lk-0004fF-M7 for help-gnu-emacs@gnu.org; Wed, 23 Jun 2004 03:02:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bd1lj-0004f2-1L for help-gnu-emacs@gnu.org; Wed, 23 Jun 2004 03:02:04 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bd1li-0004ez-Vu for help-gnu-emacs@gnu.org; Wed, 23 Jun 2004 03:02:03 -0400 Original-Received: from [212.123.84.94] (helo=sparkfist.tiscali.it) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bd1k0-0005KN-5V for help-gnu-emacs@gnu.org; Wed, 23 Jun 2004 03:00:16 -0400 Original-Received: from cyrano (217.133.20.189) by sparkfist.tiscali.it (7.1.021.3) id 40D1E3810022305B; Wed, 23 Jun 2004 09:00:05 +0200 Original-To: "Zhou Ping" In-Reply-To: X-Mailer: VM 7.18 under Emacs 21.3.50.5 X-attribution: CC X-Zippy: YOW!! Up ahead! It's a DONUT HUT!! 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:19029 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19029 >>>>> "ZP" =3D=3D Zhou Ping writes: ZP> Thank you! I'm not familiar with emacs/LISP programming, do you kno= w any=20 ZP> sample code for reference=3F 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 `(("<\\([%=3F]\\|[a-zA-Z][^>]\\|[!/][a-zA-Z]\\|!--\\)" 1 "\<"))) ;; ("\\([%=3Fa-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)) =09 (prop (get-text-property beg 'display))) (if (and (eq (car-safe prop) 'raise) =09 (member (car-safe (cdr prop)) '(-0.3 +0.3)) =09 (null (cddr prop))) =09 (put-text-property beg next 'display nil)) (setq beg next)))) (defun html-helper-font-lock-last-char-helper () (when (eq (char-syntax (preceding-char)) =3F/) (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 =E8 nil (char font-lock-string-face) (t (set 'char (char-before (point))) (cond ((string-match "[a-zA-Z/]" (char-to-string char)) =09 ;; This is an HTML tag ;=09 (put-text-property (- (point) 2) 'syntax-table '(11)) =09 (save-excursion =09 (cond ((char-equal =3F> (char-after (point))) =09=09 (put-text-property (point) (1+ (point)) 'syntax-table '(12)= )) =09=09 (t =09=09 (html-helper-skip-to-regexp "[^=3F%]>") =09=09 (html-helper-font-lock-last-char-helper)))) =09 html-helper-tag-face) =09 ((string-match "[%=3F]" (char-to-string char)) =09 ;; This is a server script block ;=09 (put-text-property (- (point) 2) 'syntax-table '(11)) =09 (save-excursion =09 (html-helper-skip-to-regexp "[%=3F]>") =09 (html-helper-font-lock-last-char-helper)) =09 html-helper-server-script-face) =09 ((char-equal =3F! char) =09 ;; This is an HTML tag =09 (if (char-equal =3F- (following-char)) ;=09=09 (put-text-property (- (point) 2) 'syntax-table '(11)) =09=09 (progn =09=09 (save-excursion =09=09 (html-helper-skip-to-regexp "-->") =09=09 (html-helper-font-lock-last-char-helper)) =09=09 font-lock-comment-face) =09=09 (progn =09=09 (save-excursion =09=09 (html-helper-skip-to-regexp "[^%=3F]>") =09=09 (html-helper-font-lock-last-char-helper)) =09=09 html-helper-tag-face))) =09 (t =09 ;; This is a comment... =09 nil)))))) (defun html-helper-mark-sexp () (interactive) (let ((here (point)) =09(point-open (1+ (point))) =09(point-close (1- (point)))) (if (not (=3D 0 (skip-chars-backward "^<"))) =09(set 'point-open (1- (point)))) (if (not (=3D 0 (skip-chars-forward "^>"))) =09(set 'point-close (1+ (point)))) =09(goto-char point-open) (if (and (<=3D point-open here) =09 (<=3D here point-close)) =09(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 "^<") =09=09 (skip-chars-backward "<")))) =09(point) (line-beginning-position inizio)))) --=20 /\ =5F=5F=5F /=5F=5F=5F/\=5F=5F|=5F|\=5F|=5F=5F|=5F=5F=5FGian Uberto Lauri=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F //--\ | | \| | Integralista GNUslamico e fancazzista=20 \/