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: Tue, 22 Dec 2009 23:43:27 +0100 Message-ID: References: <877hsen0na.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 1261521923 12640 80.91.229.12 (22 Dec 2009 22:45:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Dec 2009 22:45:23 +0000 (UTC) Cc: emacs-devel@gnu.org To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 22 23:45:16 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 1NNDST-0003dH-Le for ged-emacs-devel@m.gmane.org; Tue, 22 Dec 2009 23:44:01 +0100 Original-Received: from localhost ([127.0.0.1]:49039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNDST-0004gE-Ts for ged-emacs-devel@m.gmane.org; Tue, 22 Dec 2009 17:44:01 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNDSM-0004cd-Sj for emacs-devel@gnu.org; Tue, 22 Dec 2009 17:43:54 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNDSI-0004St-5B for emacs-devel@gnu.org; Tue, 22 Dec 2009 17:43:54 -0500 Original-Received: from [199.232.76.173] (port=38840 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNDSH-0004Sj-SJ for emacs-devel@gnu.org; Tue, 22 Dec 2009 17:43:49 -0500 Original-Received: from mail-yw0-f202.google.com ([209.85.211.202]:35111) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNDSH-0005Zp-Ba for emacs-devel@gnu.org; Tue, 22 Dec 2009 17:43:49 -0500 Original-Received: by ywh40 with SMTP id 40so6988121ywh.26 for ; Tue, 22 Dec 2009 14:43:47 -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=YiEIUGq/V3SnB2kPY3kucQXiTVPUpDbxCAPHwaJKML4=; b=srgcYA6mtphUpYnj2IGi1KXMwy+28UfxwtnY2jAitBKEHDUzciQB6YLRW1TdgfTNQP 3qYxUvI3tgQAFrsXerc0KqYz65hgJRGRUIk/r+1lQHVydU1vIzf9Wz2Aqo6MHtFviB06 UVolY4YnRsgF7PXrvJWCkJmU932vZpYCgQ0ks= 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=w2Xkpank/jHkiS+MDHcNm2J+Hmq7riGkwgHOYzOusBzujCO80uDAP+o4K5a9Hk/OjY 1kcKnIVh4kFoYcWrTPqOTm004fUrF5omrRb5S4+gHFpHT8jj3dLCiLS4h+hp/WpEY3Vj tJFQasMkok5BReUfqnlkx0+KvWftGYp2qer4k= Original-Received: by 10.101.180.19 with SMTP id h19mr14738863anp.137.1261521827245; Tue, 22 Dec 2009 14:43:47 -0800 (PST) In-Reply-To: <877hsen0na.fsf@thinkpad.tsdh.de> 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:118779 Archived-At: On Tue, Dec 22, 2009 at 10:45 PM, Tassilo Horn wro= te: > Hi all, > > in my greql-mode [1], I setup font-locking like that: > > --8<---------------cut here---------------start------------->8--- > (define-derived-mode greql-mode text-mode "GReQL" > =C2=A0"A major mode for GReQL2." > =C2=A0[...] > =C2=A0(setq font-lock-defaults > =C2=A0 =C2=A0 =C2=A0 =C2=A0'((greql-fontlock-keywords-1 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 greql-fontlock-keywords-2 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 greql-fontlock-keywords-3))) > =C2=A0(add-hook 'after-save-hook 'greql-set-fontlock-keywords-3 t t) > =C2=A0[...] > =C2=A0(define-key greql-mode-map (kbd "C-c C-f") 'greql-format)) > --8<---------------cut here---------------end--------------->8--- > > `greql-fontlock-keywords-3's value is not static, it frequently changes. > So I update it after saving (as you can see), and at several other > places. =C2=A0The updating of the variable works, but how do I tell font-= lock > that it should use the new value and re-fontify the current buffer? > > As a brute-force workaround, I can do > > =C2=A0 (set (make-local-variable 'font-lock-keywords) > =C2=A0 =C2=A0 =C2=A0 =C2=A0greql-fontlock-keywords-3) > =C2=A0 (redisplay t) > > but I guess this is very bad style. =C2=A0And even then some things that > should be highlighted are not. =C2=A0For those, I need to delete a char a= nd > add it back to apply the new fontification. > > I really tried to dig into the elisp manual, but I couldn't find any > help with font-lock-defaults KEYWORDS that aren't fixed. Maybe you can use jit-lock-refontify?