/[emacs]/emacs/lisp/emacs-lisp/syntax.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/syntax.el

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

revision 1.7 by lektu, Tue Feb 4 12:53:34 2003 UTC revision 1.8 by monnier, Wed Jul 16 15:17:02 2003 UTC
# Line 1  Line 1 
1  ;;; syntax.el --- helper functions to find syntactic context  ;;; syntax.el --- helper functions to find syntactic context
2    
3  ;; Copyright (C) 2000 Free Software Foundation, Inc.  ;; Copyright (C) 2000, 2003 Free Software Foundation, Inc.
4    
5  ;; Maintainer: FSF  ;; Maintainer: FSF
6  ;; Keywords: internal  ;; Keywords: internal
# Line 25  Line 25 
25  ;;; Commentary:  ;;; Commentary:
26    
27  ;; The main exported function is `syntax-ppss'.  You might also need  ;; The main exported function is `syntax-ppss'.  You might also need
28  ;; to call `syntax-ppss-after-change-function' or to add it to  ;; to call `syntax-ppss-flush-cache' or to add it to
29  ;; after-change-functions'(although this is automatically done by  ;; after-change-functions'(although this is automatically done by
30  ;; syntax-ppss when needed, but that might fail if syntax-ppss is  ;; syntax-ppss when needed, but that might fail if syntax-ppss is
31  ;; called in a context where after-change-functions is temporarily  ;; called in a context where after-change-functions is temporarily
# Line 73  point (where the PPSS is equivalent to n Line 73  point (where the PPSS is equivalent to n
73    "Cache of (LAST-POS . LAST-PPSS).")    "Cache of (LAST-POS . LAST-PPSS).")
74  (make-variable-buffer-local 'syntax-ppss-last)  (make-variable-buffer-local 'syntax-ppss-last)
75    
76  (defun syntax-ppss-after-change-function (beg &rest ignored)  (defalias 'syntax-ppss-after-change-function 'syntax-ppss-flush-cache)
77    (defun syntax-ppss-flush-cache (beg &rest ignored)
78      "Flush the cache of `syntax-ppss' starting at position BEG."
79    ;; Flush invalid cache entries.    ;; Flush invalid cache entries.
80    (while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg))    (while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg))
81      (setq syntax-ppss-cache (cdr syntax-ppss-cache)))      (setq syntax-ppss-cache (cdr syntax-ppss-cache)))
# Line 106  point (where the PPSS is equivalent to n Line 108  point (where the PPSS is equivalent to n
108    "Parse-Partial-Sexp State at POS.    "Parse-Partial-Sexp State at POS.
109  The returned value is the same as `parse-partial-sexp' except that  The returned value is the same as `parse-partial-sexp' except that
110  the 2nd and 6th values of the returned state cannot be relied upon.  the 2nd and 6th values of the returned state cannot be relied upon.
   
 If the caller knows the PPSS of a nearby position, she can pass it  
 in OLP-PPSS (with or without its corresponding OLD-POS) to try and  
 avoid a more expansive scan.  
111  Point is at POS when this function returns."  Point is at POS when this function returns."
112    ;; Default values.    ;; Default values.
113    (unless pos (setq pos (point)))    (unless pos (setq pos (point)))
# Line 172  Point is at POS when this function retur Line 170  Point is at POS when this function retur
170    
171            ;; Setup the after-change function if necessary.            ;; Setup the after-change function if necessary.
172            (unless (or syntax-ppss-cache syntax-ppss-last)            (unless (or syntax-ppss-cache syntax-ppss-last)
173              (add-hook 'after-change-functions              (add-hook 'after-change-functions 'syntax-ppss-flush-cache nil t))
                       'syntax-ppss-after-change-function nil t))  
174    
175            ;; Use the best of OLD-POS and CACHE.            ;; Use the best of OLD-POS and CACHE.
176            (if (or (not old-pos) (< old-pos pt-min))            (if (or (not old-pos) (< old-pos pt-min))

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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