From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: diary font-lock issue Date: Tue, 16 May 2006 17:50:06 +0200 Message-ID: <4469F4AE.8030909@gmx.at> References: <8jwtcmqvqm.fsf@fencepost.gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070609090703010401040408" X-Trace: sea.gmane.org 1147795087 13705 80.91.229.2 (16 May 2006 15:58:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 16 May 2006 15:58:07 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 16 17:58:05 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 1Fg1rB-0002fG-Ll for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 17:53:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fg1rB-0000TB-7O for ged-emacs-devel@m.gmane.org; Tue, 16 May 2006 11:53:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fg1qy-0000T6-Hx for emacs-devel@gnu.org; Tue, 16 May 2006 11:52:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fg1qx-0000Rh-0O for emacs-devel@gnu.org; Tue, 16 May 2006 11:52:56 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fg1qw-0000Re-Ui for emacs-devel@gnu.org; Tue, 16 May 2006 11:52:54 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1Fg1tb-0005VY-Hb for emacs-devel@gnu.org; Tue, 16 May 2006 11:55:40 -0400 Original-Received: (qmail invoked by alias); 16 May 2006 15:52:52 -0000 Original-Received: from N813P028.adsl.highway.telekom.at (EHLO [62.47.45.156]) [62.47.45.156] by mail.gmx.net (mp018) with SMTP; 16 May 2006 17:52:52 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: Glenn Morris In-Reply-To: <8jwtcmqvqm.fsf@fencepost.gnu.org> X-Y-GMX-Trusted: 0 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:54587 Archived-At: This is a multi-part message in MIME format. --------------070609090703010401040408 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > elisp: > ------- > (setq foo-font-lock-keywords > '(("\\(\\(?:Fri\\|Mon\\|S\\(?:atur\\|un\\)\\|\\(?:T\\(?:hur\\|ue\\)\\|Wedne\\)s\\)day\\), \\(A\\(?:pril\\|ugust\\)\\|December\\|February\\|J\\(?:anuary\\|u\\(?:ly\\|ne\\)\\)\\|Ma\\(?:rch\\|y\\)\\|\\(?:Novem\\|Octo\\|Septem\\)ber\\) [0-9]+, -?[0-9]+\n=+$" . font-lock-keyword-face))) > > (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)) > > > sample input file: > ------- > Friday, May 5, 2006 > =================== > 9.00 Xxxx Xxxxxx Xxxxx xXxxxxxxxxxxxx > 15.20-15.50 Xxxx Xxxxxxxxxxxxxxxxx > 17.30-19.00 Xxxx Xxxxxxxxxx > 18.00-19.30 Xxxx XXX > > Monday, May 8, 2006 > =================== > 8.00 Xxxxxxxx xx Xxxxxxxx Xxxxxxxxxx xxx Xxxxxxxxxxxxx > 14.30 Xxxxxx XxxxxXXxXxxxxx xxx Xxxx > 15.30-17.00 Xxxx XxxxxXX > 16.45 Xxxx xxx XxxxxXX xxxxxxx > 17.15-18.15 Xxxx XxxxxXx > > Tuesday, May 9, 2006 > ==================== > 14.50 Xxxx xxx Xxxxxxxxxxxxxxxxxxxxx xxxxxxx > 15.30-16.00 Xxxx > > Wednesday, May 10, 2006 <----------------------------------- end of font-lock-fontify-region > ======================= > 20.00-21.15 Xxxxxx Xxxxxx `foo-font-lock-keywords' will fail to find a match when the end of `font-lock-fontify-region' is positioned as indicated above. Earlier it was possible to handle this - in most cases - by setting `font-lock-lines-before' to 1, but I don't know how this will be done in the future. So far you could try the largely untested code I attached. 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. --------------070609090703010401040408 Content-Type: text/plain; name="foo-mode" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="foo-mode" (defun foo-bar (bound) (let (beg end) (and (re-search-forward "\\(\\(?:\\(?:Fri\\|Mon\\|S\\(?:atur\\|un\\)\\|\\(?:T\\(?:hur\\|ue\\)\\|Wedne\\)s\\)day\\)\ , \\(?:A\\(?:pril\\|ugust\\)\\|December\\|February\\|J\\(?:anuary\\|u\\(?:ly\\|ne\\)\\)\ \\|Ma\\(?:rch\\|y\\)\\|\\(?:Novem\\|Octo\\|Septem\\)ber\\) [0-9]+, -?[0-9]+\n\\)\\(=+\n\\)?" bound t) (or (and (> (match-end 0) (match-end 1)) (setq beg (match-beginning 0)) (setq end (match-end 0))) (and (= (match-end 1) bound) (setq beg (match-beginning 0)) (save-excursion (save-match-data (and (looking-at "=+\n") (setq end (match-end 0))))))) (and beg end (or (put-text-property beg end 'font-lock-multiline t) t))))) (setq foo-font-lock-keywords '((foo-bar 1 'font-lock-keyword-face))) (defun foo-mode-after-change (start end old-len) (save-excursion (goto-char start) (beginning-of-line) (when (eq (char-after) ?\=)) (let* ((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) (put-text-property (line-beginning-position 0) (line-beginning-position) 'fontified nil)))) (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)) --------------070609090703010401040408 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------070609090703010401040408--