From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: "Font-lock is limited to text matching" is a myth Date: Tue, 11 Aug 2009 10:53:13 -0400 Message-ID: References: <7b501d5c0908091634ndfba631vd9db6502db301097@mail.gmail.com> <200908101335.24002.danc@merrillprint.com> <87my67s8mr.fsf@randomsample.de> <1249942011.29022.15.camel@projectile.siege-engine.com> <1249955428.29022.186.camel@projectile.siege-engine.com> <9c768dc60908102347v57bdf38ara9fe2179f68c07e4@mail.gmail.com> <42D4C5C5-E702-4E30-AB95-A016280F20C7@merrillpress.com> <87r5vipgbs.fsf@catnip.gol.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1250002531 15418 80.91.229.12 (11 Aug 2009 14:55:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2009 14:55:31 +0000 (UTC) Cc: emacs-devel@gnu.org, David Engster , Daniel Colascione , Lennart Borgman , Deniz Dogan , Stefan Monnier , Steve Yegge , Leo To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 11 16:55:22 2009 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 1Maskw-0000hs-Fn for ged-emacs-devel@m.gmane.org; Tue, 11 Aug 2009 16:55:18 +0200 Original-Received: from localhost ([127.0.0.1]:37364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Masku-00089C-Ra for ged-emacs-devel@m.gmane.org; Tue, 11 Aug 2009 10:55:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MasjA-00075u-BZ for emacs-devel@gnu.org; Tue, 11 Aug 2009 10:53:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Masj5-00073d-5m for emacs-devel@gnu.org; Tue, 11 Aug 2009 10:53:27 -0400 Original-Received: from [199.232.76.173] (port=44258 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Masj5-00073Y-1u for emacs-devel@gnu.org; Tue, 11 Aug 2009 10:53:23 -0400 Original-Received: from vpn.merrillpress.com ([64.61.107.78]:56353) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Masj2-000827-E4; Tue, 11 Aug 2009 10:53:20 -0400 Original-Received: from cpe-67-246-181-235.buffalo.res.rr.com ([67.246.181.235] helo=[192.168.1.103]) by mars.merrillpress.net with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1Masix-0003LP-MB; Tue, 11 Aug 2009 10:53:15 -0400 In-Reply-To: <87r5vipgbs.fsf@catnip.gol.com> X-Mailer: Apple Mail (2.936) X-detected-operating-system: by monty-python.gnu.org: GNU/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:114058 Archived-At: On Aug 11, 2009, at 10:37 AM, Miles Bader wrote: > Daniel Colascione writes: >>> Note: diagnostic messages in js2-mode are highlighted using >>> overlays. >>> I tried using overlays for all highlighting but it was unacceptably >>> slow and had a tendency to crash Emacs. >> >> I've had the same thought. Just as in aside, overlays seem like a >> much >> better conceptual fit for fontification than text properties do. > > Why? AIUI, text properties are considered *part* of the document being edited, which is why modifying text properties modifies the buffer modified flag, why they appear in the undo list, and so on, whereas overlays are for transient, regenerable information *about* the text in the document. Fontification is definitely regenerable, transient information, and so should use overlays. I'm also not particularly fond of fontification being carried around when I kill and yank. But like you said, these are minor issues and can be worked around. It's no big deal, and text properties perform much better on GNU Emacs. (IIRC, each overlay actually uses a pair of markers. It's no wonder that using hundreds or thousands of them is slow.) > [Aside from the "changing text-properties affect buffer-modified > status" > silliness, which I think is probably a mistake, but that's easy enough > to work around.] Don't forget the undo entries too. Actually, the full list comes from font-lock.el: (defmacro save-buffer-state (varlist &rest body) "Bind variables according to VARLIST and eval BODY restoring buffer state." (declare (indent 1) (debug let)) (let ((modified (make-symbol "modified"))) `(let* ,(append varlist `((,modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename)) (progn ,@body) (unless ,modified (restore-buffer-modified-p nil)))))