From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Richard M. Stallman" Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows] Date: Sun, 12 Feb 2006 23:40:14 -0500 Message-ID: References: Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1139805678 21560 80.91.229.2 (13 Feb 2006 04:41:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 13 Feb 2006 04:41:18 +0000 (UTC) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org Original-X-From: cc-mode-help-admin@lists.sourceforge.net Mon Feb 13 05:41:14 2006 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F8VWP-0000Av-4W for sf-cc-mode-help@m.gmane.org; Mon, 13 Feb 2006 05:41:09 +0100 Original-Received: from sc8-sf-list1-b.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id 62D8A132F9; Sun, 12 Feb 2006 20:41:08 -0800 (PST) Original-Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1F8VVZ-0003iG-D8 for cc-mode-help@lists.sourceforge.net; Sun, 12 Feb 2006 20:40:17 -0800 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by mail.sourceforge.net with esmtps (TLSv1:RC4-SHA:128) (Exim 4.44) id 1F8VVY-0003UD-8m for cc-mode-help@lists.sourceforge.net; Sun, 12 Feb 2006 20:40:17 -0800 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1F8VVW-0007Oi-CN; Sun, 12 Feb 2006 23:40:14 -0500 Original-To: Ralf Angeli In-reply-to: (message from Ralf Angeli on Sun, 12 Feb 2006 14:06:49 +0100) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 Original-Sender: cc-mode-help-admin@lists.sourceforge.net Errors-To: cc-mode-help-admin@lists.sourceforge.net X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: Bug reports, feature requests, and general talk about CC Mode. List-Post: List-Help: List-Subscribe: , List-Archive: X-Original-Date: Sun, 12 Feb 2006 23:40:14 -0500 Xref: news.gmane.org gmane.emacs.cc-mode.general:2977 gmane.emacs.devel:50441 Archived-At: Here's the change I was talking about. Would someone please adapt this _now_ to the current sources, and install it? Then please rename before-font-lock-after-change-function to font-lock-extend-region-function, and rename font-lock-run-before-after-change-hook to font-lock-extend-region? Then please ack this message. ;;;;;; Changelog entry 2002-05-10 Alan Mackenzie The following set of changes allows a major mode dynamically to specify the region to fontify after a buffer change. (fast-lock.el doesn't need changing.) * font-lock.el New abnormal hook before-font-lock-after-change-function, New function font-lock-run-before-after-change-hook. Changed font-lock-after-change-function. * jit-lock.el Changed jit-lock-after-change * lazy-lock.el Changed lazy-lock-defer-line-after-change and lazy-lock-defer-rest-after-change. ;;;;;; End of Changelog entry ;;;;;; Patch diff -c -x ChangeLog -x Makefile -x README /usr/src/packages/BUILD/emacs-21.1/lisp/font-lock.el NEW/font-lock.el *** /usr/src/packages/BUILD/emacs-21.1/lisp/font-lock.el Wed Sep 5 13:36:29 2001 --- NEW/font-lock.el Fri May 10 19:24:25 2002 *************** *** 1260,1270 **** '(face nil syntax-table nil font-lock-multiline nil) '(face nil font-lock-multiline nil))))) ;; Called when any modification is made to buffer text. (defun font-lock-after-change-function (beg end old-len) ! (let ((inhibit-point-motion-hooks t)) (save-excursion (save-match-data ;; Rescan between start of lines enclosing the region. (font-lock-fontify-region (progn (goto-char beg) (beginning-of-line) (point)) --- 1260,1309 ---- '(face nil syntax-table nil font-lock-multiline nil) '(face nil font-lock-multiline nil))))) + (defvar before-font-lock-after-change-function nil + "If set to a function, this can specify the region to fontify after a change. + + This variable is a buffer-local abnormal hook whose value, if set, should be a + single function. The function gets called from the active font-lock + after-change function, and is intended to allow a major mode to calculate for + itself the region to be fontified after a buffer change. + + The function is given three parameters, the standard BEG, END and OLD-LEN from + after-change-functions. It should return either a cons of the beginning and end + buffer-positions \(in that order\) of the region to fontify, or nil (in which + case the default region will be used).") + (make-variable-buffer-local 'before-font-lock-after-change-function) + + (defun font-lock-run-before-after-change-hook (beg end old-len) + "Run the hook function, if any, in before-font-lock-after-change-function, + returning its value (a cons of beg and end), if it's valid, else nil. + + BEG END and OLD-LEN are the three parameters supplied by + after-change-functions." + (cond ((null before-font-lock-after-change-function) nil) + ((not (functionp before-font-lock-after-change-function)) + (message "before-font-lock-after-change-function's value is not a \ + function in buffer %S" + (buffer-name)) + nil) + (t (let ((region (funcall before-font-lock-after-change-function beg end old-len))) + (cond ((null region) nil) + ((or (not (consp region)) + (not (wholenump (car region))) (not (wholenump (cdr region))) + (not (<= (car region) (cdr region)))) + (message "before-font-lock-after-change-function returned %S. \ + This isn't a cons \(beg.end\), with beg and end numbers, and beg <= end") + nil) + (t region)))))) + ;; Called when any modification is made to buffer text. (defun font-lock-after-change-function (beg end old-len) ! (let ((inhibit-point-motion-hooks t) region) (save-excursion (save-match-data + ;; Does the major mode have its own ideas about the region to fontify? + (setq region (font-lock-run-before-after-change-hook beg end old-len)) + (if region (setq beg (car region) end (cdr region))) ;; Rescan between start of lines enclosing the region. (font-lock-fontify-region (progn (goto-char beg) (beginning-of-line) (point)) diff -c -x ChangeLog -x Makefile -x README /usr/src/packages/BUILD/emacs-21.1/lisp/jit-lock.el NEW/jit-lock.el *** /usr/src/packages/BUILD/emacs-21.1/lisp/jit-lock.el Mon Jul 16 12:22:58 2001 --- NEW/jit-lock.el Fri May 10 18:59:36 2002 *************** *** 426,431 **** --- 426,434 ---- (when jit-lock-mode (save-excursion (with-buffer-prepared-for-jit-lock + ;; Does the major mode have its own ideas about the region to fontify? + (let ((region (font-lock-run-before-after-change-hook start end old-len))) + (if region (setq start (car region) end (cdr region)))) ;; It's important that the `fontified' property be set from the ;; beginning of the line, else font-lock will properly change the ;; text's face, but the display will have been done already and will diff -c -x ChangeLog -x Makefile -x README /usr/src/packages/BUILD/emacs-21.1/lisp/lazy-lock.el NEW/lazy-lock.el *** /usr/src/packages/BUILD/emacs-21.1/lisp/lazy-lock.el Thu Aug 16 14:25:15 2001 --- NEW/lazy-lock.el Fri May 10 19:00:47 2002 *************** *** 771,776 **** --- 771,779 ---- (save-buffer-state nil (unless (memq (current-buffer) lazy-lock-buffers) (push (current-buffer) lazy-lock-buffers)) + ;; Does the major mode have its own ideas about what to fontify? + (let ((region (font-lock-run-before-after-change-hook beg end old-len))) + (if region (setq beg (car region) end (cdr region)))) (remove-text-properties (max (1- beg) (point-min)) (min (1+ end) (point-max)) '(lazy-lock nil)))) *************** *** 784,789 **** --- 787,795 ---- (push (current-buffer) lazy-lock-buffers)) (save-restriction (widen) + ;; Does the major mode have its own ideas about what to fontify? + (let ((region (font-lock-run-before-after-change-hook beg end old-len))) + (if region (setq beg (car region) end (cdr region)))) (remove-text-properties (max (1- beg) (point-min)) (point-max) '(lazy-lock nil))))) ;;;;;; end of patch. -- Alan Mackenzie (Munich, Germany) ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642