Mercurial > emacs
annotate lisp/facemenu.el @ 14655:8246444fbe55
(unforward-rmail-message): Handle any kind of forwarding delimiters.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 24 Feb 1996 00:36:29 +0000 |
parents | 6dfd1f4fa87c |
children | 64c1d20f4b5f |
rev | line source |
---|---|
13337 | 1 ;;; facemenu.el --- create a face menu for interactively adding fonts to text |
14169 | 2 |
14154
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
3 ;; Copyright (c) 1994, 1995, 1996 Free Software Foundation, Inc. |
8743 | 4 |
12082
257af4819582
Change email address for Boris.
Boris Goldowsky <boris@gnu.org>
parents:
12014
diff
changeset
|
5 ;; Author: Boris Goldowsky <boris@gnu.ai.mit.edu> |
8743 | 6 ;; Keywords: faces |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
8743 | 24 |
25 ;;; Commentary: | |
14169 | 26 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
27 ;; This file defines a menu of faces (bold, italic, etc) which allows you to |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
28 ;; set the face used for a region of the buffer. Some faces also have |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
29 ;; keybindings, which are shown in the menu. Faces with names beginning with |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
30 ;; "fg:" or "bg:", as in "fg:red", are treated specially. |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
31 ;; Such faces are assumed to consist only of a foreground (if "fg:") or |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
32 ;; background (if "bg:") color. They are thus put into the color submenus |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
33 ;; rather than the general Face submenu. These faces can also be |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
34 ;; automatically created by selecting the "Other..." menu items in the |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
35 ;; "Foreground" and "Background" submenus. |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
36 ;; |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
37 ;; The menu also contains submenus for indentation and justification-changing |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
38 ;; commands. |
8743 | 39 |
40 ;;; Usage: | |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
41 ;; Selecting a face from the menu or typing the keyboard equivalent will |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
42 ;; change the region to use that face. If you use transient-mark-mode and the |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
43 ;; region is not active, the face will be remembered and used for the next |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
44 ;; insertion. It will be forgotten if you move point or make other |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
45 ;; modifications before inserting or typing anything. |
8743 | 46 ;; |
47 ;; Faces can be selected from the keyboard as well. | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
48 ;; The standard keybindings are M-g (or ESC g) + letter: |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
49 ;; M-g i = "set italic", M-g b = "set bold", etc. |
8743 | 50 |
51 ;;; Customization: | |
52 ;; An alternative set of keybindings that may be easier to type can be set up | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
53 ;; using "Alt" or "Hyper" keys. This requires that you either have or create |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
54 ;; an Alt or Hyper key on your keyboard. On my keyboard, there is a key |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
55 ;; labeled "Alt", but to make it act as an Alt key I have to put this command |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
56 ;; into my .xinitrc: |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
57 ;; xmodmap -e "add Mod3 = Alt_L" |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
58 ;; Or, I can make it into a Hyper key with this: |
8743 | 59 ;; xmodmap -e "keysym Alt_L = Hyper_L" -e "add Mod2 = Hyper_L" |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
60 ;; Check with local X-perts for how to do it on your system. |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
61 ;; Then you can define your keybindings with code like this in your .emacs: |
8743 | 62 ;; (setq facemenu-keybindings |
63 ;; '((default . [?\H-d]) | |
64 ;; (bold . [?\H-b]) | |
65 ;; (italic . [?\H-i]) | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
66 ;; (bold-italic . [?\H-l]) |
8743 | 67 ;; (underline . [?\H-u]))) |
68 ;; (setq facemenu-keymap global-map) | |
69 ;; (setq facemenu-key nil) | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
70 ;; (define-key global-map [?\H-c] 'facemenu-set-foreground) ; set fg color |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
71 ;; (define-key global-map [?\H-C] 'facemenu-set-background) ; set bg color |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
72 ;; (require 'facemenu) |
8743 | 73 ;; |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
74 ;; The order of the faces that appear in the menu and their keybindings can be |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
75 ;; controlled by setting the variables `facemenu-keybindings' and |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
76 ;; `facemenu-new-faces-at-end'. List faces that you don't use in documents |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
77 ;; (eg, `region') in `facemenu-unlisted-faces'. |
8743 | 78 |
79 ;;; Known Problems: | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
80 ;; Bold and Italic do not combine to create bold-italic if you select them |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
81 ;; both, although most other combinations (eg bold + underline + some color) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
82 ;; do the intuitive thing. |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
83 ;; |
8743 | 84 ;; There is at present no way to display what the faces look like in |
85 ;; the menu itself. | |
86 ;; | |
87 ;; `list-faces-display' shows the faces in a different order than | |
88 ;; this menu, which could be confusing. I do /not/ sort the list | |
89 ;; alphabetically, because I like the default order: it puts the most | |
90 ;; basic, common fonts first. | |
91 ;; | |
92 ;; Please send me any other problems, comments or ideas. | |
93 | |
94 ;;; Code: | |
95 | |
96 (provide 'facemenu) | |
97 | |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
98 ;;; Provide some binding for startup: |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
99 ;;;###autoload (define-key global-map "\M-g" 'facemenu-keymap) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
100 ;;;###autoload (autoload 'facemenu-keymap "facemenu" "Keymap for face-changing commands." t 'keymap) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
101 |
10238
0fcafe7e34cc
(facemenu-key): Change to M-g.
Richard M. Stallman <rms@gnu.org>
parents:
9874
diff
changeset
|
102 (defvar facemenu-key "\M-g" |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
103 "Prefix key to use for facemenu commands.") |
8743 | 104 |
105 (defvar facemenu-keybindings | |
106 '((default . "d") | |
107 (bold . "b") | |
108 (italic . "i") | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
109 (bold-italic . "l") ; {bold} intersect {italic} = {l} |
8743 | 110 (underline . "u")) |
111 "Alist of interesting faces and keybindings. | |
112 Each element is itself a list: the car is the name of the face, | |
113 the next element is the key to use as a keyboard equivalent of the menu item; | |
114 the binding is made in facemenu-keymap. | |
115 | |
116 The faces specifically mentioned in this list are put at the top of | |
117 the menu, in the order specified. All other faces which are defined, | |
118 except for those in `facemenu-unlisted-faces', are listed after them, | |
119 but get no keyboard equivalents. | |
120 | |
121 If you change this variable after loading facemenu.el, you will need to call | |
122 `facemenu-update' to make it take effect.") | |
123 | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
124 (defvar facemenu-new-faces-at-end t |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
125 "Where in the menu to insert newly-created faces. |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
126 This should be nil to put them at the top of the menu, or t to put them |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
127 just before \"Other\" at the end.") |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
128 |
8743 | 129 (defvar facemenu-unlisted-faces |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
130 '(modeline region secondary-selection highlight scratch-face) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
131 "List of faces not to include in the Face menu. |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
132 You can set this list before loading facemenu.el, or add a face to it before |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
133 creating that face if you do not want it to be listed. If you change the |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
134 variable so as to eliminate faces that have already been added to the menu, |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
135 call `facemenu-update' to recalculate the menu contents. |
8743 | 136 |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
137 If this variable is t, no faces will be added to the menu. This is useful for |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
138 temporarily turning off the feature that automatically adds faces to the menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
139 when they are created.") |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
140 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
141 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
142 (defvar facemenu-face-menu |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
143 (let ((map (make-sparse-keymap "Face"))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
144 (define-key map "o" (cons "Other..." 'facemenu-set-face)) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
145 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
146 "Menu keymap for faces.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
147 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
148 (defalias 'facemenu-face-menu facemenu-face-menu) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
149 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
150 ;;;###autoload |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
151 (defvar facemenu-foreground-menu |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
152 (let ((map (make-sparse-keymap "Foreground Color"))) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
153 (define-key map "o" (cons "Other..." 'facemenu-set-foreground)) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
154 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
155 "Menu keymap for foreground colors.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
156 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
157 (defalias 'facemenu-foreground-menu facemenu-foreground-menu) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
158 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
159 ;;;###autoload |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
160 (defvar facemenu-background-menu |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
161 (let ((map (make-sparse-keymap "Background Color"))) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
162 (define-key map "o" (cons "Other..." 'facemenu-set-background)) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
163 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
164 "Menu keymap for background colors") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
165 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
166 (defalias 'facemenu-background-menu facemenu-background-menu) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
167 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
168 ;;;###autoload |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
169 (defvar facemenu-special-menu |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
170 (let ((map (make-sparse-keymap "Special"))) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
171 (define-key map [?s] (cons "Remove Special" 'facemenu-remove-special)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
172 (define-key map [?t] (cons "Intangible" 'facemenu-set-intangible)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
173 (define-key map [?v] (cons "Invisible" 'facemenu-set-invisible)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
174 (define-key map [?r] (cons "Read-Only" 'facemenu-set-read-only)) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
175 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
176 "Menu keymap for non-face text-properties.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
177 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
178 (defalias 'facemenu-special-menu facemenu-special-menu) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
179 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
180 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
181 (defvar facemenu-justification-menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
182 (let ((map (make-sparse-keymap "Justification"))) |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
183 (define-key map [?c] (cons "Center" 'set-justification-center)) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
184 (define-key map [?b] (cons "Full" 'set-justification-full)) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
185 (define-key map [?r] (cons "Right" 'set-justification-right)) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
186 (define-key map [?l] (cons "Left" 'set-justification-left)) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
187 (define-key map [?u] (cons "Unfilled" 'set-justification-none)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
188 map) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
189 "Submenu for text justification commands.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
190 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
191 (defalias 'facemenu-justification-menu facemenu-justification-menu) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
192 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
193 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
194 (defvar facemenu-indentation-menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
195 (let ((map (make-sparse-keymap "Indentation"))) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
196 (define-key map [decrease-right-margin] |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
197 (cons "Indent Right Less" 'decrease-right-margin)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
198 (define-key map [increase-right-margin] |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
199 (cons "Indent Right More" 'increase-right-margin)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
200 (define-key map [decrease-left-margin] |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
201 (cons "Indent Less" 'decrease-left-margin)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
202 (define-key map [increase-left-margin] |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
203 (cons "Indent More" 'increase-left-margin)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
204 map) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
205 "Submenu for indentation commands.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
206 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
207 (defalias 'facemenu-indentation-menu facemenu-indentation-menu) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
208 |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
209 ;; This is split up to avoid an overlong line in loaddefs.el. |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
210 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
211 (defvar facemenu-menu nil |
9874
2bf88bd23cbb
(facemenu-update): Use C-down-mouse-2 for the menu.
Richard M. Stallman <rms@gnu.org>
parents:
9623
diff
changeset
|
212 "Facemenu top-level menu keymap.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
213 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
214 (setq facemenu-menu (make-sparse-keymap "Text Properties")) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
215 ;;;###autoload |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
216 (let ((map facemenu-menu)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
217 (define-key map [dc] (cons "Display Colors" 'list-colors-display)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
218 (define-key map [df] (cons "Display Faces" 'list-faces-display)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
219 (define-key map [dp] (cons "List Properties" 'list-text-properties-at)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
220 (define-key map [ra] (cons "Remove All" 'facemenu-remove-all)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
221 (define-key map [rm] (cons "Remove Properties" 'facemenu-remove-props)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
222 (define-key map [s1] (list "-----------------"))) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
223 ;;;###autoload |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
224 (let ((map facemenu-menu)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
225 (define-key map [in] (cons "Indentation" 'facemenu-indentation-menu)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
226 (define-key map [ju] (cons "Justification" 'facemenu-justification-menu)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
227 (define-key map [s2] (list "-----------------")) |
12269 | 228 (define-key map [sp] (cons "Special Properties" 'facemenu-special-menu)) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
229 (define-key map [bg] (cons "Background Color" 'facemenu-background-menu)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
230 (define-key map [fg] (cons "Foreground Color" 'facemenu-foreground-menu)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
231 (define-key map [fc] (cons "Face" 'facemenu-face-menu))) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
232 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
233 (defalias 'facemenu-menu facemenu-menu) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
234 |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
235 (defvar facemenu-keymap |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
236 (let ((map (make-sparse-keymap "Set face"))) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
237 (define-key map "o" (cons "Other..." 'facemenu-set-face)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
238 map) |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
239 "Keymap for face-changing commands. |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
240 `Facemenu-update' fills in the keymap according to the bindings |
9874
2bf88bd23cbb
(facemenu-update): Use C-down-mouse-2 for the menu.
Richard M. Stallman <rms@gnu.org>
parents:
9623
diff
changeset
|
241 requested in `facemenu-keybindings'.") |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
242 (defalias 'facemenu-keymap facemenu-keymap) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
243 |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
244 |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
245 (defvar facemenu-add-face-function nil |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
246 "Function called at beginning of text to change or `nil'. |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
247 This function is passed the FACE to set and END of text to change, and must |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
248 return a string which is inserted. It may set `facemenu-end-add-face'.") |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
249 |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
250 (defvar facemenu-end-add-face nil |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
251 "String to insert or function called at end of text to change or `nil'. |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
252 This function is passed the FACE to set, and must return a string which is |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
253 inserted.") |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
254 |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
255 (defvar facemenu-remove-face-function nil |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
256 "When non-`nil' function called to remove faces. |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
257 This function is passed the START and END of text to change. |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
258 May also be `t' meaning to use `facemenu-add-face-function'.") |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
259 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
260 ;;; Internal Variables |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
261 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
262 (defvar facemenu-color-alist nil |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
263 ;; Don't initialize here; that doesn't work if preloaded. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
264 "Alist of colors, used for completion. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
265 If null, `facemenu-read-color' will set it.") |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
266 |
8743 | 267 (defun facemenu-update () |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
268 "Add or update the \"Face\" menu in the menu bar. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
269 You can call this to update things if you change any of the menu configuration |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
270 variables." |
8743 | 271 (interactive) |
272 | |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
273 ;; Global bindings: |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
274 (define-key global-map [C-down-mouse-2] 'facemenu-menu) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
275 (if facemenu-key (define-key global-map facemenu-key 'facemenu-keymap)) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
276 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
277 ;; Add each defined face to the menu. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
278 (facemenu-iterate 'facemenu-add-new-face |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
279 (facemenu-complete-face-list facemenu-keybindings))) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
280 |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
281 ;;;###autoload |
8743 | 282 (defun facemenu-set-face (face &optional start end) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
283 "Add FACE to the region or next character typed. |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
284 It will be added to the top of the face list; any faces lower on the list that |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
285 will not show through at all will be removed. |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
286 |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
287 Interactively, the face to be used is read with the minibuffer. |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
288 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
289 If the region is active and there is no prefix argument, |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
290 this command sets the region to the requested face. |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
291 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
292 Otherwise, this command specifies the face for the next character |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
293 inserted. Moving point or switching buffers before |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
294 typing a character to insert cancels the specification." |
8743 | 295 (interactive (list (read-face-name "Use face: "))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
296 (barf-if-buffer-read-only) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
297 (facemenu-add-new-face face) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
298 (if (and mark-active (not current-prefix-arg)) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
299 (let ((start (or start (region-beginning))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
300 (end (or end (region-end)))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
301 (facemenu-add-face face start end)) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
302 (facemenu-add-face face))) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
303 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
304 ;;;###autoload |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
305 (defun facemenu-set-foreground (color &optional start end) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
306 "Set the foreground color of the region or next character typed. |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
307 The color is prompted for. A face named `fg:color' is used \(or created). |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
308 If the region is active, it will be set to the requested face. If |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
309 it is inactive \(even if mark-even-if-inactive is set) the next |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
310 character that is typed \(via `self-insert-command') will be set to |
11830
f92fb9b9e3c8
(facemenu-set-face-from-menu): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
11465
diff
changeset
|
311 the selected face. Moving point or switching buffers before |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
312 typing a character cancels the request." |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
313 (interactive (list (facemenu-read-color "Foreground color: "))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
314 (let ((face (intern (concat "fg:" color)))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
315 (or (facemenu-get-face face) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
316 (error "Unknown color: %s" color)) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
317 (facemenu-set-face face start end))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
318 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
319 ;;;###autoload |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
320 (defun facemenu-set-background (color &optional start end) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
321 "Set the background color of the region or next character typed. |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
322 The color is prompted for. A face named `bg:color' is used \(or created). |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
323 If the region is active, it will be set to the requested face. If |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
324 it is inactive \(even if mark-even-if-inactive is set) the next |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
325 character that is typed \(via `self-insert-command') will be set to |
11830
f92fb9b9e3c8
(facemenu-set-face-from-menu): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
11465
diff
changeset
|
326 the selected face. Moving point or switching buffers before |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
327 typing a character cancels the request." |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
328 (interactive (list (facemenu-read-color "Background color: "))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
329 (let ((face (intern (concat "bg:" color)))) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
330 (or (facemenu-get-face face) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
331 (error "Unknown color: %s" color)) |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
332 (facemenu-set-face face start end))) |
8743 | 333 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
334 ;;;###autoload |
8743 | 335 (defun facemenu-set-face-from-menu (face start end) |
336 "Set the face of the region or next character typed. | |
337 This function is designed to be called from a menu; the face to use | |
338 is the menu item's name. | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
339 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
340 If the region is active and there is no prefix argument, |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
341 this command sets the region to the requested face. |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
342 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
343 Otherwise, this command specifies the face for the next character |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
344 inserted. Moving point or switching buffers before |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
345 typing a character to insert cancels the specification." |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
346 (interactive (list last-command-event |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
347 (if (and mark-active (not current-prefix-arg)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
348 (region-beginning)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
349 (if (and mark-active (not current-prefix-arg)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
350 (region-end)))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
351 (barf-if-buffer-read-only) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
352 (facemenu-get-face face) |
8743 | 353 (if start |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
354 (facemenu-add-face face start end) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
355 (facemenu-add-face face))) |
8743 | 356 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
357 ;;;###autoload |
8743 | 358 (defun facemenu-set-invisible (start end) |
359 "Make the region invisible. | |
360 This sets the `invisible' text property; it can be undone with | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
361 `facemenu-remove-special'." |
8743 | 362 (interactive "r") |
363 (put-text-property start end 'invisible t)) | |
364 | |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
365 ;;;###autoload |
8743 | 366 (defun facemenu-set-intangible (start end) |
367 "Make the region intangible: disallow moving into it. | |
368 This sets the `intangible' text property; it can be undone with | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
369 `facemenu-remove-special'." |
8743 | 370 (interactive "r") |
371 (put-text-property start end 'intangible t)) | |
372 | |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
373 ;;;###autoload |
8743 | 374 (defun facemenu-set-read-only (start end) |
375 "Make the region unmodifiable. | |
376 This sets the `read-only' text property; it can be undone with | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
377 `facemenu-remove-special'." |
8743 | 378 (interactive "r") |
379 (put-text-property start end 'read-only t)) | |
380 | |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
381 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
382 (defun facemenu-remove-props (start end) |
8743 | 383 "Remove all text properties that facemenu added to region." |
384 (interactive "*r") ; error if buffer is read-only despite the next line. | |
385 (let ((inhibit-read-only t)) | |
386 (remove-text-properties | |
387 start end '(face nil invisible nil intangible nil | |
388 read-only nil category nil)))) | |
389 | |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
390 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
391 (defun facemenu-remove-all (start end) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
392 "Remove all text properties from the region." |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
393 (interactive "*r") ; error if buffer is read-only despite the next line. |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
394 (let ((inhibit-read-only t)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
395 (set-text-properties start end nil))) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
396 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
397 ;;;###autoload |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
398 (defun facemenu-remove-special (start end) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
399 "Remove all the \"special\" text properties from the region. |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
400 These special properties include `invisible', `intangible' and `read-only'." |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
401 (interactive "*r") ; error if buffer is read-only despite the next line. |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
402 (let ((inhibit-read-only t)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
403 (remove-text-properties |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
404 start end '(invisible nil intangible nil read-only nil)))) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
405 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
406 ;;;###autoload |
11081
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
407 (defun list-text-properties-at (p) |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
408 "Pop up a buffer listing text-properties at LOCATION." |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
409 (interactive "d") |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
410 (let ((props (text-properties-at p)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
411 str) |
11081
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
412 (if (null props) |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
413 (message "None") |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
414 (if (and (not (cdr (cdr props))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
415 (< (length (setq str (format "Text property at %d: %s %S" |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
416 p (car props) (car (cdr props))))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
417 (frame-width))) |
14312
6dfd1f4fa87c
(list-text-properties-at): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
418 (message "%s" str) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
419 (with-output-to-temp-buffer "*Text Properties*" |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
420 (princ (format "Text properties at %d:\n\n" p)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
421 (while props |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
422 (princ (format "%-20s %S\n" |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
423 (car props) (car (cdr props)))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
424 (setq props (cdr (cdr props))))))))) |
11081
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
425 |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
426 ;;;###autoload |
11372
874b91f4adc4
(facemenu-read-color): Don't ignore PROMPT arg. Make arg optional.
Boris Goldowsky <boris@gnu.org>
parents:
11234
diff
changeset
|
427 (defun facemenu-read-color (&optional prompt) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
428 "Read a color using the minibuffer." |
11372
874b91f4adc4
(facemenu-read-color): Don't ignore PROMPT arg. Make arg optional.
Boris Goldowsky <boris@gnu.org>
parents:
11234
diff
changeset
|
429 (let ((col (completing-read (or prompt "Color: ") |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
430 (or facemenu-color-alist |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
431 (if window-system |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
432 (mapcar 'list (x-defined-colors)))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
433 nil t))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
434 (if (equal "" col) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
435 nil |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
436 col))) |
8743 | 437 |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
438 ;;;###autoload |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
439 (defun list-colors-display (&optional list) |
11465
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
440 "Display names of defined colors, and show what they look like. |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
441 If the optional argument LIST is non-nil, it should be a list of |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
442 colors to display. Otherwise, this command computes a list |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
443 of colors that the current display can handle." |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
444 (interactive) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
445 (if (and (null list) window-system) |
11465
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
446 (progn |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
447 (setq list (x-defined-colors)) |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
448 ;; Delete duplicate colors. |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
449 (let ((l list)) |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
450 (while (cdr l) |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
451 (if (facemenu-color-equal (car l) (car (cdr l))) |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
452 (setcdr l (cdr (cdr l))) |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
453 (setq l (cdr l))))))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
454 (with-output-to-temp-buffer "*Colors*" |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
455 (save-excursion |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
456 (set-buffer standard-output) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
457 (let ((facemenu-unlisted-faces t) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
458 s) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
459 (while list |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
460 (setq s (point)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
461 (insert (car list)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
462 (indent-to 20) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
463 (put-text-property s (point) 'face |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
464 (facemenu-get-face |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
465 (intern (concat "bg:" (car list))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
466 (setq s (point)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
467 (insert " " (car list) "\n") |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
468 (put-text-property s (point) 'face |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
469 (facemenu-get-face |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
470 (intern (concat "fg:" (car list))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
471 (setq list (cdr list))))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
472 |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
473 (defun facemenu-color-equal (a b) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
474 "Return t if colors A and B are the same color. |
11465
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
475 A and B should be strings naming colors. |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
476 This function queries the window-system server to find out what the |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
477 color names mean. It returns nil if the colors differ or if it can't |
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
478 determine the correct answer." |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
479 (cond ((equal a b) t) |
13433
21a9f15132d7
[win32] (face-menu-read-color, list-colors-display, facemenu-color-equal, face-menu-get-face):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13337
diff
changeset
|
480 ((and (or (eq window-system 'x) (eq window-system 'win32)) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
481 (equal (x-color-values a) (x-color-values b)))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
482 ((eq window-system 'pc) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
483 (and (x-color-defined-p a) (x-color-defined-p b) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
484 (eq (msdos-color-translate a) (msdos-color-translate b)))))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
485 |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
486 (defun facemenu-add-face (face &optional start end) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
487 "Add FACE to text between START and END. |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
488 If START is `nil' or START to END is empty, add FACE to next typed character |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
489 instead. For each section of that region that has a different face property, |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
490 FACE will be consed onto it, and other faces that are completely hidden by |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
491 that will be removed from the list. |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
492 If `facemenu-add-face-function' and maybe `facemenu-end-add-face' are non-`nil' |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
493 they are used to set the face information. |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
494 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
495 As a special case, if FACE is `default', then the region is left with NO face |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
496 text property. Otherwise, selecting the default face would not have any |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
497 effect. See `facemenu-remove-face-function'." |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
498 (interactive "*xFace: \nr") |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
499 (if (and (eq face 'default) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
500 (not (eq facemenu-remove-face-function t))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
501 (if facemenu-remove-face-function |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
502 (funcall facemenu-remove-face-function start end) |
14154
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
503 (if (and start (< start end)) |
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
504 (remove-text-properties start end '(face default)) |
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
505 (setq self-insert-face 'default |
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
506 self-insert-face-command this-command))) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
507 (if facemenu-add-face-function |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
508 (save-excursion |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
509 (if end (goto-char end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
510 (save-excursion |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
511 (if start (goto-char start)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
512 (insert-before-markers |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
513 (funcall facemenu-add-face-function face end))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
514 (if facemenu-end-add-face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
515 (insert (if (stringp facemenu-end-add-face) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
516 facemenu-end-add-face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
517 (funcall facemenu-end-add-face face))))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
518 (if (and start (< start end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
519 (let ((part-start start) part-end) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
520 (while (not (= part-start end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
521 (setq part-end (next-single-property-change part-start 'face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
522 nil end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
523 (let ((prev (get-text-property part-start 'face))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
524 (put-text-property part-start part-end 'face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
525 (if (null prev) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
526 face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
527 (facemenu-active-faces |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
528 (cons face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
529 (if (listp prev) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
530 prev |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
531 (list prev))))))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
532 (setq part-start part-end))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
533 (setq self-insert-face (if (eq last-command self-insert-face-command) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
534 (cons face (if (listp self-insert-face) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
535 self-insert-face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
536 (list self-insert-face))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
537 face) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
538 self-insert-face-command this-command))))) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
539 |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
540 (defun facemenu-active-faces (face-list &optional frame) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
541 "Return from FACE-LIST those faces that would be used for display. |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
542 This means each face attribute is not specified in a face earlier in FACE-LIST |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
543 and such a face is therefore active when used to display text. |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
544 If the optional argument FRAME is given, use the faces in that frame; otherwise |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
545 use the selected frame. If t, then the global, non-frame faces are used." |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
546 (let* ((mask-atts (copy-sequence (internal-get-face (car face-list) frame))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
547 (active-list (list (car face-list))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
548 (face-list (cdr face-list)) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
549 (mask-len (length mask-atts))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
550 (while face-list |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
551 (if (let ((face-atts (internal-get-face (car face-list) frame)) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
552 (i mask-len) (useful nil)) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
553 (while (> (setq i (1- i)) 1) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
554 (and (aref face-atts i) (not (aref mask-atts i)) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
555 (aset mask-atts i (setq useful t)))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
556 useful) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
557 (setq active-list (cons (car face-list) active-list))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
558 (setq face-list (cdr face-list))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
559 (nreverse active-list))) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
560 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
561 (defun facemenu-get-face (symbol) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
562 "Make sure FACE exists. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
563 If not, it is created. If it is created and is of the form `fg:color', then |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
564 set the foreground to that color. If of the form `bg:color', set the |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
565 background. In any case, add it to the appropriate menu. Returns the face, |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
566 or nil if given a bad color." |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
567 (if (or (internal-find-face symbol) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
568 (let* ((face (make-face symbol)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
569 (name (symbol-name symbol)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
570 (color (substring name 3))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
571 (cond ((string-match "^fg:" name) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
572 (set-face-foreground face color) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
573 (and window-system |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
574 (x-color-defined-p color))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
575 ((string-match "^bg:" name) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
576 (set-face-background face color) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
577 (and window-system |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
578 (x-color-defined-p color))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
579 (t)))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
580 symbol)) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
581 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
582 (defun facemenu-add-new-face (face) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
583 "Add a FACE to the appropriate Face menu. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
584 Automatically called when a new face is created." |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
585 (let* ((name (symbol-name face)) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
586 (menu (cond ((string-match "^fg:" name) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
587 (setq name (substring name 3)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
588 'facemenu-foreground-menu) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
589 ((string-match "^bg:" name) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
590 (setq name (substring name 3)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
591 'facemenu-background-menu) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
592 (t 'facemenu-face-menu))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
593 (key (cdr (assoc face facemenu-keybindings))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
594 function menu-val) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
595 (cond ((eq t facemenu-unlisted-faces)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
596 ((memq face facemenu-unlisted-faces)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
597 (key ; has a keyboard equivalent. These go at the front. |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
598 (setq function (intern (concat "facemenu-set-" name))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
599 (fset function |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
600 (` (lambda () (interactive) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
601 (facemenu-set-face (quote (, face)))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
602 (define-key 'facemenu-keymap key (cons name function)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
603 (define-key menu key (cons name function))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
604 ((facemenu-iterate ; check if equivalent face is already in the menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
605 (lambda (m) (and (listp m) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
606 (symbolp (car m)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
607 (face-equal (car m) face))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
608 (cdr (symbol-function menu)))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
609 (t ; No keyboard equivalent. Figure out where to put it: |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
610 (setq key (vector face) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
611 function 'facemenu-set-face-from-menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
612 menu-val (symbol-function menu)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
613 (if (and facemenu-new-faces-at-end |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
614 (> (length menu-val) 3)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
615 (define-key-after menu-val key (cons name function) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
616 (car (nth (- (length menu-val) 3) menu-val))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
617 (define-key menu key (cons name function)))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
618 nil) ; Return nil for facemenu-iterate |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
619 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
620 (defun facemenu-complete-face-list (&optional oldlist) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
621 "Return list of all faces that are look different. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
622 Starts with given ALIST of faces, and adds elements only if they display |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
623 differently from any face already on the list. |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
624 The faces on ALIST will end up at the end of the returned list, in reverse |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
625 order." |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
626 (let ((list (nreverse (mapcar 'car oldlist)))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
627 (facemenu-iterate |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
628 (lambda (new-face) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
629 (if (not (memq new-face list)) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
630 (setq list (cons new-face list))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
631 nil) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
632 (nreverse (face-list))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
633 list)) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
634 |
8743 | 635 (defun facemenu-iterate (func iterate-list) |
636 "Apply FUNC to each element of LIST until one returns non-nil. | |
637 Returns the non-nil value it found, or nil if all were nil." | |
638 (while (and iterate-list (not (funcall func (car iterate-list)))) | |
639 (setq iterate-list (cdr iterate-list))) | |
640 (car iterate-list)) | |
641 | |
642 (facemenu-update) | |
643 | |
644 ;;; facemenu.el ends here |