diff options
| author | Kenichi Handa | 2005-02-02 00:57:07 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2005-02-02 00:57:07 +0000 |
| commit | e1e89a70b9a54fa5dc2365398ef4df2eb5944b2a (patch) | |
| tree | 85f309405f8e051255a4fe2727a23ab58bb65cbc | |
| parent | f98a8aa964088ab816829eacd5812b413330e20c (diff) | |
| download | emacs-e1e89a70b9a54fa5dc2365398ef4df2eb5944b2a.tar.gz emacs-e1e89a70b9a54fa5dc2365398ef4df2eb5944b2a.zip | |
(get-upcase-table): New function.
(copy-case-table): Copy upcaes table too if non-nil.
(set-case-syntax-delims): Maintain upcase table too.
(set-case-syntax-pair): Likewise.
(set-upcase-syntax, set-downcase-syntax): New functions.
(set-case-syntax): Maintain upcase table too.
| -rw-r--r-- | lisp/case-table.el | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/lisp/case-table.el b/lisp/case-table.el index 094c1d6e62a..77ebe857ff2 100644 --- a/lisp/case-table.el +++ b/lisp/case-table.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; case-table.el --- code to extend the character set and support case tables | 1 | ;;; case-table.el --- code to extend the character set and support case tables |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1988, 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1988, 1994, 2005 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Howard Gayle | 5 | ;; Author: Howard Gayle |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -62,11 +62,26 @@ | |||
| 62 | (describe-vector description) | 62 | (describe-vector description) |
| 63 | (help-mode))))) | 63 | (help-mode))))) |
| 64 | 64 | ||
| 65 | (defun get-upcase-table (case-table) | ||
| 66 | "Return the upcase table of CASE-TABLE." | ||
| 67 | (or (char-table-extra-slot case-table 0) | ||
| 68 | ;; Setup all extra slots of CASE-TABLE by temporarily selecting | ||
| 69 | ;; it as the standard case table. | ||
| 70 | (let ((old (standard-case-table))) | ||
| 71 | (unwind-protect | ||
| 72 | (progn | ||
| 73 | (set-standard-case-table case-table) | ||
| 74 | (char-table-extra-slot case-table 0)) | ||
| 75 | (or (eq case-table old) | ||
| 76 | (set-standard-case-table old)))))) | ||
| 77 | |||
| 65 | (defun copy-case-table (case-table) | 78 | (defun copy-case-table (case-table) |
| 66 | (let ((copy (copy-sequence case-table))) | 79 | (let ((copy (copy-sequence case-table)) |
| 67 | ;; Clear out the extra slots so that they will be | 80 | (up (char-table-extra-slot case-table 0))) |
| 68 | ;; recomputed from the main (downcase) table. | 81 | ;; Clear out the extra slots (except for upcase table) so that |
| 69 | (set-char-table-extra-slot copy 0 nil) | 82 | ;; they will be recomputed from the main (downcase) table. |
| 83 | (if up | ||
| 84 | (set-char-table-extra-slot copy 0 (copy-sequence up))) | ||
| 70 | (set-char-table-extra-slot copy 1 nil) | 85 | (set-char-table-extra-slot copy 1 nil) |
| 71 | (set-char-table-extra-slot copy 2 nil) | 86 | (set-char-table-extra-slot copy 2 nil) |
| 72 | copy)) | 87 | copy)) |
| @@ -87,9 +102,11 @@ indicate left and right delimiters." | |||
| 87 | (setq r (set-case-syntax-1 r)) | 102 | (setq r (set-case-syntax-1 r)) |
| 88 | (aset table l l) | 103 | (aset table l l) |
| 89 | (aset table r r) | 104 | (aset table r r) |
| 105 | (let ((up (get-upcase-table table))) | ||
| 106 | (aset up l l) | ||
| 107 | (aset up r r)) | ||
| 90 | ;; Clear out the extra slots so that they will be | 108 | ;; Clear out the extra slots so that they will be |
| 91 | ;; recomputed from the main (downcase) table. | 109 | ;; recomputed from the main (downcase) table and upcase table. |
| 92 | (set-char-table-extra-slot table 0 nil) | ||
| 93 | (set-char-table-extra-slot table 1 nil) | 110 | (set-char-table-extra-slot table 1 nil) |
| 94 | (set-char-table-extra-slot table 2 nil) | 111 | (set-char-table-extra-slot table 2 nil) |
| 95 | (modify-syntax-entry l (concat "(" (char-to-string r) " ") | 112 | (modify-syntax-entry l (concat "(" (char-to-string r) " ") |
| @@ -103,16 +120,46 @@ This sets the entries for characters UC and LC in TABLE, which is a string | |||
| 103 | that will be used as the downcase part of a case table. | 120 | that will be used as the downcase part of a case table. |
| 104 | It also modifies `standard-syntax-table' to give them the syntax of | 121 | It also modifies `standard-syntax-table' to give them the syntax of |
| 105 | word constituents." | 122 | word constituents." |
| 106 | (unless (= (charset-bytes (char-charset uc)) | 123 | (setq uc (set-case-syntax-1 uc)) |
| 107 | (charset-bytes (char-charset lc))) | 124 | (setq lc (set-case-syntax-1 lc)) |
| 108 | (error "Can't casify chars with different `charset-bytes' values")) | 125 | (aset table uc lc) |
| 126 | (aset table lc lc) | ||
| 127 | (let ((up (get-upcase-table table))) | ||
| 128 | (aset up uc uc) | ||
| 129 | (aset up lc uc)) | ||
| 130 | ;; Clear out the extra slots so that they will be | ||
| 131 | ;; recomputed from the main (downcase) table and upcase table. | ||
| 132 | (set-char-table-extra-slot table 1 nil) | ||
| 133 | (set-char-table-extra-slot table 2 nil) | ||
| 134 | (modify-syntax-entry lc "w " (standard-syntax-table)) | ||
| 135 | (modify-syntax-entry uc "w " (standard-syntax-table))) | ||
| 136 | |||
| 137 | (defun set-upcase-syntax (uc lc table) | ||
| 138 | "Make character UC an upcase of character LC. | ||
| 139 | It also modifies `standard-syntax-table' to give them the syntax of | ||
| 140 | word constituents." | ||
| 141 | (setq uc (set-case-syntax-1 uc)) | ||
| 142 | (setq lc (set-case-syntax-1 lc)) | ||
| 143 | (let ((up (get-upcase-table table))) | ||
| 144 | (aset up uc uc) | ||
| 145 | (aset up lc uc)) | ||
| 146 | ;; Clear out the extra slots so that they will be | ||
| 147 | ;; recomputed from the main (downcase) table and upcase table. | ||
| 148 | (set-char-table-extra-slot table 1 nil) | ||
| 149 | (set-char-table-extra-slot table 2 nil) | ||
| 150 | (modify-syntax-entry lc "w " (standard-syntax-table)) | ||
| 151 | (modify-syntax-entry uc "w " (standard-syntax-table))) | ||
| 152 | |||
| 153 | (defun set-downcase-syntax (uc lc table) | ||
| 154 | "Make character LC a downcase of character UC. | ||
| 155 | It also modifies `standard-syntax-table' to give them the syntax of | ||
| 156 | word constituents." | ||
| 109 | (setq uc (set-case-syntax-1 uc)) | 157 | (setq uc (set-case-syntax-1 uc)) |
| 110 | (setq lc (set-case-syntax-1 lc)) | 158 | (setq lc (set-case-syntax-1 lc)) |
| 111 | (aset table uc lc) | 159 | (aset table uc lc) |
| 112 | (aset table lc lc) | 160 | (aset table lc lc) |
| 113 | ;; Clear out the extra slots so that they will be | 161 | ;; Clear out the extra slots so that they will be |
| 114 | ;; recomputed from the main (downcase) table. | 162 | ;; recomputed from the main (downcase) table and upcase table. |
| 115 | (set-char-table-extra-slot table 0 nil) | ||
| 116 | (set-char-table-extra-slot table 1 nil) | 163 | (set-char-table-extra-slot table 1 nil) |
| 117 | (set-char-table-extra-slot table 2 nil) | 164 | (set-char-table-extra-slot table 2 nil) |
| 118 | (modify-syntax-entry lc "w " (standard-syntax-table)) | 165 | (modify-syntax-entry lc "w " (standard-syntax-table)) |
| @@ -126,9 +173,10 @@ It also modifies `standard-syntax-table'. | |||
| 126 | SYNTAX should be \" \", \"w\", \".\" or \"_\"." | 173 | SYNTAX should be \" \", \"w\", \".\" or \"_\"." |
| 127 | (setq c (set-case-syntax-1 c)) | 174 | (setq c (set-case-syntax-1 c)) |
| 128 | (aset table c c) | 175 | (aset table c c) |
| 176 | (let ((up (get-upcase-table table))) | ||
| 177 | (aset up c c)) | ||
| 129 | ;; Clear out the extra slots so that they will be | 178 | ;; Clear out the extra slots so that they will be |
| 130 | ;; recomputed from the main (downcase) table. | 179 | ;; recomputed from the main (downcase) table and upcase table. |
| 131 | (set-char-table-extra-slot table 0 nil) | ||
| 132 | (set-char-table-extra-slot table 1 nil) | 180 | (set-char-table-extra-slot table 1 nil) |
| 133 | (set-char-table-extra-slot table 2 nil) | 181 | (set-char-table-extra-slot table 2 nil) |
| 134 | (modify-syntax-entry c syntax (standard-syntax-table))) | 182 | (modify-syntax-entry c syntax (standard-syntax-table))) |