X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ae940284fa77a6928f5162b7de859e67bdc7506c..5148da153e385332f3fc87ace4bf4c2fc580b41e:/lisp/case-table.el diff --git a/lisp/case-table.el b/lisp/case-table.el index 34e4fc7824..7d4aa27de1 100644 --- a/lisp/case-table.el +++ b/lisp/case-table.el @@ -1,11 +1,11 @@ -;;; case-table.el --- code to extend the character set and support case tables +;;; case-table.el --- code to extend the character set and support case tables -*- lexical-binding: t -*- -;; Copyright (C) 1988, 1994, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +;; Copyright (C) 1988, 1994, 2001-2013 Free Software Foundation, Inc. ;; Author: Howard Gayle ;; Maintainer: FSF ;; Keywords: i18n +;; Package: emacs ;; This file is part of GNU Emacs. @@ -39,19 +39,25 @@ (let ((description (make-char-table 'case-table))) (map-char-table (function (lambda (key value) - (if (consp key) - (set-char-table-range description key "case-invariant") - (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")))))) + (if (not (natnump value)) + (if (consp key) + (set-char-table-range description key "case-invariant") + (aset description key "case-invariant")) + (let (from to) + (if (consp key) + (setq from (car key) to (cdr key)) + (setq from (setq to key))) + (while (<= from to) + (aset + description from + (cond ((/= from (downcase from)) + (concat "uppercase, matches " + (char-to-string (downcase from)))) + ((/= from (upcase from)) + (concat "lowercase, matches " + (char-to-string (upcase from)))) + (t "case-invariant"))) + (setq from (1+ from))))))) (current-case-table)) (save-excursion (with-output-to-temp-buffer "*Help*" @@ -59,18 +65,26 @@ (describe-vector description) (help-mode))))) +(defun case-table-get-table (case-table table) + "Return the TABLE of CASE-TABLE. +TABLE can be `down', `up', `eqv' or `canon'." + (let ((slot-nb (cdr (assq table '((up . 0) (canon . 1) (eqv . 2)))))) + (or (if (eq table 'down) case-table) + (char-table-extra-slot case-table slot-nb) + ;; 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 slot-nb)) + (or (eq case-table old) + (set-standard-case-table old))))))) + (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)))))) + (case-table-get-table case-table 'up)) +(make-obsolete 'get-upcase-table 'case-table-get-table "24.4") (defun copy-case-table (case-table) (let ((copy (copy-sequence case-table)) @@ -91,7 +105,7 @@ It also modifies `standard-syntax-table' to indicate left and right delimiters." (aset table l l) (aset table r r) - (let ((up (get-upcase-table table))) + (let ((up (case-table-get-table table 'up))) (aset up l l) (aset up r r)) ;; Clear out the extra slots so that they will be @@ -111,7 +125,7 @@ It also modifies `standard-syntax-table' to give them the syntax of word constituents." (aset table uc lc) (aset table lc lc) - (let ((up (get-upcase-table table))) + (let ((up (case-table-get-table table 'up))) (aset up uc uc) (aset up lc uc)) ;; Clear out the extra slots so that they will be @@ -126,7 +140,7 @@ word constituents." It also modifies `standard-syntax-table' to give them the syntax of word constituents." (aset table lc lc) - (let ((up (get-upcase-table table))) + (let ((up (case-table-get-table table 'up))) (aset up uc uc) (aset up lc uc)) ;; Clear out the extra slots so that they will be @@ -142,7 +156,7 @@ It also modifies `standard-syntax-table' to give them the syntax of word constituents." (aset table uc lc) (aset table lc lc) - (let ((up (get-upcase-table table))) + (let ((up (case-table-get-table table 'up))) (aset up uc uc)) ;; Clear out the extra slots so that they will be ;; recomputed from the main (downcase) table and upcase table. @@ -158,7 +172,7 @@ that will be used as the downcase part of a case table. It also modifies `standard-syntax-table'. SYNTAX should be \" \", \"w\", \".\" or \"_\"." (aset table c c) - (let ((up (get-upcase-table table))) + (let ((up (case-table-get-table table 'up))) (aset up c c)) ;; Clear out the extra slots so that they will be ;; recomputed from the main (downcase) table and upcase table. @@ -168,5 +182,4 @@ SYNTAX should be \" \", \"w\", \".\" or \"_\"." (provide 'case-table) -;; arch-tag: 3c2cf885-2c9a-449a-9972-2e269191896d ;;; case-table.el ends here