aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2001-11-25 22:01:15 +0000
committerStefan Monnier2001-11-25 22:01:15 +0000
commit47fc2db3ebb036b0689f77757451f36c1a29cb15 (patch)
treef01a16a00374e3fa93e01b7819c734fc04b8d251
parent52cf5c37c1ce9e3f6e4f35b91e3c784f6bfbdd7d (diff)
downloademacs-47fc2db3ebb036b0689f77757451f36c1a29cb15.tar.gz
emacs-47fc2db3ebb036b0689f77757451f36c1a29cb15.zip
(font-lock-cache-state, font-lock-cache-position)
(font-lock-ppss-stats, font-lock-ppss): Remove. (font-lock-fontify-syntactically-region): Remove tuning code. (font-lock-compile-keywords): Fix off-by-one bug. (font-lock-set-defaults): Don't set removed vars. (c-keywords): Add `inline'. (c-type-names): Add `_Complex', `_Imaginary' and `_Bool'.
-rw-r--r--lisp/font-lock.el62
1 files changed, 10 insertions, 52 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 447f6db7d45..7019c57151c 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -618,14 +618,13 @@ This is normally set via `font-lock-defaults'.")
618If this is nil, the major mode's syntax table is used. 618If this is nil, the major mode's syntax table is used.
619This is normally set via `font-lock-defaults'.") 619This is normally set via `font-lock-defaults'.")
620 620
621;; If this is nil, we only use the beginning of the buffer if we can't use
622;; `font-lock-cache-position' and `font-lock-cache-state'.
623(defvar font-lock-beginning-of-syntax-function nil 621(defvar font-lock-beginning-of-syntax-function nil
624 "*Non-nil means use this function to move back outside of a syntactic block. 622 "*Non-nil means use this function to move back outside of a syntactic block.
625When called with no args it should leave point at the beginning of any 623When called with no args it should leave point at the beginning of any
626enclosing syntactic block. 624enclosing syntactic block.
627If this is nil, the beginning of the buffer is used (in the worst case). 625If this is nil, the beginning of the buffer is used (in the worst case).
628This is normally set via `font-lock-defaults'.") 626This is normally set via `font-lock-defaults'.
627It is preferable to set `syntax-begin-function' instead.")
629 628
630(defvar font-lock-mark-block-function nil 629(defvar font-lock-mark-block-function nil
631 "*Non-nil means use this function to mark a block of text. 630 "*Non-nil means use this function to mark a block of text.
@@ -1491,44 +1490,6 @@ START should be at the beginning of a line."
1491 1490
1492;;; Syntactic fontification functions. 1491;;; Syntactic fontification functions.
1493 1492
1494;; These record the parse state at a particular position, always the start of a
1495;; line. Used to make `font-lock-fontify-syntactically-region' faster.
1496;; Previously, `font-lock-cache-position' was just a buffer position. However,
1497;; under certain situations, this occasionally resulted in mis-fontification.
1498;; I think the "situations" were deletion with Lazy Lock mode's deferral. sm.
1499(defvar font-lock-cache-state nil)
1500(defvar font-lock-cache-position nil)
1501(defvar font-lock-ppss-stats '(0 . 0.0))
1502
1503(defun font-lock-ppss (start)
1504 (let ((cache (marker-position font-lock-cache-position)))
1505 (if (eq start cache)
1506 ;; Use the cache for the state of `start'.
1507 font-lock-cache-state
1508 ;; Find the state of `start'.
1509 (let ((state
1510 (if (null font-lock-beginning-of-syntax-function)
1511 ;; Use the state at the previous cache position, if any, or
1512 ;; otherwise calculate from `point-min'.
1513 (if (or (null cache) (< start cache))
1514 (progn
1515 (incf (cdr font-lock-ppss-stats) (- start (point-min)))
1516 (parse-partial-sexp (point-min) start))
1517 (incf (cdr font-lock-ppss-stats) (- start cache))
1518 (parse-partial-sexp cache start nil nil
1519 font-lock-cache-state))
1520 ;; Call the function to move outside any syntactic block.
1521 (funcall font-lock-beginning-of-syntax-function)
1522 (incf (cdr font-lock-ppss-stats) (- start (point)))
1523 (parse-partial-sexp (point) start))))
1524 (incf (car font-lock-ppss-stats))
1525 ;; Cache the state and position of `start'.
1526 (setq font-lock-cache-state state)
1527 (set-marker font-lock-cache-position start)
1528 state))))
1529
1530(elp-instrument-list '(font-lock-ppss))
1531
1532(defun font-lock-fontify-syntactically-region (start end &optional loudly ppss) 1493(defun font-lock-fontify-syntactically-region (start end &optional loudly ppss)
1533 "Put proper face on each string and comment between START and END. 1494 "Put proper face on each string and comment between START and END.
1534START should be at the beginning of a line." 1495START should be at the beginning of a line."
@@ -1537,12 +1498,7 @@ START should be at the beginning of a line."
1537 (goto-char start) 1498 (goto-char start)
1538 ;; 1499 ;;
1539 ;; Find the state at the `beginning-of-line' before `start'. 1500 ;; Find the state at the `beginning-of-line' before `start'.
1540 (setq state 1501 (setq state (or ppss (syntax-ppss start)))
1541 ;; We use both functions for benchmarking/tuning purposes.
1542 ;; FIXME: this should be fixed before the release.
1543 (or ppss (let ((state1 (font-lock-ppss start))
1544 (state2 (syntax-ppss start)))
1545 state2)))
1546 ;; 1502 ;;
1547 ;; Find each interesting place between here and `end'. 1503 ;; Find each interesting place between here and `end'.
1548 (while 1504 (while
@@ -1699,7 +1655,7 @@ If REGEXP is non-nil, it means these keywords are used for
1699 (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(") 1655 (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(")
1700 "^\\s(") 1656 "^\\s(")
1701 (0 1657 (0
1702 (if (memq (get-text-property (point) 'face) 1658 (if (memq (get-text-property (1- (point)) 'face)
1703 '(font-lock-string-face font-lock-doc-face 1659 '(font-lock-string-face font-lock-doc-face
1704 font-lock-comment-face)) 1660 font-lock-comment-face))
1705 font-lock-warning-face) 1661 font-lock-warning-face)
@@ -1762,8 +1718,6 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1762 ;; Set fontification defaults iff not previously set. 1718 ;; Set fontification defaults iff not previously set.
1763 (unless font-lock-set-defaults 1719 (unless font-lock-set-defaults
1764 (set (make-local-variable 'font-lock-set-defaults) t) 1720 (set (make-local-variable 'font-lock-set-defaults) t)
1765 (set (make-local-variable 'font-lock-cache-state) nil)
1766 (set (make-local-variable 'font-lock-cache-position) (make-marker))
1767 (make-local-variable 'font-lock-fontified) 1721 (make-local-variable 'font-lock-fontified)
1768 (make-local-variable 'font-lock-multiline) 1722 (make-local-variable 'font-lock-multiline)
1769 (let* ((defaults (or font-lock-defaults 1723 (let* ((defaults (or font-lock-defaults
@@ -2286,7 +2240,9 @@ The value of this variable is used when Font Lock mode is turned on."
2286 "typedef" "extern" "auto" "register" "static" 2240 "typedef" "extern" "auto" "register" "static"
2287 "volatile" "const" 2241 "volatile" "const"
2288 ;; Dan Nicolaescu <done@gnu.org> says this is new. 2242 ;; Dan Nicolaescu <done@gnu.org> says this is new.
2289 "restrict")))) 2243 "restrict"
2244 ;; Henrik Enberg <henrik@enberg.org> says this is new.
2245 "inline"))))
2290 (c-type-specs 2246 (c-type-specs
2291 (eval-when-compile 2247 (eval-when-compile
2292 (regexp-opt '("enum" "struct" "union")))) 2248 (regexp-opt '("enum" "struct" "union"))))
@@ -2298,7 +2254,9 @@ The value of this variable is used when Font Lock mode is turned on."
2298 ,(eval-when-compile 2254 ,(eval-when-compile
2299 (regexp-opt 2255 (regexp-opt
2300 '("char" "short" "int" "long" "signed" "unsigned" 2256 '("char" "short" "int" "long" "signed" "unsigned"
2301 "float" "double" "void" "complex"))) 2257 "float" "double" "void" "complex"
2258 ;; Henrik Enberg <henrik@enberg.org> says these are new.
2259 "_Complex" "_Imaginary" "_Bool")))
2302 c-font-lock-extra-types) 2260 c-font-lock-extra-types)
2303 "\\|")) 2261 "\\|"))
2304 (c-type-names-depth 2262 (c-type-names-depth