From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [patch] use font-lock Date: Sat, 24 May 2008 16:38:42 -0400 Message-ID: References: <200805231826.27371.danc@merrillpress.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1211661543 745 80.91.229.12 (24 May 2008 20:39:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 May 2008 20:39:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 24 22:39:43 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K00Wk-00085H-1y for ged-emacs-devel@m.gmane.org; Sat, 24 May 2008 22:39:42 +0200 Original-Received: from localhost ([127.0.0.1]:57345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K00Vz-0007Gc-Nx for ged-emacs-devel@m.gmane.org; Sat, 24 May 2008 16:38:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K00Vu-0007FN-TP for emacs-devel@gnu.org; Sat, 24 May 2008 16:38:50 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K00Vt-0007Ds-Eg for emacs-devel@gnu.org; Sat, 24 May 2008 16:38:50 -0400 Original-Received: from [199.232.76.173] (port=56521 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K00Vt-0007Di-Ar for emacs-devel@gnu.org; Sat, 24 May 2008 16:38:49 -0400 Original-Received: from 206-248-174-248.dsl.teksavvy.com ([206.248.174.248]:34105 helo=ceviche.home) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K00Vs-0006gh-Ix for emacs-devel@gnu.org; Sat, 24 May 2008 16:38:48 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 90128B400C; Sat, 24 May 2008 16:38:42 -0400 (EDT) In-Reply-To: <200805231826.27371.danc@merrillpress.com> (Daniel Colascione's message of "Fri, 23 May 2008 18:26:27 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:97666 Archived-At: > I've converted nxml to font-lock. I used the existing fontification machinery > and put it inside a cc-mode-style matcher. Efficiency and output are the > same, but: Looks pretty good. See some comments below. > + "after-change book-keeping. returns a cons containing a > +possibly-enlarged change region. you must still call > +nxml-extend-region on this expanded region to obtain the full > +extent of the area needing refontification. > + > +For book-keeping, call this function even when fontification is > +disabled." > + ;; Work around bug in insert-file-contents, apparently > + (when (> end (1+ (buffer-size))) > + (setq start 1) > + (setq end (1+ (buffer-size)))) Please use (point-max) rather than (1+ (buffer-size)). Could you expand on this "bug in insert-file-contents"? Maybe we can fix it. > +(defun nxml-fontify-matcher (bound) > + "Called as font-lock keyword matcher." > + > + (unless nxml-degraded > + (nxml-debug-change "nxml-fontify-matcher" (point) bound) > + > + (when (< (point) nxml-prolog-end) > + (goto-char (point-min)) > + (nxml-fontify-prolog) > + (goto-char nxml-prolog-end)) Fontifying outside of (point)...bound is likely to lead to problems. Either we should change nxml-fontify-prolog so it can be told to only fontify some part of the prolog, or we need to extend the region according in nxml-extend-region rather than in nxml-fontify-matcher. > + (when (not (eq nxml-last-fontify-end (point))) > + (when (not (equal (char-after) ?\<)) > + (search-backward "<" nxml-prolog-end t)) > + (nxml-ensure-scan-up-to-date) > + (nxml-move-outside-backwards)) This should be done in nxml-extend-region instead. And it indeed seems to be done there, so it should be removed. If it's still needed here, despite nxml-extend-region, then we probably have a bug somewhere (for the same reason as above: Fontifying outside of (point)...bound is likely to lead to problems.) Stefan