From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Need help with search based font-locking Date: Tue, 22 Dec 2009 22:45:29 +0100 Message-ID: <877hsen0na.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1261518353 1513 80.91.229.12 (22 Dec 2009 21:45:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Dec 2009 21:45:53 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 22 22:45:46 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 1NNCY6-0004vI-53 for ged-emacs-devel@m.gmane.org; Tue, 22 Dec 2009 22:45:46 +0100 Original-Received: from localhost ([127.0.0.1]:45077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNCY6-0000wW-DE for ged-emacs-devel@m.gmane.org; Tue, 22 Dec 2009 16:45:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNCXz-0000tU-W3 for emacs-devel@gnu.org; Tue, 22 Dec 2009 16:45:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNCXv-0000oV-A6 for emacs-devel@gnu.org; Tue, 22 Dec 2009 16:45:39 -0500 Original-Received: from [199.232.76.173] (port=42931 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNCXv-0000oS-51 for emacs-devel@gnu.org; Tue, 22 Dec 2009 16:45:35 -0500 Original-Received: from out1.smtp.messagingengine.com ([66.111.4.25]:41750) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNCXu-0000ec-TE for emacs-devel@gnu.org; Tue, 22 Dec 2009 16:45:35 -0500 Original-Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 7E9B9C6D3B for ; Tue, 22 Dec 2009 16:45:34 -0500 (EST) Original-Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 22 Dec 2009 16:45:34 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=from:to:subject:date:message-id:mime-version:content-type; s=smtpout; bh=3XJgombtWyKHo2cJ6gmIReBcjaU=; b=gyd1hrDsaznnsSZiCj+/vQQLgNMzyG35fUV/zjhHw+SC1M2rCPpCEPZJSISbCPG6q/4iaWL8y7KwdnLq5uxzGCWR8dVMwhRykot0bbi7gpEw54aviLy6zYzxAhpLwa+r/Hm2SWAUS2DSQ4JWOuoAqj73fywrJMNXLWi4hE55Y1A= X-Sasl-enc: jAo/BOkAZ1Up3S07IO8pdDuxdmn955boOs68djKP5kSZ 1261518334 Original-Received: from thinkpad.tsdh.de (p54AF1F3E.dip0.t-ipconnect.de [84.175.31.62]) by mail.messagingengine.com (Postfix) with ESMTPA id A0A554B995B for ; Tue, 22 Dec 2009 16:45:33 -0500 (EST) Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:118777 Archived-At: 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" "A major mode for GReQL2." [...] (setq font-lock-defaults '((greql-fontlock-keywords-1 greql-fontlock-keywords-2 greql-fontlock-keywords-3))) (add-hook 'after-save-hook 'greql-set-fontlock-keywords-3 t t) [...] (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. The 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 (set (make-local-variable 'font-lock-keywords) greql-fontlock-keywords-3) (redisplay t) but I guess this is very bad style. And even then some things that should be highlighted are not. For those, I need to delete a char and 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. Thanks for help! Tassilo __________ [1] GReQL is a graph query language developed at our institute.