/[emacs]/emacs/lisp/font-lock.el
ViewVC logotype

Diff of /emacs/lisp/font-lock.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.185 by monnier, Sun Nov 18 02:10:01 2001 UTC revision 1.186 by monnier, Sun Nov 25 22:01:15 2001 UTC
# Line 618  This is normally set via `font-lock-defa Line 618  This is normally set via `font-lock-defa
618  If this is nil, the major mode's syntax table is used.  If this is nil, the major mode's syntax table is used.
619  This is normally set via `font-lock-defaults'.")  This is normally set via `font-lock-defaults'.")
620    
 ;; If this is nil, we only use the beginning of the buffer if we can't use  
 ;; `font-lock-cache-position' and `font-lock-cache-state'.  
621  (defvar font-lock-beginning-of-syntax-function nil  (defvar font-lock-beginning-of-syntax-function nil
622    "*Non-nil means use this function to move back outside of a syntactic block.    "*Non-nil means use this function to move back outside of a syntactic block.
623  When called with no args it should leave point at the beginning of any  When called with no args it should leave point at the beginning of any
624  enclosing syntactic block.  enclosing syntactic block.
625  If this is nil, the beginning of the buffer is used (in the worst case).  If this is nil, the beginning of the buffer is used (in the worst case).
626  This is normally set via `font-lock-defaults'.")  This is normally set via `font-lock-defaults'.
627    It is preferable to set `syntax-begin-function' instead.")
628    
629  (defvar font-lock-mark-block-function nil  (defvar font-lock-mark-block-function nil
630    "*Non-nil means use this function to mark a block of text.    "*Non-nil means use this function to mark a block of text.
# Line 1491  START should be at the beginning of a li Line 1490  START should be at the beginning of a li
1490    
1491  ;;; Syntactic fontification functions.  ;;; Syntactic fontification functions.
1492    
 ;; These record the parse state at a particular position, always the start of a  
 ;; line.  Used to make `font-lock-fontify-syntactically-region' faster.  
 ;; Previously, `font-lock-cache-position' was just a buffer position.  However,  
 ;; under certain situations, this occasionally resulted in mis-fontification.  
 ;; I think the "situations" were deletion with Lazy Lock mode's deferral.  sm.  
 (defvar font-lock-cache-state nil)  
 (defvar font-lock-cache-position nil)  
 (defvar font-lock-ppss-stats '(0 . 0.0))  
   
 (defun font-lock-ppss (start)  
   (let ((cache (marker-position font-lock-cache-position)))  
     (if (eq start cache)  
         ;; Use the cache for the state of `start'.  
         font-lock-cache-state  
       ;; Find the state of `start'.  
       (let ((state  
              (if (null font-lock-beginning-of-syntax-function)  
                  ;; Use the state at the previous cache position, if any, or  
                  ;; otherwise calculate from `point-min'.  
                  (if (or (null cache) (< start cache))  
                      (progn  
                        (incf (cdr font-lock-ppss-stats) (- start (point-min)))  
                        (parse-partial-sexp (point-min) start))  
                    (incf (cdr font-lock-ppss-stats) (- start cache))  
                    (parse-partial-sexp cache start nil nil  
                                                    font-lock-cache-state))  
                ;; Call the function to move outside any syntactic block.  
                (funcall font-lock-beginning-of-syntax-function)  
                (incf (cdr font-lock-ppss-stats) (- start (point)))  
                (parse-partial-sexp (point) start))))  
         (incf (car font-lock-ppss-stats))  
         ;; Cache the state and position of `start'.  
         (setq font-lock-cache-state state)  
         (set-marker font-lock-cache-position start)  
         state))))  
   
 (elp-instrument-list '(font-lock-ppss))  
   
1493  (defun font-lock-fontify-syntactically-region (start end &optional loudly ppss)  (defun font-lock-fontify-syntactically-region (start end &optional loudly ppss)
1494    "Put proper face on each string and comment between START and END.    "Put proper face on each string and comment between START and END.
1495  START should be at the beginning of a line."  START should be at the beginning of a line."
# Line 1537  START should be at the beginning of a li Line 1498  START should be at the beginning of a li
1498      (goto-char start)      (goto-char start)
1499      ;;      ;;
1500      ;; Find the state at the `beginning-of-line' before `start'.      ;; Find the state at the `beginning-of-line' before `start'.
1501      (setq state      (setq state (or ppss (syntax-ppss start)))
           ;; We use both functions for benchmarking/tuning purposes.  
           ;; FIXME: this should be fixed before the release.  
           (or ppss (let ((state1 (font-lock-ppss start))  
                          (state2 (syntax-ppss start)))  
                      state2)))  
1502      ;;      ;;
1503      ;; Find each interesting place between here and `end'.      ;; Find each interesting place between here and `end'.
1504      (while      (while
# Line 1699  If REGEXP is non-nil, it means these key Line 1655  If REGEXP is non-nil, it means these key
1655                         (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(")                         (concat "^\\(?:" defun-prompt-regexp "\\)?\\s(")
1656                       "^\\s(")                       "^\\s(")
1657                    (0                    (0
1658                     (if (memq (get-text-property (point) 'face)                     (if (memq (get-text-property (1- (point)) 'face)
1659                               '(font-lock-string-face font-lock-doc-face                               '(font-lock-string-face font-lock-doc-face
1660                                 font-lock-comment-face))                                 font-lock-comment-face))
1661                         font-lock-warning-face)                         font-lock-warning-face)
# Line 1762  Sets various variables using `font-lock- Line 1718  Sets various variables using `font-lock-
1718    ;; Set fontification defaults iff not previously set.    ;; Set fontification defaults iff not previously set.
1719    (unless font-lock-set-defaults    (unless font-lock-set-defaults
1720      (set (make-local-variable 'font-lock-set-defaults)          t)      (set (make-local-variable 'font-lock-set-defaults)          t)
     (set (make-local-variable 'font-lock-cache-state)           nil)  
     (set (make-local-variable 'font-lock-cache-position)        (make-marker))  
1721      (make-local-variable 'font-lock-fontified)      (make-local-variable 'font-lock-fontified)
1722      (make-local-variable 'font-lock-multiline)      (make-local-variable 'font-lock-multiline)
1723      (let* ((defaults (or font-lock-defaults      (let* ((defaults (or font-lock-defaults
# Line 2286  The value of this variable is used when Line 2240  The value of this variable is used when
2240                          "typedef" "extern" "auto" "register" "static"                          "typedef" "extern" "auto" "register" "static"
2241                          "volatile" "const"                          "volatile" "const"
2242                          ;; Dan Nicolaescu <done@gnu.org> says this is new.                          ;; Dan Nicolaescu <done@gnu.org> says this is new.
2243                          "restrict"))))                          "restrict"
2244                            ;; Henrik Enberg <henrik@enberg.org> says this is new.
2245                            "inline"))))
2246         (c-type-specs         (c-type-specs
2247          (eval-when-compile          (eval-when-compile
2248            (regexp-opt '("enum" "struct" "union"))))            (regexp-opt '("enum" "struct" "union"))))
# Line 2298  The value of this variable is used when Line 2254  The value of this variable is used when
2254             ,(eval-when-compile             ,(eval-when-compile
2255                (regexp-opt                (regexp-opt
2256                 '("char" "short" "int" "long" "signed" "unsigned"                 '("char" "short" "int" "long" "signed" "unsigned"
2257                   "float" "double" "void" "complex")))                   "float" "double" "void" "complex"
2258                     ;; Henrik Enberg <henrik@enberg.org> says these are new.
2259                     "_Complex" "_Imaginary" "_Bool")))
2260             c-font-lock-extra-types)             c-font-lock-extra-types)
2261            "\\|"))            "\\|"))
2262         (c-type-names-depth         (c-type-names-depth

Legend:
Removed from v.1.185  
changed lines
  Added in v.1.186

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26