]> code.delx.au - gnu-emacs/blob - lisp/disp-table.el
(rmail-summary-get-new-mail): Don't call rmail-summary-goto-msg if msg is 0.
[gnu-emacs] / lisp / disp-table.el
1 ;;; disp-table.el --- functions for dealing with char tables.
2
3 ;; Copyright (C) 1987, 1994, 1995 Free Software Foundation, Inc.
4
5 ;; Author: Erik Naggum <erik@naggum.no>
6 ;; Based on a previous version by Howard Gayle
7 ;; Maintainer: FSF
8 ;; Keywords: i18n
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25
26 ;;; Code:
27
28 (put 'display-table 'char-table-extra-slots 6)
29
30 ;;;###autoload
31 (defun make-display-table ()
32 "Return a new, empty display table."
33 (make-char-table 'display-table nil))
34
35 (or standard-display-table
36 (setq standard-display-table (make-display-table)))
37
38 ;;; Display-table slot names. The property value says which slot.
39
40 (put 'truncation 'display-table-slot 0)
41 (put 'wrap 'display-table-slot 1)
42 (put 'escape 'display-table-slot 2)
43 (put 'control 'display-table-slot 3)
44 (put 'selective-display 'display-table-slot 4)
45 (put 'vertical-border 'display-table-slot 5)
46
47 ;;;###autoload
48 (defun display-table-slot (display-table slot)
49 "Return the value of the extra slot in DISPLAY-TABLE named SLOT.
50 SLOT may be a number from 0 to 5 inclusive, or a slot name (symbol)."
51 (let ((slot-number
52 (if (numberp slot) slot
53 (or (get slot 'display-table-slot)
54 (error "Invalid display-table slot name: %s" slot)))))
55 (char-table-extra-slot display-table slot-number)))
56
57 ;;;###autoload
58 (defun set-display-table-slot (display-table slot value)
59 "Set the value of the extra slot in DISPLAY-TABLE named SLOT to VALUE.
60 SLOT may be a number from 0 to 5 inclusive, or a name (symbol).
61 See `display-table-slot-name-alist' for the names and numbers."
62 (let ((slot-number
63 (if (numberp slot) slot
64 (or (get slot 'display-table-slot)
65 (error "Invalid display-table slot name: %s" slot)))))
66 (set-char-table-extra-slot display-table slot-number value)))
67
68 ;;;###autoload
69 (defun describe-display-table (dt)
70 "Describe the display table DT in a help buffer."
71 (with-output-to-temp-buffer "*Help*"
72 (princ "\nTruncation glyph: ")
73 (prin1 (display-table-slot dt 'truncation))
74 (princ "\nWrap glyph: ")
75 (prin1 (display-table-slot dt 'wrap))
76 (princ "\nEscape glyph: ")
77 (prin1 (display-table-slot dt 'escape))
78 (princ "\nCtrl glyph: ")
79 (prin1 (display-table-slot dt 'control))
80 (princ "\nSelective display glyph sequence: ")
81 (prin1 (display-table-slot dt 'selective-display))
82 (princ "\nVertical window border glyph: ")
83 (prin1 (display-table-slot dt 'vertical-border))
84 (princ "\nCharacter display glyph sequences:\n")
85 (save-excursion
86 (set-buffer standard-output)
87 (let ((vector (make-vector 256 nil))
88 (i 0))
89 (while (< i 256)
90 (aset vector i (aref dt i))
91 (setq i (1+ i)))
92 (describe-vector vector))
93 (help-mode))
94 (print-help-return-message)))
95
96 ;;;###autoload
97 (defun describe-current-display-table ()
98 "Describe the display table in use in the selected window and buffer."
99 (interactive)
100 (let ((disptab (or (window-display-table (selected-window))
101 buffer-display-table
102 standard-display-table)))
103 (if disptab
104 (describe-display-table disptab)
105 (message "No display table"))))
106
107 ;;;###autoload
108 (defun standard-display-8bit (l h)
109 "Display characters in the range L to H literally."
110 (while (<= l h)
111 (if (and (>= l ?\ ) (< l 127))
112 (aset standard-display-table l nil)
113 (aset standard-display-table l (vector l)))
114 (setq l (1+ l))))
115
116 ;;;###autoload
117 (defun standard-display-default (l h)
118 "Display characters in the range L to H using the default notation."
119 (while (<= l h)
120 (if (and (>= l ?\ ) (< l 127))
121 (aset standard-display-table l nil)
122 (aset standard-display-table l nil))
123 (setq l (1+ l))))
124
125 ;; This function does NOT take terminal-dependent escape sequences.
126 ;; For that, you need to go through create-glyph. Use one of the
127 ;; other functions below, or roll your own.
128 ;;;###autoload
129 (defun standard-display-ascii (c s)
130 "Display character C using printable string S."
131 (aset standard-display-table c (vconcat s)))
132
133 ;;;###autoload
134 (defun standard-display-g1 (c sc)
135 "Display character C as character SC in the g1 character set.
136 This function assumes that your terminal uses the SO/SI characters;
137 it is meaningless for an X frame."
138 (if window-system
139 (error "Cannot use string glyphs in a windowing system"))
140 (aset standard-display-table c
141 (vector (create-glyph (concat "\016" (char-to-string sc) "\017")))))
142
143 ;;;###autoload
144 (defun standard-display-graphic (c gc)
145 "Display character C as character GC in graphics character set.
146 This function assumes VT100-compatible escapes; it is meaningless for an
147 X frame."
148 (if window-system
149 (error "Cannot use string glyphs in a windowing system"))
150 (aset standard-display-table c
151 (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B")))))
152
153 ;;;###autoload
154 (defun standard-display-underline (c uc)
155 "Display character C as character UC plus underlining."
156 (if window-system (require 'faces))
157 (aset standard-display-table c
158 (vector
159 (if window-system
160 (logior uc (lsh (face-id (internal-find-face 'underline)) 8))
161 (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m"))))))
162
163 ;; Allocate a glyph code to display by sending STRING to the terminal.
164 ;;;###autoload
165 (defun create-glyph (string)
166 (if (= (length glyph-table) 65536)
167 (error "No free glyph codes remain"))
168 ;; Don't use slots that correspond to ASCII characters.
169 (if (= (length glyph-table) 32)
170 (setq glyph-table (vconcat glyph-table (make-vector 224 nil))))
171 (setq glyph-table (vconcat glyph-table (list string)))
172 (1- (length glyph-table)))
173
174 ;;;###autoload
175 (defun standard-display-european (arg)
176 "Toggle display of European characters encoded with ISO 8859.
177 When enabled, characters in the range of 160 to 255 display not
178 as octal escapes, but as accented characters.
179 With prefix argument, enable European character display iff arg is positive."
180 (interactive "P")
181 (if (or (<= (prefix-numeric-value arg) 0)
182 (and (null arg)
183 (char-table-p standard-display-table)
184 (equal (aref standard-display-table 160) [160])))
185 (standard-display-default 160 255)
186 (standard-display-8bit 160 255)))
187
188 (provide 'disp-table)
189
190 ;;; disp-table.el ends here