From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: Re: diary font-lock issue Date: Tue, 16 May 2006 13:56:39 -0400 Message-ID: <1hac9hn99k.fsf@fencepost.gnu.org> References: <8jwtcmqvqm.fsf@fencepost.gnu.org> <4469F4AE.8030909@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1147802223 12215 80.91.229.2 (16 May 2006 17:57:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 16 May 2006 17:57:03 +0000 (UTC) Cc: Glenn Morris , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 16 19:57:01 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fg3mx-0005UG-Un for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 19:56:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fg3mx-0004zh-Hk for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 13:56:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fg3mk-0004zR-NX for emacs-devel@gnu.org; Tue, 16 May 2006 13:56:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fg3mj-0004yV-Ox for emacs-devel@gnu.org; Tue, 16 May 2006 13:56:42 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fg3mj-0004yL-Fp for emacs-devel@gnu.org; Tue, 16 May 2006 13:56:41 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fg3pQ-0003fj-03 for emacs-devel@gnu.org; Tue, 16 May 2006 13:59:28 -0400 Original-Received: from localhost ([127.0.0.1]) by fencepost.gnu.org with esmtp (Exim 4.34) id 1Fg3mi-0002re-8H; Tue, 16 May 2006 13:56:40 -0400 Original-To: martin rudalics X-Spook: $400 million in gold bullion mania EuroFed lock picking X-Ran: Jk5>DWA~`rk'yS#Kd0dcJv/xloY+IECs2X2U0SUpGAvAtylY*R>SILM7<'AeKdY\>k3M@g X-Hue: green X-Attribution: GM In-Reply-To: <4469F4AE.8030909@gmx.at> (martin rudalics's message of "Tue, 16 May 2006 17:50:06 +0200") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) 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:54596 Archived-At: Hi Martin, thanks for the response. martin rudalics wrote: > `foo-font-lock-keywords' will fail to find a match when the end of > `font-lock-fontify-region' is positioned as indicated above. > As soon as `font-lock-extend-region' has undergone its final revision > you should be able to replace the after-change-hook by writing an > appropriate `font-lock-extend-region-function'. If > `font-lock-extend-region' will be regularly called by say > `font-lock-default-fontify-region', you will have to simply check > whether the first character to be fontified is an "=" and you may use > your original code practically unchanged. > > (defun foo-bar (bound) [...] > (setq foo-font-lock-keywords > '((foo-bar 1 'font-lock-keyword-face))) Just looking at this quickly, it looks to be doing the same job as the regexp I originally quoted, but using a function instead to do the match. Setting font-lock-multiline to t in the buffer means that it gets added as a property to all fontified regions, so yours is more elegant (only adding the property where needed), but the two ought to be equivalent, right? > (defun foo-mode-after-change (start end old-len) > (define-derived-mode foo-mode fundamental-mode > "foo" > (set (make-local-variable 'font-lock-defaults) > '(foo-font-lock-keywords t)) > (set (make-local-variable 'font-lock-multiline) t) > (add-hook 'after-change-functions 'foo-mode-after-change nil t)) This all seems very complex. According to: "the font-lock-multiline property should be enough in all cases to make it unnecessary to use an after-change-function hook." That's a long thread, but AFAICS, it seems that for simple keyword fontification, setting font-lock-multiline for the buffer ought to be enough. (Though later on I find: > (i) The matching of keywords which span line breaks; ... setting the font-lock-multiline variable... won't reliably take care of (i) which confuses me.) I'm also confused as to why the initial fontification is not working as it should. There are no "changes" involved in this instance. (Indeed, the fancy diary buffer is not something one edits, so this is about as simple as multiline font-lockign can get.)