36
|
1 ;; Functions for extending the character set and dealing with case tables.
|
|
2 ;; Copyright (C) 1988 Free Software Foundation, Inc.
|
|
3
|
|
4 ;; This file is part of GNU Emacs.
|
|
5
|
|
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
7 ;; it under the terms of the GNU General Public License as published by
|
|
8 ;; the Free Software Foundation; either version 1, or (at your option)
|
|
9 ;; any later version.
|
|
10
|
|
11 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 ;; GNU General Public License for more details.
|
|
15
|
|
16 ;; You should have received a copy of the GNU General Public License
|
|
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19
|
|
20
|
|
21 ;; Written by:
|
|
22 ;; TN/ETX/TX/UMG Howard Gayle UUCP : seismo!enea!erix!howard
|
|
23 ;; Telefonaktiebolaget L M Ericsson Phone: +46 8 719 55 65
|
|
24 ;; Ericsson Telecom Telex: 14910 ERIC S
|
|
25 ;; S-126 25 Stockholm FAX : +46 8 719 64 82
|
|
26 ;; Sweden
|
|
27
|
|
28 (defun describe-buffer-case-table ()
|
|
29 "Describe the case table of the current buffer."
|
|
30 (interactive)
|
|
31 (let ((vector (make-vector 256 nil))
|
|
32 (case-table (current-case-table))
|
|
33 (i 0))
|
|
34 (while (< i 256)
|
|
35 (aset vector i
|
|
36 (cond ((/= ch (downcase ch))
|
|
37 (concat "uppercase, matches "
|
|
38 (text-char-description (downcase ch))))
|
|
39 ((/= ch (upcase ch))
|
|
40 (concat "lowercase, matches "
|
|
41 (text-char-description (upcase ch))))
|
|
42 (t "case-invariant")))
|
|
43 (setq i (1+ i))))
|
|
44 (with-output-to-temp-buffer "*Help*"
|
|
45 (describe-vector vector)))
|
|
46
|
|
47 (defun invert-case (count)
|
|
48 "Change the case of the character just after point and move over it.
|
|
49 With arg, applies to that many chars.
|
|
50 Negative arg inverts characters before point but does not move."
|
|
51 (interactive "p")
|
|
52 (if (< count 0)
|
|
53 (progn (setq count (min (1- (point)) (- count)))
|
|
54 (forward-char (- count))))
|
|
55 (while (> count 0)
|
|
56 (let ((oc (following-char))) ; Old character.
|
|
57 (cond ((/= (upcase ch) ch)
|
|
58 (replace-char (upcase ch)))
|
|
59 ((/= (downcase ch) ch)
|
|
60 (replace-char (downcase ch)))))
|
|
61 (forward-char 1)
|
|
62 (setq count (1- count))))
|
|
63
|
|
64 (defun set-case-syntax-delims (l r table)
|
|
65 "Make characters L and R a matching pair of non-case-converting delimiters.
|
|
66 Sets the entries for L and R in standard-case-table,
|
|
67 standard-syntax-table, and text-mode-syntax-table to indicate
|
|
68 left and right delimiters."
|
|
69 (aset (car table) l l)
|
|
70 (aset (car table) r r)
|
|
71 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
|
|
72 (standard-syntax-table))
|
|
73 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
|
|
74 text-mode-syntax-table)
|
|
75 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
|
|
76 (standard-syntax-table))
|
|
77 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
|
|
78 text-mode-syntax-table))
|
|
79
|
|
80 (defun set-case-syntax-pair (uc lc table)
|
|
81 "Make characters UC and LC a pair of inter-case-converting letters.
|
|
82 Sets the entries for characters UC and LC in
|
|
83 standard-case-table, standard-syntax-table, and
|
|
84 text-mode-syntax-table to indicate an (uppercase, lowercase)
|
|
85 pair of letters."
|
|
86 (aset (car table) uc lc)
|
|
87 (modify-syntax-entry lc "w " (standard-syntax-table))
|
|
88 (modify-syntax-entry lc "w " text-mode-syntax-table)
|
|
89 (modify-syntax-entry uc "w " (standard-syntax-table))
|
|
90 (modify-syntax-entry uc "w " text-mode-syntax-table))
|
|
91
|
|
92 (defun set-case-syntax (c syntax table)
|
|
93 "Make characters C case-invariant with syntax SYNTAX.
|
|
94 Sets the entries for character C in standard-case-table,
|
|
95 standard-syntax-table, and text-mode-syntax-table to indicate this.
|
|
96 SYNTAX should be \" \", \"w\", \".\" or \"_\"."
|
|
97 (aset (car table) c c)
|
|
98 (modify-syntax-entry c syntax (standard-syntax-table))
|
|
99 (modify-syntax-entry c syntax text-mode-syntax-table))
|
|
100
|
|
101 (provide 'case-table)
|