| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
(defvar set-case-syntax-offset 0) |
|---|
| 38 |
|
|---|
| 39 |
(defvar set-case-syntax-set-multibyte nil) |
|---|
| 40 |
|
|---|
| 41 |
(defun describe-buffer-case-table () |
|---|
| 42 |
"Describe the case table of the current buffer." |
|---|
| 43 |
(interactive) |
|---|
| 44 |
(let ((description (make-char-table 'case-table))) |
|---|
| 45 |
(map-char-table |
|---|
| 46 |
(function (lambda (key value) |
|---|
| 47 |
(aset |
|---|
| 48 |
description key |
|---|
| 49 |
(cond ((not (natnump value)) |
|---|
| 50 |
"case-invariant") |
|---|
| 51 |
((/= key (downcase key)) |
|---|
| 52 |
(concat "uppercase, matches " |
|---|
| 53 |
(char-to-string (downcase key)))) |
|---|
| 54 |
((/= key (upcase key)) |
|---|
| 55 |
(concat "lowercase, matches " |
|---|
| 56 |
(char-to-string (upcase key)))) |
|---|
| 57 |
(t "case-invariant"))))) |
|---|
| 58 |
(current-case-table)) |
|---|
| 59 |
(save-excursion |
|---|
| 60 |
(with-output-to-temp-buffer "*Help*" |
|---|
| 61 |
(set-buffer standard-output) |
|---|
| 62 |
(describe-vector description) |
|---|
| 63 |
(help-mode))))) |
|---|
| 64 |
|
|---|
| 65 |
(defun copy-case-table (case-table) |
|---|
| 66 |
(let ((copy (copy-sequence case-table))) |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
(set-char-table-extra-slot copy 0 nil) |
|---|
| 70 |
(set-char-table-extra-slot copy 1 nil) |
|---|
| 71 |
(set-char-table-extra-slot copy 2 nil) |
|---|
| 72 |
copy)) |
|---|
| 73 |
|
|---|
| 74 |
(defsubst set-case-syntax-1 (char) |
|---|
| 75 |
"Offset CHAR by `set-case-syntax-offset' if CHAR is a non-ASCII 8-bit char." |
|---|
| 76 |
(if (and (>= char 128) (< char 256)) |
|---|
| 77 |
(+ char set-case-syntax-offset) |
|---|
| 78 |
char)) |
|---|
| 79 |
|
|---|
| 80 |
(defun set-case-syntax-delims (l r table) |
|---|
| 81 |
"Make characters L and R a matching pair of non-case-converting delimiters. |
|---|
| 82 |
This sets the entries for L and R in TABLE, which is a string |
|---|
| 83 |
that will be used as the downcase part of a case table. |
|---|
| 84 |
It also modifies `standard-syntax-table' to |
|---|
| 85 |
indicate left and right delimiters." |
|---|
| 86 |
(setq l (set-case-syntax-1 l)) |
|---|
| 87 |
(setq r (set-case-syntax-1 r)) |
|---|
| 88 |
(aset table l l) |
|---|
| 89 |
(aset table r r) |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
(set-char-table-extra-slot table 0 nil) |
|---|
| 93 |
(set-char-table-extra-slot table 1 nil) |
|---|
| 94 |
(set-char-table-extra-slot table 2 nil) |
|---|
| 95 |
(modify-syntax-entry l (concat "(" (char-to-string r) " ") |
|---|
| 96 |
(standard-syntax-table)) |
|---|
| 97 |
(modify-syntax-entry r (concat ")" (char-to-string l) " ") |
|---|
| 98 |
(standard-syntax-table))) |
|---|
| 99 |
|
|---|
| 100 |
(defun set-case-syntax-pair (uc lc table) |
|---|
| 101 |
"Make characters UC and LC a pair of inter-case-converting letters. |
|---|
| 102 |
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. |
|---|
| 104 |
It also modifies `standard-syntax-table' to give them the syntax of |
|---|
| 105 |
word constituents." |
|---|
| 106 |
(setq uc (set-case-syntax-1 uc)) |
|---|
| 107 |
(setq lc (set-case-syntax-1 lc)) |
|---|
| 108 |
(aset table uc lc) |
|---|
| 109 |
(aset table lc lc) |
|---|
| 110 |
(set-char-table-extra-slot table 0 nil) |
|---|
| 111 |
(set-char-table-extra-slot table 1 nil) |
|---|
| 112 |
(set-char-table-extra-slot table 2 nil) |
|---|
| 113 |
(modify-syntax-entry lc "w " (standard-syntax-table)) |
|---|
| 114 |
(modify-syntax-entry uc "w " (standard-syntax-table))) |
|---|
| 115 |
|
|---|
| 116 |
(defun set-case-syntax (c syntax table) |
|---|
| 117 |
"Make character C case-invariant with syntax SYNTAX. |
|---|
| 118 |
This sets the entry for character C in TABLE, which is a string |
|---|
| 119 |
that will be used as the downcase part of a case table. |
|---|
| 120 |
It also modifies `standard-syntax-table'. |
|---|
| 121 |
SYNTAX should be \" \", \"w\", \".\" or \"_\"." |
|---|
| 122 |
(setq c (set-case-syntax-1 c)) |
|---|
| 123 |
(aset table c c) |
|---|
| 124 |
(set-char-table-extra-slot table 0 nil) |
|---|
| 125 |
(set-char-table-extra-slot table 1 nil) |
|---|
| 126 |
(set-char-table-extra-slot table 2 nil) |
|---|
| 127 |
(modify-syntax-entry c syntax (standard-syntax-table))) |
|---|
| 128 |
|
|---|
| 129 |
(provide 'case-table) |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|