From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Need help with search based font-locking Date: Thu, 24 Dec 2009 14:48:49 +0100 Message-ID: References: <877hsen0na.fsf@thinkpad.tsdh.de> <87637yj64c.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1261662569 16728 80.91.229.12 (24 Dec 2009 13:49:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Dec 2009 13:49:29 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 24 14:49: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 1NNo49-0007Tn-Q6 for ged-emacs-devel@m.gmane.org; Thu, 24 Dec 2009 14:49:22 +0100 Original-Received: from localhost ([127.0.0.1]:48375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNo4A-0007yH-58 for ged-emacs-devel@m.gmane.org; Thu, 24 Dec 2009 08:49:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNo43-0007xt-DQ for emacs-devel@gnu.org; Thu, 24 Dec 2009 08:49:15 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNo3y-0007wO-Ou for emacs-devel@gnu.org; Thu, 24 Dec 2009 08:49:14 -0500 Original-Received: from [199.232.76.173] (port=43539 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNo3y-0007wL-K1 for emacs-devel@gnu.org; Thu, 24 Dec 2009 08:49:10 -0500 Original-Received: from mail-yw0-f177.google.com ([209.85.211.177]:45706) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNo3y-000516-8h for emacs-devel@gnu.org; Thu, 24 Dec 2009 08:49:10 -0500 Original-Received: by ywh7 with SMTP id 7so747603ywh.24 for ; Thu, 24 Dec 2009 05:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=KC0EgNyGvvJwI54wYIfhi1tUOXgGNqRE5wW8eepT+io=; b=Ujn3Tb88w/sybDwCO3ZR2ABLM5pNWehf89bbOti4I5+JOw3ApmAJV+mvY39CUlTA77 SFXbrBa9DLrpbMHACgClkByy+qGseLnzMJ6ZlnUGKskbGq5TtqrBbvIuW8ssAMbPQhWF R7L8qJB+BH9GqtzfsIM3CM8rzGk9qXsRC03TA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=GY2mwPaXn1WHp60UqOPz/jak7GX8cn4LL6wdfW5NMf5JGxTQ0EWkxgytJorgc55l7V S+46z1+ZzyRbh/rBb4iuTNhFta5V4XwaeUjrIRZXSBQPvZmf5iqmsYs0re7neDHpR1tt qTpjfr6CZpOJLilLWZNrcVAoMKNx6EHFRii/s= Original-Received: by 10.101.105.2 with SMTP id h2mr18297537anm.28.1261662549333; Thu, 24 Dec 2009 05:49:09 -0800 (PST) In-Reply-To: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:118810 Archived-At: On Thu, Dec 24, 2009 at 5:46 AM, Stefan Monnier wrote: >> + (defun lock-font-refresh-defaults () >> + =C2=A0 "Refresh defaults and restart fontification. >> + Set defaults again as if function `font-lock-defaults' had not >> + been called and then restart fontification." >> + =C2=A0 (before-lock-mode -1) >> + =C2=A0 (kill-local-variable 'font-lock-set-defaults) >> + =C2=A0 (font-lock-mode 1)) > > I thought I was the only one who could muster so many typos in so few > lines. =C2=A0BTW, the docstring should be more radical without reference = to > internal functions like font-lock-set-defaults, as in "Restart, > recomputing everything from scratch" and then explain that it's > typically used to let font-lock react to external changes in variables > like font-lock-defaults and keywords. Ehum ;-) This is slightly better: Index: font-lock.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/font-lock.el,v retrieving revision 1.354 diff -c -r1.354 font-lock.el *** font-lock.el 2 Oct 2009 03:48:41 -0000 1.354 --- font-lock.el 24 Dec 2009 13:47:41 -0000 *************** *** 1767,1772 **** --- 1767,1790 ---- (defvar font-lock-set-defaults nil) ; Whether we have set up defaults. + (defun font-lock-refresh-defaults () + "Restart fontification in current buffer after recomputing from default= s. + Recompute fontification variables using `font-lock-defaults' (or, + if nil, using `font-lock-defaults-alist') and + `font-lock-maximum-decoration'. Then restart fontification. + + Use this function when you have changed any of the above + variables directly. + + Note: This function will erase modifications done by + `font-lock-add-keywords' or `font-lock-remove-keywords', but will + preserve `hi-lock-mode' highlighting patterns \(and any other + setting set up in `fontlock-mode-hook')." + (let (font-lock-mode-hook) + (font-lock-mode -1)) + (kill-local-variable 'font-lock-set-defaults) + (font-lock-mode 1)) + (defvar font-lock-mode-major-mode) (defun font-lock-set-defaults () "Set fontification defaults appropriately for this mode.