1 ;;; case-table.el --- code to extend the character set and support case tables
3 ;; Copyright (C) 1988, 1994 Free Software Foundation, Inc.
5 ;; Author: Howard Gayle
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (defvar set-case-syntax-set-multibyte nil
)
32 (defun describe-buffer-case-table ()
33 "Describe the case table of the current buffer."
35 (let ((description (make-char-table 'case-table
)))
37 (function (lambda (key value
)
40 (cond ((not (natnump value
))
42 ((/= key
(downcase key
))
43 (concat "uppercase, matches "
44 (char-to-string (downcase key
))))
45 ((/= key
(upcase key
))
46 (concat "lowercase, matches "
47 (char-to-string (upcase key
))))
48 (t "case-invariant")))))
51 (with-output-to-temp-buffer "*Help*"
52 (set-buffer standard-output
)
53 (describe-vector description
)
56 (defun copy-case-table (case-table)
57 (let ((copy (copy-sequence case-table
)))
58 ;; Clear out the extra slots so that they will be
59 ;; recomputed from the main (downcase) table.
60 (set-char-table-extra-slot copy
0 nil
)
61 (set-char-table-extra-slot copy
1 nil
)
62 (set-char-table-extra-slot copy
2 nil
)
65 (defun set-case-syntax-delims (l r table
)
66 "Make characters L and R a matching pair of non-case-converting delimiters.
67 This sets the entries for L and R in TABLE, which is a string
68 that will be used as the downcase part of a case table.
69 It also modifies `standard-syntax-table' to
70 indicate left and right delimiters."
73 ;; Clear out the extra slots so that they will be
74 ;; recomputed from the main (downcase) table.
75 (set-char-table-extra-slot table
0 nil
)
76 (set-char-table-extra-slot table
1 nil
)
77 (set-char-table-extra-slot table
2 nil
)
78 (modify-syntax-entry l
(concat "(" (char-to-string r
) " ")
79 (standard-syntax-table))
80 (modify-syntax-entry r
(concat ")" (char-to-string l
) " ")
81 (standard-syntax-table)))
83 (defun set-case-syntax-pair (uc lc table
)
84 "Make characters UC and LC a pair of inter-case-converting letters.
85 This sets the entries for characters UC and LC in TABLE, which is a string
86 that will be used as the downcase part of a case table.
87 It also modifies `standard-syntax-table' to give them the syntax of
89 (let ((lu (length (string-as-unibyte (string uc
))))
90 (ll (length (string-as-unibyte (string lc
)))))
92 (error "Can't casify chars with different `charset-bytes' values")))
95 (set-char-table-extra-slot table
0 nil
)
96 (set-char-table-extra-slot table
1 nil
)
97 (set-char-table-extra-slot table
2 nil
)
98 (modify-syntax-entry lc
"w " (standard-syntax-table))
99 (modify-syntax-entry uc
"w " (standard-syntax-table)))
101 (defun set-case-syntax (c syntax table
)
102 "Make character C case-invariant with syntax SYNTAX.
103 This sets the entry for character C in TABLE, which is a string
104 that will be used as the downcase part of a case table.
105 It also modifies `standard-syntax-table'.
106 SYNTAX should be \" \", \"w\", \".\" or \"_\"."
108 (set-char-table-extra-slot table
0 nil
)
109 (set-char-table-extra-slot table
1 nil
)
110 (set-char-table-extra-slot table
2 nil
)
111 (modify-syntax-entry c syntax
(standard-syntax-table)))
113 (provide 'case-table
)
115 ;;; case-table.el ends here