[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mysterious fontification/C++ context issue - Patch for beginning-of-
From: |
Stefan Monnier |
Subject: |
Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw. |
Date: |
Fri, 15 Dec 2006 18:24:14 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux) |
> M-> ran almost instantaneously before `beginning-of-defun-raw' changed.
> And you did fill CC Mode's cache already before the change. I could
> imagine it's because font-locking runs `beginning-of-defun' repeatedly
> for decreasing buffer positions and the `syntax-ppss' cache doesn't
> handle these cases optimally.
I thought "no, can't be, 'cause I was careful to treat this correctly", so
I went and measured it to give a clear proof of it, and much to my surprise
you seemed to be right:
parse-partial-sexp on the whole buffer takes about 0.08 seconds on my laptop
(1.2GHz P-III M, maybe running at 800MHz at that time). syntax-ppss on that
same buffer takes about 0.24s (about 3 times slower: not great, but seemed
possible), but
(syntax-ppss (point-max))
(syntax-ppss (- (point-max) 2000))
(syntax-ppss (- (point-max) 4000))
takes a good 1.8s which doesn't make any sense. After the shock (thinking,
god, I was wrong, how could that be?), I realized that these numbers didn't
make any sense. And sure enough the problem was that in xdisp.c
syntax-begin-function is not nil but set to c-beginning-of-syntax which
doesn't make any sense: if you don't want to use a heuristic, then set the
damn thing to nil.
This variable is set to c-beginning-of-defun in cc-mode.el via
font-lock-beginning-of-syntax-function which is set via font-lock-defaults.
Try the patch below,
Stefan
--- orig/lisp/progmodes/cc-mode.el
+++ mod/lisp/progmodes/cc-mode.el
@@ -597,7 +597,7 @@
"font-lock-keywords-2" "font-lock-keywords-3")))
nil nil
,c-identifier-syntax-modifications
- c-beginning-of-syntax
+ nil
(font-lock-lines-before . 1)
(font-lock-mark-block-function
. c-mark-function)))
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., (continued)
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Alan Mackenzie, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Chong Yidong, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Alan Mackenzie, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for c-basic-common-init, Chong Yidong, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Stefan Monnier, 2006/12/17
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw.,
Stefan Monnier <=
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Chong Yidong, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Chong Yidong, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Chong Yidong, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Chong Yidong, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., martin rudalics, 2006/12/16
- Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw., Stefan Monnier, 2006/12/16