aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2015-05-11 17:23:36 -0400
committerStefan Monnier2015-05-11 17:23:36 -0400
commit0a21b26c58a241ac41cd12cd10cd605238bb2640 (patch)
treef345cb572f52595d112764759efbe8a964d11e25
parent3c5cc185df0d4143883d9bef921c2e5ffb59586f (diff)
downloademacs-0a21b26c58a241ac41cd12cd10cd605238bb2640.tar.gz
emacs-0a21b26c58a241ac41cd12cd10cd605238bb2640.zip
* lisp/term/xterm.el: Fix xterm-paste handling for rxvt
* lisp/term/rxvt.el: Require term/xterm. (rxvt-function-map): Use xterm-rxvt-function-map. (rxvt-standard-colors): Move before first use. (terminal-init-rxvt): Use xterm--push-map and xterm-register-default-colors. (rxvt-rgb-convert-to-16bit, rxvt-register-default-colors): Remove. * lisp/term/xterm.el (xterm-rxvt-function-map): New var. Move shared bindings between rxvt and xterm to it. (xterm-function-map): Use it. Move the xterm-paste binding to xterm-rxvt-function-map (bug#20444). (xterm-standard-colors): Move before first use. (xterm--push-map): New function. (xterm-register-default-colors): Take standard colors as argument. (terminal-init-xterm): Use it. Adjust call to xterm-register-default-colors.
-rw-r--r--lisp/term/rxvt.el142
-rw-r--r--lisp/term/xterm.el148
2 files changed, 92 insertions, 198 deletions
diff --git a/lisp/term/rxvt.el b/lisp/term/rxvt.el
index fa981c6625b..c2055088fb5 100644
--- a/lisp/term/rxvt.el
+++ b/lisp/term/rxvt.el
@@ -24,36 +24,21 @@
24 24
25;;; Code: 25;;; Code:
26 26
27(require 'term/xterm)
28
27(defvar rxvt-function-map 29(defvar rxvt-function-map
28 (let ((map (make-sparse-keymap))) 30 (let ((map (make-sparse-keymap)))
31 (set-keymap-parent map xterm-rxvt-function-map)
29 32
30 ;; Set up input-decode-map entries that termcap and terminfo don't know. 33 ;; Set up input-decode-map entries that termcap and terminfo don't know.
31 (define-key map "\e[A" [up])
32 (define-key map "\e[B" [down])
33 (define-key map "\e[C" [right])
34 (define-key map "\e[D" [left])
35 (define-key map "\e[2~" [insert])
36 (define-key map "\e[3~" [delete])
37 (define-key map "\e[4~" [select])
38 (define-key map "\e[5~" [prior])
39 (define-key map "\e[6~" [next])
40 (define-key map "\e[7~" [home]) 34 (define-key map "\e[7~" [home])
41 (define-key map "\e[8~" [end]) 35 (define-key map "\e[8~" [end])
42 (define-key map "\e[11~" [f1])
43 (define-key map "\e[12~" [f2])
44 (define-key map "\e[13~" [f3])
45 (define-key map "\e[14~" [f4])
46 (define-key map "\e[15~" [f5])
47 (define-key map "\e[17~" [f6])
48 (define-key map "\e[18~" [f7])
49 (define-key map "\e[19~" [f8])
50 (define-key map "\e[20~" [f9])
51 (define-key map "\e[21~" [f10])
52 ;; The strings emitted by f11 and f12 are the same as the strings 36 ;; The strings emitted by f11 and f12 are the same as the strings
53 ;; emitted by S-f1 and S-f2, so don't define f11 and f12. 37 ;; emitted by S-f1 and S-f2, so don't define f11 and f12.
54 ;; (define-key rxvt-function-map "\e[23~" [f11]) 38 ;; (define-key rxvt-function-map "\e[23~" [f11])
55 ;; (define-key rxvt-function-map "\e[24~" [f12]) 39 ;; (define-key rxvt-function-map "\e[24~" [f12])
56 (define-key map "\e[29~" [print]) 40 (define-key map "\e[23~" [S-f1])
41 (define-key map "\e[24~" [S-f2])
57 42
58 (define-key map "\e[11^" [C-f1]) 43 (define-key map "\e[11^" [C-f1])
59 (define-key map "\e[12^" [C-f2]) 44 (define-key map "\e[12^" [C-f2])
@@ -66,8 +51,6 @@
66 (define-key map "\e[20^" [C-f9]) 51 (define-key map "\e[20^" [C-f9])
67 (define-key map "\e[21^" [C-f10]) 52 (define-key map "\e[21^" [C-f10])
68 53
69 (define-key map "\e[23~" [S-f1])
70 (define-key map "\e[24~" [S-f2])
71 (define-key map "\e[25~" [S-f3]) 54 (define-key map "\e[25~" [S-f3])
72 (define-key map "\e[26~" [S-f4]) 55 (define-key map "\e[26~" [S-f4])
73 (define-key map "\e[28~" [S-f5]) 56 (define-key map "\e[28~" [S-f5])
@@ -99,7 +82,6 @@
99 (define-key map "\eOa" [C-up]) 82 (define-key map "\eOa" [C-up])
100 (define-key map "\eOb" [C-down]) 83 (define-key map "\eOb" [C-down])
101 84
102 (define-key map "\e[2;2~" [S-insert])
103 (define-key map "\e[3$" [S-delete]) 85 (define-key map "\e[3$" [S-delete])
104 (define-key map "\e[5$" [S-prior]) 86 (define-key map "\e[5$" [S-prior])
105 (define-key map "\e[6$" [S-next]) 87 (define-key map "\e[6$" [S-next])
@@ -157,26 +139,6 @@
157 map) 139 map)
158 "Keymap of possible alternative meanings for some keys.") 140 "Keymap of possible alternative meanings for some keys.")
159 141
160(defun terminal-init-rxvt ()
161 "Terminal initialization function for rxvt."
162
163 (let ((map (copy-keymap rxvt-alternatives-map)))
164 (set-keymap-parent map (keymap-parent local-function-key-map))
165 (set-keymap-parent local-function-key-map map))
166
167 ;; Use inheritance to let the main keymap override those defaults.
168 ;; This way we don't override terminfo-derived settings or settings
169 ;; made in the init file.
170 (let ((m (copy-keymap rxvt-function-map)))
171 (set-keymap-parent m (keymap-parent input-decode-map))
172 (set-keymap-parent input-decode-map m))
173
174 ;; Initialize colors and background mode.
175 (rxvt-register-default-colors)
176 (rxvt-set-background-mode)
177 ;; This recomputes all the default faces given the colors we've just set up.
178 (tty-set-up-initial-frame-faces))
179
180;; Set up colors, for those versions of rxvt that support it. 142;; Set up colors, for those versions of rxvt that support it.
181(defvar rxvt-standard-colors 143(defvar rxvt-standard-colors
182 ;; The names of the colors in the comments taken from the rxvt.1 man 144 ;; The names of the colors in the comments taken from the rxvt.1 man
@@ -199,93 +161,17 @@
199 ("brightwhite" 15 (255 255 255))) ; white 161 ("brightwhite" 15 (255 255 255))) ; white
200 "Names of 16 standard rxvt colors, their numbers, and RGB values.") 162 "Names of 16 standard rxvt colors, their numbers, and RGB values.")
201 163
202(defun rxvt-rgb-convert-to-16bit (prim) 164(defun terminal-init-rxvt ()
203 "Convert an 8-bit primary color value PRIM to a corresponding 16-bit value." 165 "Terminal initialization function for rxvt."
204 (logior prim (lsh prim 8)))
205
206(defun rxvt-register-default-colors ()
207 "Register the default set of colors for rxvt or compatible emulator.
208 166
209This function registers the number of colors returned by `display-color-cells' 167 (xterm--push-map rxvt-alternatives-map local-function-key-map)
210for the currently selected frame." 168 (xterm--push-map rxvt-function-map input-decode-map)
211 (let* ((ncolors (display-color-cells))
212 (colors rxvt-standard-colors)
213 (color (car colors)))
214 (if (> ncolors 0)
215 ;; Clear the 8 default tty colors registered by startup.el
216 (tty-color-clear))
217 ;; Only register as many colors as are supported by the display.
218 (while (and (> ncolors 0) colors)
219 (tty-color-define (car color) (cadr color)
220 (mapcar 'rxvt-rgb-convert-to-16bit
221 (car (cddr color))))
222 (setq colors (cdr colors)
223 color (car colors)
224 ncolors (1- ncolors)))
225 (when (> ncolors 0)
226 (cond
227 ((= ncolors 240) ; 256-color rxvt
228 ;; 216 non-gray colors first
229 (let ((r 0) (g 0) (b 0))
230 (while (> ncolors 24)
231 ;; This and other formulas taken from 256colres.pl and
232 ;; 88colres.pl in the xterm distribution.
233 (tty-color-define (format "color-%d" (- 256 ncolors))
234 (- 256 ncolors)
235 (mapcar 'rxvt-rgb-convert-to-16bit
236 (list (if (zerop r) 0 (+ (* r 40) 55))
237 (if (zerop g) 0 (+ (* g 40) 55))
238 (if (zerop b) 0 (+ (* b 40) 55)))))
239 (setq b (1+ b))
240 (if (> b 5)
241 (setq g (1+ g)
242 b 0))
243 (if (> g 5)
244 (setq r (1+ r)
245 g 0))
246 (setq ncolors (1- ncolors))))
247 ;; Now the 24 gray colors
248 (while (> ncolors 0)
249 (setq color (rxvt-rgb-convert-to-16bit (+ 8 (* (- 24 ncolors) 10))))
250 (tty-color-define (format "color-%d" (- 256 ncolors))
251 (- 256 ncolors)
252 (list color color color))
253 (setq ncolors (1- ncolors))))
254 169
255 ((= ncolors 72) ; rxvt-unicode 170 ;; Initialize colors and background mode.
256 ;; 64 non-gray colors 171 (xterm-register-default-colors rxvt-standard-colors)
257 (let ((levels '(0 139 205 255)) 172 (rxvt-set-background-mode)
258 (r 0) (g 0) (b 0)) 173 ;; This recomputes all the default faces given the colors we've just set up.
259 (while (> ncolors 8) 174 (tty-set-up-initial-frame-faces))
260 (tty-color-define (format "color-%d" (- 88 ncolors))
261 (- 88 ncolors)
262 (mapcar 'rxvt-rgb-convert-to-16bit
263 (list (nth r levels)
264 (nth g levels)
265 (nth b levels))))
266 (setq b (1+ b))
267 (if (> b 3)
268 (setq g (1+ g)
269 b 0))
270 (if (> g 3)
271 (setq r (1+ r)
272 g 0))
273 (setq ncolors (1- ncolors))))
274 ;; Now the 8 gray colors
275 (while (> ncolors 0)
276 (setq color (rxvt-rgb-convert-to-16bit
277 (floor
278 (if (= ncolors 8)
279 46.36363636
280 (+ (* (- 8 ncolors) 23.18181818) 69.54545454)))))
281 (tty-color-define (format "color-%d" (- 88 ncolors))
282 (- 88 ncolors)
283 (list color color color))
284 (setq ncolors (1- ncolors))))
285 (t (error "Unsupported number of rxvt colors (%d)" (+ 16 ncolors)))))
286 ;; Modifying color mappings means realized faces don't use the
287 ;; right colors, so clear them.
288 (clear-face-cache)))
289 175
290;; rxvt puts the default colors into an environment variable 176;; rxvt puts the default colors into an environment variable
291;; COLORFGBG. We use this to set the background mode in a more 177;; COLORFGBG. We use this to set the background mode in a more
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 79699c6fe43..667e4ce63ee 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -95,20 +95,50 @@ string bytes that can be copied is 3/4 of this value."
95 95
96(define-key global-map [xterm-paste] #'xterm-paste) 96(define-key global-map [xterm-paste] #'xterm-paste)
97 97
98(defvar xterm-function-map 98(defvar xterm-rxvt-function-map
99 (let ((map (make-sparse-keymap))) 99 (let ((map (make-sparse-keymap)))
100 (define-key map "\e[2~" [insert])
101 (define-key map "\e[3~" [delete])
102 (define-key map "\e[4~" [select])
103 (define-key map "\e[5~" [prior])
104 (define-key map "\e[6~" [next])
100 105
101 ;; xterm from X.org 6.8.2 uses these key definitions.
102 (define-key map "\eOP" [f1])
103 (define-key map "\eOQ" [f2])
104 (define-key map "\eOR" [f3])
105 (define-key map "\eOS" [f4])
106 (define-key map "\e[15~" [f5]) 106 (define-key map "\e[15~" [f5])
107 (define-key map "\e[17~" [f6]) 107 (define-key map "\e[17~" [f6])
108 (define-key map "\e[18~" [f7]) 108 (define-key map "\e[18~" [f7])
109 (define-key map "\e[19~" [f8]) 109 (define-key map "\e[19~" [f8])
110 (define-key map "\e[20~" [f9]) 110 (define-key map "\e[20~" [f9])
111 (define-key map "\e[21~" [f10]) 111 (define-key map "\e[21~" [f10])
112
113 (define-key map "\e[2;2~" [S-insert])
114
115 ;; Other versions of xterm might emit these.
116 (define-key map "\e[A" [up])
117 (define-key map "\e[B" [down])
118 (define-key map "\e[C" [right])
119 (define-key map "\e[D" [left])
120
121 (define-key map "\e[11~" [f1])
122 (define-key map "\e[12~" [f2])
123 (define-key map "\e[13~" [f3])
124 (define-key map "\e[14~" [f4])
125
126 ;; Recognize the start of a bracketed paste sequence. The handler
127 ;; internally recognizes the end.
128 (define-key map "\e[200~" [xterm-paste])
129
130 map)
131 "Keymap of escape sequences, shared between xterm and rxvt support.")
132
133(defvar xterm-function-map
134 (let ((map (make-sparse-keymap)))
135 (set-keymap-parent map xterm-rxvt-function-map)
136
137 ;; xterm from X.org 6.8.2 uses these key definitions.
138 (define-key map "\eOP" [f1])
139 (define-key map "\eOQ" [f2])
140 (define-key map "\eOR" [f3])
141 (define-key map "\eOS" [f4])
112 (define-key map "\e[23~" [f11]) 142 (define-key map "\e[23~" [f11])
113 (define-key map "\e[24~" [f12]) 143 (define-key map "\e[24~" [f12])
114 144
@@ -237,12 +267,6 @@ string bytes that can be copied is 3/4 of this value."
237 (define-key map "\e[1;3F" [M-end]) 267 (define-key map "\e[1;3F" [M-end])
238 (define-key map "\e[1;3H" [M-home]) 268 (define-key map "\e[1;3H" [M-home])
239 269
240 (define-key map "\e[2~" [insert])
241 (define-key map "\e[3~" [delete])
242 (define-key map "\e[5~" [prior])
243 (define-key map "\e[6~" [next])
244
245 (define-key map "\e[2;2~" [S-insert])
246 (define-key map "\e[3;2~" [S-delete]) 270 (define-key map "\e[3;2~" [S-delete])
247 (define-key map "\e[5;2~" [S-prior]) 271 (define-key map "\e[5;2~" [S-prior])
248 (define-key map "\e[6;2~" [S-next]) 272 (define-key map "\e[6;2~" [S-next])
@@ -277,7 +301,6 @@ string bytes that can be copied is 3/4 of this value."
277 (define-key map "\e[5;3~" [M-prior]) 301 (define-key map "\e[5;3~" [M-prior])
278 (define-key map "\e[6;3~" [M-next]) 302 (define-key map "\e[6;3~" [M-next])
279 303
280 (define-key map "\e[4~" [select])
281 (define-key map "\e[29~" [print]) 304 (define-key map "\e[29~" [print])
282 305
283 (define-key map "\eOj" [kp-multiply]) 306 (define-key map "\eOj" [kp-multiply])
@@ -482,10 +505,6 @@ string bytes that can be copied is 3/4 of this value."
482 (format "\e[%d;%du" (nth 1 bind) (nth 0 bind)) (nth 2 bind))) 505 (format "\e[%d;%du" (nth 1 bind) (nth 0 bind)) (nth 2 bind)))
483 506
484 ;; Other versions of xterm might emit these. 507 ;; Other versions of xterm might emit these.
485 (define-key map "\e[A" [up])
486 (define-key map "\e[B" [down])
487 (define-key map "\e[C" [right])
488 (define-key map "\e[D" [left])
489 (define-key map "\e[1~" [home]) 508 (define-key map "\e[1~" [home])
490 509
491 (define-key map "\eO2A" [S-up]) 510 (define-key map "\eO2A" [S-up])
@@ -502,15 +521,6 @@ string bytes that can be copied is 3/4 of this value."
502 (define-key map "\eO5F" [C-end]) 521 (define-key map "\eO5F" [C-end])
503 (define-key map "\eO5H" [C-home]) 522 (define-key map "\eO5H" [C-home])
504 523
505 (define-key map "\e[11~" [f1])
506 (define-key map "\e[12~" [f2])
507 (define-key map "\e[13~" [f3])
508 (define-key map "\e[14~" [f4])
509
510 ;; Recognize the start of a bracketed paste sequence. The handler
511 ;; internally recognizes the end.
512 (define-key map "\e[200~" [xterm-paste])
513
514 map) 524 map)
515 "Function key map overrides for xterm.") 525 "Function key map overrides for xterm.")
516 526
@@ -580,6 +590,29 @@ string bytes that can be copied is 3/4 of this value."
580 map) 590 map)
581 "Keymap of possible alternative meanings for some keys.") 591 "Keymap of possible alternative meanings for some keys.")
582 592
593;; Set up colors, for those versions of xterm that support it.
594(defvar xterm-standard-colors
595 ;; The names in the comments taken from XTerm-col.ad in the xterm
596 ;; distribution, see ftp://dickey.his.com/xterm/. RGB values are
597 ;; from rgb.txt.
598 '(("black" 0 ( 0 0 0)) ; black
599 ("red" 1 (205 0 0)) ; red3
600 ("green" 2 ( 0 205 0)) ; green3
601 ("yellow" 3 (205 205 0)) ; yellow3
602 ("blue" 4 ( 0 0 238)) ; blue2
603 ("magenta" 5 (205 0 205)) ; magenta3
604 ("cyan" 6 ( 0 205 205)) ; cyan3
605 ("white" 7 (229 229 229)) ; gray90
606 ("brightblack" 8 (127 127 127)) ; gray50
607 ("brightred" 9 (255 0 0)) ; red
608 ("brightgreen" 10 ( 0 255 0)) ; green
609 ("brightyellow" 11 (255 255 0)) ; yellow
610 ("brightblue" 12 (92 92 255)) ; rgb:5c/5c/ff
611 ("brightmagenta" 13 (255 0 255)) ; magenta
612 ("brightcyan" 14 ( 0 255 255)) ; cyan
613 ("brightwhite" 15 (255 255 255))) ; white
614 "Names of 16 standard xterm/aixterm colors, their numbers, and RGB values.")
615
583(defun xterm--report-background-handler () 616(defun xterm--report-background-handler ()
584 (let ((str "") 617 (let ((str "")
585 chr) 618 chr)
@@ -687,6 +720,14 @@ We run the first FUNCTION whose STRING matches the input events."
687 (push (aref (car handler) (setq i (1- i))) 720 (push (aref (car handler) (setq i (1- i)))
688 unread-command-events))))))) 721 unread-command-events)))))))
689 722
723(defun xterm--push-map (map basemap)
724 ;; Use inheritance to let the main keymaps override those defaults.
725 ;; This way we don't override terminfo-derived settings or settings
726 ;; made in the init file.
727 (set-keymap-parent
728 basemap
729 (make-composed-keymap map (keymap-parent basemap))))
730
690(defun terminal-init-xterm () 731(defun terminal-init-xterm ()
691 "Terminal initialization function for xterm." 732 "Terminal initialization function for xterm."
692 ;; rxvt terminals sometimes set the TERM variable to "xterm", but 733 ;; rxvt terminals sometimes set the TERM variable to "xterm", but
@@ -696,19 +737,10 @@ We run the first FUNCTION whose STRING matches the input events."
696 (string-match "\\`rxvt" (getenv "COLORTERM" (selected-frame)))) 737 (string-match "\\`rxvt" (getenv "COLORTERM" (selected-frame))))
697 (tty-run-terminal-initialization (selected-frame) "rxvt") 738 (tty-run-terminal-initialization (selected-frame) "rxvt")
698 739
699 (let ((map (copy-keymap xterm-alternatives-map))) 740 (xterm--push-map xterm-alternatives-map local-function-key-map)
700 (set-keymap-parent map (keymap-parent local-function-key-map)) 741 (xterm--push-map xterm-function-map input-decode-map))
701 (set-keymap-parent local-function-key-map map))
702
703 (let ((map (copy-keymap xterm-function-map)))
704 742
705 ;; Use inheritance to let the main keymap override those defaults. 743 (xterm-register-default-colors xterm-standard-colors)
706 ;; This way we don't override terminfo-derived settings or settings
707 ;; made in the init file.
708 (set-keymap-parent map (keymap-parent input-decode-map))
709 (set-keymap-parent input-decode-map map)))
710
711 (xterm-register-default-colors)
712 (tty-set-up-initial-frame-faces) 744 (tty-set-up-initial-frame-faces)
713 745
714 (if (eq xterm-extra-capabilities 'check) 746 (if (eq xterm-extra-capabilities 'check)
@@ -807,43 +839,19 @@ hitting screen's max DCS length."
807 "\a" 839 "\a"
808 (when screen "\e\\")))))))) 840 (when screen "\e\\"))))))))
809 841
810;; Set up colors, for those versions of xterm that support it.
811(defvar xterm-standard-colors
812 ;; The names in the comments taken from XTerm-col.ad in the xterm
813 ;; distribution, see ftp://dickey.his.com/xterm/. RGB values are
814 ;; from rgb.txt.
815 '(("black" 0 ( 0 0 0)) ; black
816 ("red" 1 (205 0 0)) ; red3
817 ("green" 2 ( 0 205 0)) ; green3
818 ("yellow" 3 (205 205 0)) ; yellow3
819 ("blue" 4 ( 0 0 238)) ; blue2
820 ("magenta" 5 (205 0 205)) ; magenta3
821 ("cyan" 6 ( 0 205 205)) ; cyan3
822 ("white" 7 (229 229 229)) ; gray90
823 ("brightblack" 8 (127 127 127)) ; gray50
824 ("brightred" 9 (255 0 0)) ; red
825 ("brightgreen" 10 ( 0 255 0)) ; green
826 ("brightyellow" 11 (255 255 0)) ; yellow
827 ("brightblue" 12 (92 92 255)) ; rgb:5c/5c/ff
828 ("brightmagenta" 13 (255 0 255)) ; magenta
829 ("brightcyan" 14 ( 0 255 255)) ; cyan
830 ("brightwhite" 15 (255 255 255))) ; white
831 "Names of 16 standard xterm/aixterm colors, their numbers, and RGB values.")
832
833(defun xterm-rgb-convert-to-16bit (prim) 842(defun xterm-rgb-convert-to-16bit (prim)
834 "Convert an 8-bit primary color value PRIM to a corresponding 16-bit value." 843 "Convert an 8-bit primary color value PRIM to a corresponding 16-bit value."
835 (logior prim (lsh prim 8))) 844 (logior prim (lsh prim 8)))
836 845
837(defun xterm-register-default-colors () 846(defun xterm-register-default-colors (colors)
838 "Register the default set of colors for xterm or compatible emulator. 847 "Register the default set of colors for xterm or compatible emulator.
839 848
840This function registers the number of colors returned by `display-color-cells' 849This function registers the number of colors returned by `display-color-cells'
841for the currently selected frame. The first 16 colors are taken from 850for the currently selected frame. The first (16) colors are taken from
842`xterm-standard-colors', which see, while the rest are computed assuming 851COLORS, which see, while the rest are computed assuming
843either the 88- or 256-color standard color scheme supported by latest 852either the 88- or 256-color standard color scheme supported by latest
844versions of xterm." 853versions of xterm."
845 (let* ((ncolors (display-color-cells (selected-frame))) 854 (let* ((ncolors (display-color-cells))
846 (colors xterm-standard-colors)
847 (color (car colors))) 855 (color (car colors)))
848 (if (> ncolors 0) 856 (if (> ncolors 0)
849 ;; Clear the 8 default tty colors registered by startup.el 857 ;; Clear the 8 default tty colors registered by startup.el
@@ -851,12 +859,12 @@ versions of xterm."
851 ;; Only register as many colors as are supported by the display. 859 ;; Only register as many colors as are supported by the display.
852 (while (and (> ncolors 0) colors) 860 (while (and (> ncolors 0) colors)
853 (tty-color-define (car color) (cadr color) 861 (tty-color-define (car color) (cadr color)
854 (mapcar 'xterm-rgb-convert-to-16bit 862 (mapcar #'xterm-rgb-convert-to-16bit
855 (car (cddr color)))) 863 (car (cddr color))))
856 (setq colors (cdr colors) 864 (setq colors (cdr colors)
857 color (car colors) 865 color (car colors)
858 ncolors (1- ncolors))) 866 ncolors (1- ncolors)))
859 ;; We've exhausted the colors from `xterm-standard-colors'. If there 867 ;; We've exhausted the colors from `colors'. If there
860 ;; are more colors to support, compute them now. 868 ;; are more colors to support, compute them now.
861 (when (> ncolors 0) 869 (when (> ncolors 0)
862 (cond 870 (cond
@@ -868,7 +876,7 @@ versions of xterm."
868 ;; 88colres.pl in the xterm distribution. 876 ;; 88colres.pl in the xterm distribution.
869 (tty-color-define (format "color-%d" (- 256 ncolors)) 877 (tty-color-define (format "color-%d" (- 256 ncolors))
870 (- 256 ncolors) 878 (- 256 ncolors)
871 (mapcar 'xterm-rgb-convert-to-16bit 879 (mapcar #'xterm-rgb-convert-to-16bit
872 (list (if (zerop r) 0 (+ (* r 40) 55)) 880 (list (if (zerop r) 0 (+ (* r 40) 55))
873 (if (zerop g) 0 (+ (* g 40) 55)) 881 (if (zerop g) 0 (+ (* g 40) 55))
874 (if (zerop b) 0 (+ (* b 40) 55))))) 882 (if (zerop b) 0 (+ (* b 40) 55)))))
@@ -895,7 +903,7 @@ versions of xterm."
895 (while (> ncolors 8) 903 (while (> ncolors 8)
896 (tty-color-define (format "color-%d" (- 88 ncolors)) 904 (tty-color-define (format "color-%d" (- 88 ncolors))
897 (- 88 ncolors) 905 (- 88 ncolors)
898 (mapcar 'xterm-rgb-convert-to-16bit 906 (mapcar #'xterm-rgb-convert-to-16bit
899 (list (nth r levels) 907 (list (nth r levels)
900 (nth g levels) 908 (nth g levels)
901 (nth b levels)))) 909 (nth b levels))))