diff options
| -rw-r--r-- | lisp/emacs-lisp/syntax.el | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el index d7ad3bacd45..b5b8ec251a7 100644 --- a/lisp/emacs-lisp/syntax.el +++ b/lisp/emacs-lisp/syntax.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; syntax.el --- helper functions to find syntactic context | 1 | ;;; syntax.el --- helper functions to find syntactic context |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000, 2003 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Maintainer: FSF | 5 | ;; Maintainer: FSF |
| 6 | ;; Keywords: internal | 6 | ;; Keywords: internal |
| @@ -25,7 +25,7 @@ | |||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| 27 | ;; The main exported function is `syntax-ppss'. You might also need | 27 | ;; The main exported function is `syntax-ppss'. You might also need |
| 28 | ;; to call `syntax-ppss-after-change-function' or to add it to | 28 | ;; to call `syntax-ppss-flush-cache' or to add it to |
| 29 | ;; after-change-functions'(although this is automatically done by | 29 | ;; after-change-functions'(although this is automatically done by |
| 30 | ;; syntax-ppss when needed, but that might fail if syntax-ppss is | 30 | ;; syntax-ppss when needed, but that might fail if syntax-ppss is |
| 31 | ;; called in a context where after-change-functions is temporarily | 31 | ;; called in a context where after-change-functions is temporarily |
| @@ -73,7 +73,9 @@ point (where the PPSS is equivalent to nil).") | |||
| 73 | "Cache of (LAST-POS . LAST-PPSS).") | 73 | "Cache of (LAST-POS . LAST-PPSS).") |
| 74 | (make-variable-buffer-local 'syntax-ppss-last) | 74 | (make-variable-buffer-local 'syntax-ppss-last) |
| 75 | 75 | ||
| 76 | (defun syntax-ppss-after-change-function (beg &rest ignored) | 76 | (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." | ||
| 77 | ;; Flush invalid cache entries. | 79 | ;; Flush invalid cache entries. |
| 78 | (while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg)) | 80 | (while (and syntax-ppss-cache (> (caar syntax-ppss-cache) beg)) |
| 79 | (setq syntax-ppss-cache (cdr syntax-ppss-cache))) | 81 | (setq syntax-ppss-cache (cdr syntax-ppss-cache))) |
| @@ -106,10 +108,6 @@ point (where the PPSS is equivalent to nil).") | |||
| 106 | "Parse-Partial-Sexp State at POS. | 108 | "Parse-Partial-Sexp State at POS. |
| 107 | The returned value is the same as `parse-partial-sexp' except that | 109 | The returned value is the same as `parse-partial-sexp' except that |
| 108 | the 2nd and 6th values of the returned state cannot be relied upon. | 110 | the 2nd and 6th values of the returned state cannot be relied upon. |
| 109 | |||
| 110 | If the caller knows the PPSS of a nearby position, she can pass it | ||
| 111 | in OLP-PPSS (with or without its corresponding OLD-POS) to try and | ||
| 112 | avoid a more expansive scan. | ||
| 113 | Point is at POS when this function returns." | 111 | Point is at POS when this function returns." |
| 114 | ;; Default values. | 112 | ;; Default values. |
| 115 | (unless pos (setq pos (point))) | 113 | (unless pos (setq pos (point))) |
| @@ -172,8 +170,7 @@ Point is at POS when this function returns." | |||
| 172 | 170 | ||
| 173 | ;; Setup the after-change function if necessary. | 171 | ;; Setup the after-change function if necessary. |
| 174 | (unless (or syntax-ppss-cache syntax-ppss-last) | 172 | (unless (or syntax-ppss-cache syntax-ppss-last) |
| 175 | (add-hook 'after-change-functions | 173 | (add-hook 'after-change-functions 'syntax-ppss-flush-cache nil t)) |
| 176 | 'syntax-ppss-after-change-function nil t)) | ||
| 177 | 174 | ||
| 178 | ;; Use the best of OLD-POS and CACHE. | 175 | ;; Use the best of OLD-POS and CACHE. |
| 179 | (if (or (not old-pos) (< old-pos pt-min)) | 176 | (if (or (not old-pos) (< old-pos pt-min)) |