- (let ((vector (make-vector 256 nil))
- (case-table (current-case-table))
- (i 0))
- (while (< i 256)
- (aset vector i
- (cond ((/= ch (downcase ch))
- (concat "uppercase, matches "
- (text-char-description (downcase ch))))
- ((/= ch (upcase ch))
- (concat "lowercase, matches "
- (text-char-description (upcase ch))))
- (t "case-invariant")))
- (setq i (1+ i))))
- (with-output-to-temp-buffer "*Help*"
- (describe-vector vector)))
-
-(defun set-case-syntax-delims (l r string)
+ (let ((description (make-char-table 'case-table)))
+ (map-char-table
+ (function (lambda (key value)
+ (aset
+ description key
+ (cond ((not (natnump value))
+ "case-invariant")
+ ((/= key (downcase key))
+ (concat "uppercase, matches "
+ (char-to-string (downcase key))))
+ ((/= key (upcase key))
+ (concat "lowercase, matches "
+ (char-to-string (upcase key))))
+ (t "case-invariant")))))
+ (current-case-table))
+ (save-excursion
+ (with-output-to-temp-buffer "*Help*"
+ (set-buffer standard-output)
+ (describe-vector description)
+ (help-mode)))))
+
+(defun get-upcase-table (case-table)
+ "Return the upcase table of CASE-TABLE."
+ (or (char-table-extra-slot case-table 0)
+ ;; Setup all extra slots of CASE-TABLE by temporarily selecting
+ ;; it as the standard case table.
+ (let ((old (standard-case-table)))
+ (unwind-protect
+ (progn
+ (set-standard-case-table case-table)
+ (char-table-extra-slot case-table 0))
+ (or (eq case-table old)
+ (set-standard-case-table old))))))
+
+(defun copy-case-table (case-table)
+ (let ((copy (copy-sequence case-table))
+ (up (char-table-extra-slot case-table 0)))
+ ;; Clear out the extra slots (except for upcase table) so that
+ ;; they will be recomputed from the main (downcase) table.
+ (if up
+ (set-char-table-extra-slot copy 0 (copy-sequence up)))
+ (set-char-table-extra-slot copy 1 nil)
+ (set-char-table-extra-slot copy 2 nil)
+ copy))
+
+(defsubst set-case-syntax-1 (char)
+ "Offset CHAR by `set-case-syntax-offset' if CHAR is a non-ASCII 8-bit char."
+ (if (and (>= char 128) (< char 256))
+ (+ char set-case-syntax-offset)
+ char))
+
+(defun set-case-syntax-delims (l r table)