]> code.delx.au - gnu-emacs/blob - lisp/case-table.el
(set-case-syntax-offset): New variable.
[gnu-emacs] / lisp / case-table.el
1 ;;; case-table.el --- code to extend the character set and support case tables.
2
3 ;; Copyright (C) 1988, 1994 Free Software Foundation, Inc.
4
5 ;; Author: Howard Gayle
6 ;; Maintainer: FSF
7 ;; Keywords: i18n
8
9 ;; This file is part of GNU Emacs.
10
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)
14 ;; any later version.
15
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.
20
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.
25
26 ;;; Commentary:
27
28 ;; Written by:
29 ;; TN/ETX/TX/UMG Howard Gayle UUCP : seismo!enea!erix!howard
30 ;; Telefonaktiebolaget L M Ericsson Phone: +46 8 719 55 65
31 ;; Ericsson Telecom Telex: 14910 ERIC S
32 ;; S-126 25 Stockholm FAX : +46 8 719 64 82
33 ;; Sweden
34
35 ;;; Code:
36
37 (defvar set-case-syntax-offset 0)
38
39 ;;;###autoload
40 (defun describe-buffer-case-table ()
41 "Describe the case table of the current buffer."
42 (interactive)
43 (let ((description (make-char-table 'case-table)))
44 (map-char-table
45 (function (lambda (key value)
46 (set-char-table-range
47 description key
48 (cond ((null key)
49 "case-invariant")
50 ((/= key (downcase key))
51 (concat "uppercase, matches "
52 (char-to-string (downcase key))))
53 ((/= key (upcase key))
54 (concat "lowercase, matches "
55 (char-to-string (upcase key))))
56 (t "case-invariant")))))
57 (current-case-table))
58 (save-excursion
59 (with-output-to-temp-buffer "*Help*"
60 (set-buffer standard-output)
61 (describe-vector description)
62 (help-mode)))))
63
64 ;;;###autoload
65 (defun copy-case-table (case-table)
66 (let ((copy (copy-sequence case-table)))
67 ;; Clear out the extra slots so that they will be
68 ;; recomputed from the main (downcase) table.
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 ;;;###autoload
75 (defun set-case-syntax-delims (l r table)
76 "Make characters L and R a matching pair of non-case-converting delimiters.
77 This sets the entries for L and R in TABLE, which is a string
78 that will be used as the downcase part of a case table.
79 It also modifies `standard-syntax-table' to
80 indicate left and right delimiters."
81 (setq l (+ set-case-syntax-offset l))
82 (setq r (+ set-case-syntax-offset r))
83 (aset table l l)
84 (aset table r r)
85 ;; Clear out the extra slots so that they will be
86 ;; recomputed from the main (downcase) table.
87 (set-char-table-extra-slot table 0 nil)
88 (set-char-table-extra-slot table 1 nil)
89 (set-char-table-extra-slot table 2 nil)
90 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
91 (standard-syntax-table))
92 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
93 (standard-syntax-table)))
94
95 ;;;###autoload
96 (defun set-case-syntax-pair (uc lc table)
97 "Make characters UC and LC a pair of inter-case-converting letters.
98 This sets the entries for characters UC and LC in TABLE, which is a string
99 that will be used as the downcase part of a case table.
100 It also modifies `standard-syntax-table' to give them the syntax of
101 word constituents."
102 (setq uc (+ set-case-syntax-offset uc))
103 (setq lc (+ set-case-syntax-offset lc))
104 (aset table uc lc)
105 (aset table lc lc)
106 (set-char-table-extra-slot table 0 nil)
107 (set-char-table-extra-slot table 1 nil)
108 (set-char-table-extra-slot table 2 nil)
109 (modify-syntax-entry lc "w " (standard-syntax-table))
110 (modify-syntax-entry uc "w " (standard-syntax-table)))
111
112 ;;;###autoload
113 (defun set-case-syntax (c syntax table)
114 "Make character C case-invariant with syntax SYNTAX.
115 This sets the entry for character C in TABLE, which is a string
116 that will be used as the downcase part of a case table.
117 It also modifies `standard-syntax-table'.
118 SYNTAX should be \" \", \"w\", \".\" or \"_\"."
119 (setq c (+ set-case-syntax-offset c))
120 (aset table c c)
121 (set-char-table-extra-slot table 0 nil)
122 (set-char-table-extra-slot table 1 nil)
123 (set-char-table-extra-slot table 2 nil)
124 (modify-syntax-entry c syntax (standard-syntax-table)))
125
126 (provide 'case-table)
127
128 ;;; case-table.el ends here