remove `declare' macro
[bpt/emacs.git] / lisp / emacs-lisp / syntax.el
index 51bfc05..db68148 100644 (file)
@@ -1,8 +1,8 @@
 ;;; syntax.el --- helper functions to find syntactic context  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2000-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2014 Free Software Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: internal
 
 ;; This file is part of GNU Emacs.
   ;; have to flush that cache between each function, and we couldn't use
   ;; syntax-ppss-flush-cache since that would not only flush the cache but also
   ;; reset syntax-propertize--done which should not be done in this case).
-  "Mode-specific function to apply the syntax-table properties.
-Called with two arguments: START and END.
-This function can call `syntax-ppss' on any position before END, but it
-should not call `syntax-ppss-flush-cache', which means that it should not
-call `syntax-ppss' on some position and later modify the buffer on some
-earlier position.")
+  "Mode-specific function to apply `syntax-table' text properties.
+It is the work horse of `syntax-propertize', which is called by things like
+Font-Lock and indentation.
+
+It is given two arguments, START and END: the start and end of the text to
+which `syntax-table' might need to be applied.  Major modes can use this to
+override the buffer's syntax table for special syntactic constructs that
+cannot be handled just by the buffer's syntax-table.
+
+The specified function may call `syntax-ppss' on any position
+before END, but it should not call `syntax-ppss-flush-cache',
+which means that it should not call `syntax-ppss' on some
+position and later modify the buffer on some earlier position.")
 
 (defvar syntax-propertize-chunk-size 500)
 
@@ -93,7 +100,7 @@ Put first the functions more likely to cause a change and cheaper to compute.")
     (setq beg (or (previous-single-property-change beg 'syntax-multiline)
                  (point-min))))
   ;;
-  (when (get-text-property end 'font-lock-multiline)
+  (when (get-text-property end 'syntax-multiline)
     (setq end (or (text-property-any end (point-max)
                                     'syntax-multiline nil)
                  (point-max))))
@@ -118,7 +125,7 @@ The arg RULES can be of the same form as in `syntax-propertize-rules'.
 The return value is an object that can be passed as a rule to
 `syntax-propertize-rules'.
 I.e. this is useful only when you want to share rules among several
-syntax-propertize-functions."
+`syntax-propertize-function's."
   (declare (debug syntax-propertize-rules))
   ;; Precompile?  Yeah, right!
   ;; Seriously, tho, this is a macro for 2 reasons:
@@ -398,9 +405,14 @@ point (where the PPSS is equivalent to nil).")
 (defun syntax-ppss (&optional pos)
   "Parse-Partial-Sexp State at POS, defaulting to point.
 The returned value is the same as that of `parse-partial-sexp'
-run from point-min to POS except that values at positions 2 and 6
+run from `point-min' to POS except that values at positions 2 and 6
 in the returned list (counting from 0) cannot be relied upon.
-Point is at POS when this function returns."
+Point is at POS when this function returns.
+
+It is necessary to call `syntax-ppss-flush-cache' explicitly if
+this function is called while `before-change-functions' is
+temporarily let-bound, or if the buffer is modified without
+running the hook."
   ;; Default values.
   (unless pos (setq pos (point)))
   (syntax-propertize pos)
@@ -511,10 +523,8 @@ Point is at POS when this function returns."
                  (setq ppss (parse-partial-sexp
                              pt-min (setq pt-min (/ (+ pt-min pos) 2))
                              nil nil ppss))
-                 (let ((pair (cons pt-min ppss)))
-                   (if cache-pred
-                       (cl-push pair (cdr cache-pred))
-                     (push pair syntax-ppss-cache))))
+                  (push (cons pt-min ppss)
+                        (if cache-pred (cdr cache-pred) syntax-ppss-cache)))
 
                ;; Compute the actual return value.
                (setq ppss (parse-partial-sexp pt-min pos nil nil ppss))
@@ -533,7 +543,7 @@ Point is at POS when this function returns."
                (let ((pair (cons pos ppss)))
                  (if cache-pred
                      (if (> (- (caar cache-pred) pos) syntax-ppss-max-span)
-                         (cl-push pair (cdr cache-pred))
+                         (push pair (cdr cache-pred))
                        (setcar cache-pred pair))
                    (if (or (null syntax-ppss-cache)
                            (> (- (caar syntax-ppss-cache) pos)