diff lisp/syntax.el @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents 99e465e2da2e
children 308d34e9f07d
line wrap: on
line diff
--- a/lisp/syntax.el	Wed Jan 20 07:05:57 2010 -0600
+++ b/lisp/syntax.el	Wed Feb 24 01:58:04 2010 -0600
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1993, 1997 Free Software Foundation, Inc.
 ;; Copyright (C) 1995 Sun Microsystems.
-;; Copyright (C) 2005 Ben Wing.
+;; Copyright (C) 2005, 2010 Ben Wing.
 
 ;; This file is part of XEmacs.
 
@@ -36,7 +36,20 @@
 
 (defun make-syntax-table (&optional oldtable)
   "Return a new syntax table.
-It inherits all characters from the standard syntax table."
+
+It inherits all characters from the standard syntax table.
+
+A syntax table is a char table of type `syntax' (see `make-char-table').
+The valid values are integers (intended to be syntax codes as generated by
+`syntax-string-to-code'), and the default result given by `get-char-table'
+is the syntax code for `word'. (Note: In 21.4 and prior, it was the code
+for `inherit'.)
+
+To modify a syntax table, you should normally use `modify-syntax-entry'
+rather than directly modify the table with `put-char-table'.
+
+See `modify-syntax-entry' for a description of the character codes used
+to indicate the various syntax classes."
   (make-char-table 'syntax))
 
 (defun syntax-after (pos)
@@ -205,21 +218,35 @@
 	  (wrong-type-argument 'syntax-table-p syntax-table))))
   nil)
 
-(defun map-syntax-table (__function __syntax_table &optional __range)
-  "Map FUNCTION over entries in SYNTAX-TABLE, collapsing inheritance.
+((macro
+  . (lambda (map-syntax-definition)
+      "Replace the variable names in MAP-SYNTAX-DEFINITION with uninterned
+symbols, at byte-compile time.  This avoids the risk of variable names
+within the functions called from MAP-SYNTAX-DEFINITION being shared with
+MAP-SYNTAX-DEFINITION, and as such subject to modification, one of the
+common downsides of dynamic scope."
+      (nsublis
+       '((syntax-table . #:syntax-table)
+	 (m-s-function . #:function)
+	 (range . #:range)
+	 (key . #:key)
+	 (value . #:value))
+       map-syntax-definition)))
+ (defun map-syntax-table (m-s-function syntax-table &optional range)
+   "Map FUNCTION over entries in SYNTAX-TABLE, collapsing inheritance.
 This is similar to `map-char-table', but works only on syntax tables, and
  collapses any entries that call for inheritance by invisibly substituting
  the inherited values from the standard syntax table."
-  (check-argument-type 'syntax-table-p __syntax_table)
-  (map-char-table #'(lambda (__key __value)
-		      (if (eq ?@ (char-syntax-from-code __value))
-			  (map-char-table #'(lambda (__key __value)
-					      (funcall __function
-						       __key __value))
-					  (standard-syntax-table)
-					  __key)
-			(funcall __function __key __value)))
-		  __syntax_table __range))
+   (check-argument-type 'syntax-table-p syntax-table)
+   (map-char-table #'(lambda (key value)
+		       (if (eq ?@ (char-syntax-from-code value))
+			   (map-char-table
+			    #'(lambda (key value)
+				(funcall m-s-function key value))
+			    (standard-syntax-table)
+			    key)
+			 (funcall m-s-function key value)))
+		   syntax-table range)))
 
 ;(defun test-xm ()
 ;  (let ((o (copy-syntax-table))