Mercurial > emacs
annotate lisp/facemenu.el @ 43633:2c255d245320
(International, Language Environments, Specify Coding): Make it clear
that locale-coding-system is used for decoding keyboard input on X.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 02 Mar 2002 14:33:47 +0000 |
parents | ce181770fa8e |
children | e0e6df854822 |
rev | line source |
---|---|
13337 | 1 ;;; facemenu.el --- create a face menu for interactively adding fonts to text |
14169 | 2 |
43295
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
3 ;; Copyright (c) 1994, 1995, 1996, 2001, 2002 Free Software Foundation, Inc. |
8743 | 4 |
25278 | 5 ;; Author: Boris Goldowsky <boris@gnu.org> |
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]))) |
17505
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
68 ;; (facemenu-update) |
8743 | 69 ;; (setq facemenu-keymap global-map) |
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 |
8743 | 72 ;; |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
73 ;; 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
|
74 ;; controlled by setting the variables `facemenu-keybindings' and |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
75 ;; `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
|
76 ;; (eg, `region') in `facemenu-unlisted-faces'. |
8743 | 77 |
78 ;;; Known Problems: | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
79 ;; 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
|
80 ;; 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
|
81 ;; do the intuitive thing. |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
82 ;; |
8743 | 83 ;; There is at present no way to display what the faces look like in |
84 ;; the menu itself. | |
85 ;; | |
86 ;; `list-faces-display' shows the faces in a different order than | |
87 ;; this menu, which could be confusing. I do /not/ sort the list | |
88 ;; alphabetically, because I like the default order: it puts the most | |
89 ;; basic, common fonts first. | |
90 ;; | |
91 ;; Please send me any other problems, comments or ideas. | |
92 | |
93 ;;; Code: | |
94 | |
95 (provide 'facemenu) | |
96 | |
43295
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
97 (eval-when-compile |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
98 (require 'help) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
99 (require 'button)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
100 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
101 ;;; Provide some binding for startup: |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
102 ;;;###autoload (define-key global-map "\M-g" 'facemenu-keymap) |
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
103 ;;;###autoload (autoload 'facemenu-keymap "facemenu" "Keymap for face-changing commands." t 'keymap) |
17505
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
104 |
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
105 ;; Global bindings: |
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
106 (define-key global-map [C-down-mouse-2] 'facemenu-menu) |
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
107 (define-key global-map "\M-g" 'facemenu-keymap) |
8743 | 108 |
19009 | 109 (defgroup facemenu nil |
110 "Create a face menu for interactively adding fonts to text" | |
111 :group 'faces | |
112 :prefix "facemenu-") | |
113 | |
114 (defcustom facemenu-keybindings | |
8743 | 115 '((default . "d") |
116 (bold . "b") | |
117 (italic . "i") | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
118 (bold-italic . "l") ; {bold} intersect {italic} = {l} |
8743 | 119 (underline . "u")) |
41799 | 120 "Alist of interesting faces and keybindings. |
8743 | 121 Each element is itself a list: the car is the name of the face, |
122 the next element is the key to use as a keyboard equivalent of the menu item; | |
17505
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
123 the binding is made in `facemenu-keymap'. |
8743 | 124 |
125 The faces specifically mentioned in this list are put at the top of | |
126 the menu, in the order specified. All other faces which are defined, | |
127 except for those in `facemenu-unlisted-faces', are listed after them, | |
128 but get no keyboard equivalents. | |
129 | |
130 If you change this variable after loading facemenu.el, you will need to call | |
19009 | 131 `facemenu-update' to make it take effect." |
132 :type '(repeat (cons face string)) | |
133 :group 'facemenu) | |
8743 | 134 |
19009 | 135 (defcustom facemenu-new-faces-at-end t |
17505
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
136 "*Where in the menu to insert newly-created faces. |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
137 This should be nil to put them at the top of the menu, or t to put them |
19009 | 138 just before \"Other\" at the end." |
139 :type 'boolean | |
140 :group 'facemenu) | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
141 |
19009 | 142 (defcustom facemenu-unlisted-faces |
34331
7b91d8c3787f
(facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents:
30092
diff
changeset
|
143 `(modeline region secondary-selection highlight scratch-face |
7b91d8c3787f
(facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents:
30092
diff
changeset
|
144 ,(purecopy "^font-lock-") ,(purecopy "^gnus-") ,(purecopy "^message-") |
7b91d8c3787f
(facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents:
30092
diff
changeset
|
145 ,(purecopy "^ediff-") ,(purecopy "^term-") ,(purecopy "^vc-") |
7b91d8c3787f
(facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents:
30092
diff
changeset
|
146 ,(purecopy "^widget-") ,(purecopy "^custom-") ,(purecopy "^vm-")) |
17505
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
147 "*List of faces not to include in the Face menu. |
19558
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
148 Each element may be either a symbol, which is the name of a face, or a string, |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
149 which is a regular expression to be matched against face names. Matching |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
150 faces will not be added to the menu. |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
151 |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 call `facemenu-update' to recalculate the menu contents. |
8743 | 156 |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
157 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
|
158 temporarily turning off the feature that automatically adds faces to the menu |
19009 | 159 when they are created." |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
160 :type '(choice (const :tag "Don't add faces" t) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
161 (const :tag "None (do add any face)" nil) |
19558
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
162 (repeat (choice symbol regexp))) |
19009 | 163 :group 'facemenu) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
164 |
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 (defvar facemenu-face-menu |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
167 (let ((map (make-sparse-keymap "Face"))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
168 (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
|
169 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
170 "Menu keymap for faces.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
171 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
172 (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
|
173 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
174 ;;;###autoload |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
175 (defvar facemenu-foreground-menu |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
176 (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
|
177 (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
|
178 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
179 "Menu keymap for foreground colors.") |
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 (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
|
182 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
183 ;;;###autoload |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
184 (defvar facemenu-background-menu |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
185 (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
|
186 (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
|
187 map) |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
188 "Menu keymap for background colors.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
189 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
190 (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
|
191 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
192 ;;;###autoload |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
193 (defvar facemenu-special-menu |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
194 (let ((map (make-sparse-keymap "Special"))) |
27494 | 195 (define-key map [?s] (cons (purecopy "Remove Special") |
196 'facemenu-remove-special)) | |
197 (define-key map [?t] (cons (purecopy "Intangible") | |
198 'facemenu-set-intangible)) | |
199 (define-key map [?v] (cons (purecopy "Invisible") | |
200 'facemenu-set-invisible)) | |
201 (define-key map [?r] (cons (purecopy "Read-Only") | |
202 'facemenu-set-read-only)) | |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
203 map) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
204 "Menu keymap for non-face text-properties.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
205 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
206 (defalias 'facemenu-special-menu facemenu-special-menu) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
207 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
208 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
209 (defvar facemenu-justification-menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
210 (let ((map (make-sparse-keymap "Justification"))) |
27494 | 211 (define-key map [?c] (cons (purecopy "Center") 'set-justification-center)) |
212 (define-key map [?b] (cons (purecopy "Full") 'set-justification-full)) | |
213 (define-key map [?r] (cons (purecopy "Right") 'set-justification-right)) | |
214 (define-key map [?l] (cons (purecopy "Left") 'set-justification-left)) | |
215 (define-key map [?u] (cons (purecopy "Unfilled") 'set-justification-none)) | |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
216 map) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
217 "Submenu for text justification commands.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
218 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
219 (defalias 'facemenu-justification-menu facemenu-justification-menu) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
220 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
221 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
222 (defvar facemenu-indentation-menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
223 (let ((map (make-sparse-keymap "Indentation"))) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
224 (define-key map [decrease-right-margin] |
27494 | 225 (cons (purecopy "Indent Right Less") 'decrease-right-margin)) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
226 (define-key map [increase-right-margin] |
27494 | 227 (cons (purecopy "Indent Right More") 'increase-right-margin)) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
228 (define-key map [decrease-left-margin] |
27494 | 229 (cons (purecopy "Indent Less") 'decrease-left-margin)) |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
230 (define-key map [increase-left-margin] |
27494 | 231 (cons (purecopy "Indent More") 'increase-left-margin)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
232 map) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
233 "Submenu for indentation commands.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
234 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
235 (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
|
236 |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
237 ;; 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
|
238 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
239 (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
|
240 "Facemenu top-level menu keymap.") |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
241 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
242 (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
|
243 ;;;###autoload |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
244 (let ((map facemenu-menu)) |
27494 | 245 (define-key map [dc] (cons (purecopy "Display Colors") 'list-colors-display)) |
246 (define-key map [df] (cons (purecopy "Display Faces") 'list-faces-display)) | |
43295
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
247 (define-key map [dp] (cons (purecopy "Describe Text") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
248 'describe-text-at)) |
27494 | 249 (define-key map [ra] (cons (purecopy "Remove Text Properties") |
250 'facemenu-remove-all)) | |
251 (define-key map [rm] (cons (purecopy "Remove Face Properties") | |
252 'facemenu-remove-face-props)) | |
253 (define-key map [s1] (list (purecopy "--")))) | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
254 ;;;###autoload |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
255 (let ((map facemenu-menu)) |
27494 | 256 (define-key map [in] (cons (purecopy "Indentation") |
257 'facemenu-indentation-menu)) | |
258 (define-key map [ju] (cons (purecopy "Justification") | |
259 'facemenu-justification-menu)) | |
260 (define-key map [s2] (list (purecopy "--"))) | |
261 (define-key map [sp] (cons (purecopy "Special Properties") | |
262 'facemenu-special-menu)) | |
263 (define-key map [bg] (cons (purecopy "Background Color") | |
264 'facemenu-background-menu)) | |
265 (define-key map [fg] (cons (purecopy "Foreground Color") | |
266 'facemenu-foreground-menu)) | |
267 (define-key map [fc] (cons (purecopy "Face") | |
268 'facemenu-face-menu))) | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
269 ;;;###autoload |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
270 (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
|
271 |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
272 (defvar facemenu-keymap |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
273 (let ((map (make-sparse-keymap "Set face"))) |
27494 | 274 (define-key map "o" (cons (purecopy "Other...") 'facemenu-set-face)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
275 map) |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
276 "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
|
277 `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
|
278 requested in `facemenu-keybindings'.") |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
279 (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
|
280 |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
281 |
19009 | 282 (defcustom facemenu-add-face-function nil |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
283 "Function called at beginning of text to change or nil. |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
284 This function is passed the FACE to set and END of text to change, and must |
19009 | 285 return a string which is inserted. It may set `facemenu-end-add-face'." |
286 :type '(choice (const :tag "None" nil) | |
287 function) | |
288 :group 'facemenu) | |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
289 |
19009 | 290 (defcustom facemenu-end-add-face nil |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
291 "String to insert or function called at end of text to change or nil. |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
292 This function is passed the FACE to set, and must return a string which is |
19009 | 293 inserted." |
294 :type '(choice (const :tag "None" nil) | |
295 string | |
296 function) | |
297 :group 'facemenu) | |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
298 |
19009 | 299 (defcustom facemenu-remove-face-function nil |
17505
c2640d101ca9
(facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents:
17073
diff
changeset
|
300 "When non-nil, this is a function called to remove faces. |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
301 This function is passed the START and END of text to change. |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
302 May also be t meaning to use `facemenu-add-face-function'." |
19009 | 303 :type '(choice (const :tag "None" nil) |
304 (const :tag "Use add-face" t) | |
305 function) | |
306 :group 'facemenu) | |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
307 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
308 ;;; Internal Variables |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
309 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
310 (defvar facemenu-color-alist nil |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
311 ;; 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
|
312 "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
|
313 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
|
314 |
8743 | 315 (defun facemenu-update () |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
316 "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
|
317 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
|
318 variables." |
8743 | 319 (interactive) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
320 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
321 ;; 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
|
322 (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
|
323 (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
|
324 |
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
325 ;;;###autoload |
8743 | 326 (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
|
327 "Add FACE to the region or next character typed. |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
328 This adds FACE to the top of the face list; any faces lower on the list that |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
329 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
|
330 |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
331 Interactively, reads the face name with the minibuffer. |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
332 |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
333 If the region is active (normally true except in Transient Mark mode) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
334 and there is no prefix argument, this command sets the region to the |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
335 requested face. |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
336 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
337 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
|
338 inserted. Moving point or switching buffers before |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
339 typing a character to insert cancels the specification." |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
340 (interactive (list (progn |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
341 (barf-if-buffer-read-only) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
342 (read-face-name "Use face")) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
343 (if (and mark-active (not current-prefix-arg)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
344 (region-beginning)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
345 (if (and mark-active (not current-prefix-arg)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
346 (region-end)))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
347 (facemenu-add-new-face face) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
348 (facemenu-add-face face start end)) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
349 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
350 ;;;###autoload |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
351 (defun facemenu-set-foreground (color &optional start end) |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
352 "Set the foreground COLOR of the region or next character typed. |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
353 The color is prompted for. A face named `fg:color' is used \(or created). |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
354 |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
355 If the region is active (normally true except in Transient Mark mode) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
356 and there is no prefix argument, this command sets the region to the |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
357 requested face. |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
358 |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
359 Otherwise, this command specifies the face for the next character |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
360 inserted. Moving point or switching buffers before |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
361 typing a character to insert cancels the specification." |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
362 (interactive (list (progn |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
363 (barf-if-buffer-read-only) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
364 (facemenu-read-color "Foreground color: ")) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
365 (if (and mark-active (not current-prefix-arg)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
366 (region-beginning)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
367 (if (and mark-active (not current-prefix-arg)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
368 (region-end)))) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
369 (unless (color-defined-p color) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
370 (message "Color `%s' undefined" color)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
371 (facemenu-add-new-face color 'facemenu-foreground-menu) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
372 (facemenu-add-face (list (list :foreground color)) start end)) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
373 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
374 ;;;###autoload |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
375 (defun facemenu-set-background (color &optional start end) |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
376 "Set the background COLOR of the region or next character typed. |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
377 Reads the color in the minibuffer. |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
378 |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
379 If the region is active (normally true except in Transient Mark mode) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
380 and there is no prefix argument, this command sets the region to the |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
381 requested face. |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
382 |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
383 Otherwise, this command specifies the face for the next character |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
384 inserted. Moving point or switching buffers before |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
385 typing a character to insert cancels the specification." |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
386 (interactive (list (progn |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
387 (barf-if-buffer-read-only) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
388 (facemenu-read-color "Background color: ")) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
389 (if (and mark-active (not current-prefix-arg)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
390 (region-beginning)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
391 (if (and mark-active (not current-prefix-arg)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
392 (region-end)))) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
393 (unless (color-defined-p color) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
394 (message "Color `%s' undefined" color)) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
395 (facemenu-add-new-face color 'facemenu-background-menu) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
396 (facemenu-add-face (list (list :background color)) start end)) |
8743 | 397 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
398 ;;;###autoload |
8743 | 399 (defun facemenu-set-face-from-menu (face start end) |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
400 "Set the FACE of the region or next character typed. |
8743 | 401 This function is designed to be called from a menu; the face to use |
402 is the menu item's name. | |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
403 |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
404 If the region is active (normally true except in Transient Mark mode) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
405 and there is no prefix argument, this command sets the region to the |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
406 requested face. |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
407 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
408 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
|
409 inserted. Moving point or switching buffers before |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
410 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
|
411 (interactive (list last-command-event |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
412 (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
|
413 (region-beginning)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
414 (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
|
415 (region-end)))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
416 (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
|
417 (facemenu-get-face face) |
8743 | 418 (if start |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
419 (facemenu-add-face face start end) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
420 (facemenu-add-face face))) |
8743 | 421 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
422 ;;;###autoload |
8743 | 423 (defun facemenu-set-invisible (start end) |
424 "Make the region invisible. | |
425 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
|
426 `facemenu-remove-special'." |
8743 | 427 (interactive "r") |
17073
5e66b1087c94
Change put-text-property with constant args to add-text-properties for efficiency. Suggested by Stavros Macrakis <s.macrakis@opengroup.org>
Boris Goldowsky <boris@gnu.org>
parents:
16590
diff
changeset
|
428 (add-text-properties start end '(invisible t))) |
8743 | 429 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
430 ;;;###autoload |
8743 | 431 (defun facemenu-set-intangible (start end) |
432 "Make the region intangible: disallow moving into it. | |
433 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
|
434 `facemenu-remove-special'." |
8743 | 435 (interactive "r") |
17073
5e66b1087c94
Change put-text-property with constant args to add-text-properties for efficiency. Suggested by Stavros Macrakis <s.macrakis@opengroup.org>
Boris Goldowsky <boris@gnu.org>
parents:
16590
diff
changeset
|
436 (add-text-properties start end '(intangible t))) |
8743 | 437 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
438 ;;;###autoload |
8743 | 439 (defun facemenu-set-read-only (start end) |
440 "Make the region unmodifiable. | |
441 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
|
442 `facemenu-remove-special'." |
8743 | 443 (interactive "r") |
17073
5e66b1087c94
Change put-text-property with constant args to add-text-properties for efficiency. Suggested by Stavros Macrakis <s.macrakis@opengroup.org>
Boris Goldowsky <boris@gnu.org>
parents:
16590
diff
changeset
|
444 (add-text-properties start end '(read-only t))) |
8743 | 445 |
11091
c968d4c026b7
Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents:
11081
diff
changeset
|
446 ;;;###autoload |
20443
76ea51acad22
(facemenu-remove-face-props): Renamed from
Karl Heuer <kwzh@gnu.org>
parents:
19686
diff
changeset
|
447 (defun facemenu-remove-face-props (start end) |
76ea51acad22
(facemenu-remove-face-props): Renamed from
Karl Heuer <kwzh@gnu.org>
parents:
19686
diff
changeset
|
448 "Remove `face' and `mouse-face' text properties." |
8743 | 449 (interactive "*r") ; error if buffer is read-only despite the next line. |
450 (let ((inhibit-read-only t)) | |
451 (remove-text-properties | |
20443
76ea51acad22
(facemenu-remove-face-props): Renamed from
Karl Heuer <kwzh@gnu.org>
parents:
19686
diff
changeset
|
452 start end '(face nil mouse-face nil)))) |
8743 | 453 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
454 ;;;###autoload |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
455 (defun facemenu-remove-all (start end) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
456 "Remove all text properties from the region." |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
457 (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
|
458 (let ((inhibit-read-only t)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
459 (set-text-properties start end nil))) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
460 |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
461 ;;;###autoload |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
462 (defun facemenu-remove-special (start end) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
463 "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
|
464 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
|
465 (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
|
466 (let ((inhibit-read-only t)) |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
467 (remove-text-properties |
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
468 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
|
469 |
43295
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
470 ;;; Describe-Text Mode. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
471 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
472 (defun describe-text-done () |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
473 "Delete the current window or bury the current buffer." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
474 (interactive) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
475 (if (> (count-windows) 1) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
476 (delete-window) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
477 (bury-buffer))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
478 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
479 (defvar describe-text-mode-map |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
480 (let ((map (make-sparse-keymap))) |
43412
ce181770fa8e
2002-02-19 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
43295
diff
changeset
|
481 (set-keymap-parent map widget-keymap) |
43295
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
482 map) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
483 "Keymap for `describe-text-mode'.") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
484 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
485 (defcustom describe-text-mode-hook nil |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
486 "List of hook functions ran by `describe-text-mode'." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
487 :type 'hook) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
488 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
489 (defun describe-text-mode () |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
490 "Major mode for buffers created by `describe-text-at'. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
491 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
492 \\{describe-text-mode-map} |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
493 Entry to this mode calls the value of `describe-text-mode-hook' |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
494 if that value is non-nil." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
495 (kill-all-local-variables) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
496 (setq major-mode 'describe-text-mode |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
497 mode-name "Describe-Text") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
498 (use-local-map describe-text-mode-map) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
499 (widget-setup) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
500 (run-hooks 'describe-text-mode-hook)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
501 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
502 ;;; Describe-Text Utilities. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
503 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
504 (defun describe-text-widget (widget) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
505 "Insert text to describe WIDGET in the current buffer." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
506 (widget-create 'link |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
507 :notify `(lambda (&rest ignore) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
508 (widget-browse ',widget)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
509 (format "%S" (if (symbolp widget) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
510 widget |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
511 (car widget)))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
512 (widget-insert " ") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
513 (widget-create 'info-link :tag "widget" "(widget)Top")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
514 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
515 (defun describe-text-sexp (sexp) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
516 "Insert a short description of SEXP in the current buffer." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
517 (let ((pp (condition-case signal |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
518 (pp-to-string sexp) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
519 (error (prin1-to-string signal))))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
520 (when (string-match "\n\\'" pp) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
521 (setq pp (substring pp 0 (1- (length pp))))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
522 (if (cond ((string-match "\n" pp) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
523 nil) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
524 ((> (length pp) (- (window-width) (current-column))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
525 nil) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
526 (t t)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
527 (widget-insert pp) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
528 (widget-create 'push-button |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
529 :tag "show" |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
530 :action (lambda (widget &optional event) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
531 (with-output-to-temp-buffer |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
532 "*Pp Eval Output*" |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
533 (princ (widget-get widget :value)))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
534 pp)))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
535 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
536 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
537 (defun describe-text-properties (properties) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
538 "Insert a description of PROPERTIES in the current buffer. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
539 PROPERTIES should be a list of overlay or text properties. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
540 The `category' property is made into a widget button that call |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
541 `describe-text-category' when pushed." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
542 (while properties |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
543 (widget-insert (format " %-20s " (car properties))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
544 (let ((key (nth 0 properties)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
545 (value (nth 1 properties))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
546 (cond ((eq key 'category) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
547 (widget-create 'link |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
548 :notify `(lambda (&rest ignore) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
549 (describe-text-category ',value)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
550 (format "%S" value))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
551 ((widgetp value) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
552 (describe-text-widget value)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
553 (t |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
554 (describe-text-sexp value)))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
555 (widget-insert "\n") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
556 (setq properties (cdr (cdr properties))))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
557 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
558 ;;; Describe-Text Commands. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
559 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
560 (defun describe-text-category (category) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
561 "Describe a text property category." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
562 (interactive "S") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
563 (when (get-buffer "*Text Category*") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
564 (kill-buffer "*Text Category*")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
565 (save-excursion |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
566 (with-output-to-temp-buffer "*Text Category*" |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
567 (set-buffer "*Text Category*") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
568 (widget-insert "Category " (format "%S" category) ":\n\n") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
569 (describe-text-properties (symbol-plist category)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
570 (describe-text-mode) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
571 (goto-char (point-min))))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
572 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
573 ;;;###autoload |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
574 (defun describe-text-at (pos) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
575 "Describe widgets, buttons, overlays and text properties at POS." |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
576 (interactive "d") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
577 (when (eq (current-buffer) (get-buffer "*Text Description*")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
578 (error "Can't do self inspection")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
579 (let* ((properties (text-properties-at pos)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
580 (overlays (overlays-at pos)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
581 overlay |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
582 (wid-field (get-char-property pos 'field)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
583 (wid-button (get-char-property pos 'button)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
584 (wid-doc (get-char-property pos 'widget-doc)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
585 ;; If button.el is not loaded, we have no buttons in the text. |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
586 (button (and (fboundp 'button-at) (button-at pos))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
587 (button-type (and button (button-type button))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
588 (button-label (and button (button-label button))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
589 (widget (or wid-field wid-button wid-doc))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
590 (if (not (or properties overlays)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
591 (message "This is plain text.") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
592 (when (get-buffer "*Text Description*") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
593 (kill-buffer "*Text Description*")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
594 (save-excursion |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
595 (with-output-to-temp-buffer "*Text Description*" |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
596 (set-buffer "*Text Description*") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
597 (widget-insert "Text content at position " (format "%d" pos) ":\n\n") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
598 ;; Widgets |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
599 (when (widgetp widget) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
600 (widget-insert (cond (wid-field "This is an editable text area") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
601 (wid-button "This is an active area") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
602 (wid-doc "This is documentation text"))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
603 (widget-insert " of a ") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
604 (describe-text-widget widget) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
605 (widget-insert ".\n\n")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
606 ;; Buttons |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
607 (when (and button (not (widgetp wid-button))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
608 (widget-insert "Here is a " (format "%S" button-type) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
609 " button labeled `" button-label "'.\n\n")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
610 ;; Overlays |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
611 (when overlays |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
612 (if (eq (length overlays) 1) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
613 (widget-insert "There is an overlay here:\n") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
614 (widget-insert "There are " (format "%d" (length overlays)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
615 " overlays here:\n")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
616 (dolist (overlay overlays) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
617 (widget-insert " From " (format "%d" (overlay-start overlay)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
618 " to " (format "%d" (overlay-end overlay)) "\n") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
619 (describe-text-properties (overlay-properties overlay))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
620 (widget-insert "\n")) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
621 ;; Text properties |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
622 (when properties |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
623 (widget-insert "There are text properties here:\n") |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
624 (describe-text-properties properties)) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
625 (describe-text-mode) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
626 (goto-char (point-min))))))) |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
627 |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
628 ;;; List Text Properties |
ce2590f06ba0
2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
42948
diff
changeset
|
629 |
12014
e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents:
11830
diff
changeset
|
630 ;;;###autoload |
11081
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
631 (defun list-text-properties-at (p) |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
632 "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
|
633 (interactive "d") |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
634 (let ((props (text-properties-at p)) |
14901
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
635 category |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
636 str) |
11081
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
637 (if (null props) |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
638 (message "None") |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
639 (if (and (not (cdr (cdr props))) |
14901
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
640 (not (eq (car props) 'category)) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
641 (< (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
|
642 p (car props) (car (cdr props))))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
643 (frame-width))) |
14312
6dfd1f4fa87c
(list-text-properties-at): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
644 (message "%s" str) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
645 (with-output-to-temp-buffer "*Text Properties*" |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
646 (princ (format "Text properties at %d:\n\n" p)) |
27929
c3e8689514c1
(list-text-properties-at): Set help-xref-stack to
Dave Love <fx@gnu.org>
parents:
27715
diff
changeset
|
647 (setq help-xref-stack nil) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
648 (while props |
14901
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
649 (if (eq (car props) 'category) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
650 (setq category (car (cdr props)))) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
651 (princ (format "%-20s %S\n" |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
652 (car props) (car (cdr props)))) |
14901
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
653 (setq props (cdr (cdr props)))) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
654 (if category |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
655 (progn |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
656 (setq props (symbol-plist category)) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
657 (princ (format "\nCategory %s:\n\n" category)) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
658 (while props |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
659 (princ (format "%-20s %S\n" |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
660 (car props) (car (cdr props)))) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
661 (if (eq (car props) 'category) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
662 (setq category (car (cdr props)))) |
64c1d20f4b5f
(list-text-properties-at): Display category's properties.
Richard M. Stallman <rms@gnu.org>
parents:
14312
diff
changeset
|
663 (setq props (cdr (cdr props))))))))))) |
11081
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
664 |
b651fb9a8216
(list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents:
10814
diff
changeset
|
665 ;;;###autoload |
11372
874b91f4adc4
(facemenu-read-color): Don't ignore PROMPT arg. Make arg optional.
Boris Goldowsky <boris@gnu.org>
parents:
11234
diff
changeset
|
666 (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
|
667 "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
|
668 (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
|
669 (or facemenu-color-alist |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
25278
diff
changeset
|
670 (mapcar 'list (defined-colors))) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
671 nil t))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
672 (if (equal "" col) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
673 nil |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
674 col))) |
8743 | 675 |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
676 ;;;###autoload |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
677 (defun list-colors-display (&optional list) |
11465
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
678 "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
|
679 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
|
680 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
|
681 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
|
682 (interactive) |
42948
74d5b26ad460
(list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents:
42488
diff
changeset
|
683 (when (and (null list) (> (display-color-cells) 0)) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
25278
diff
changeset
|
684 (setq list (defined-colors)) |
25138
b005bf702615
(list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents:
20443
diff
changeset
|
685 ;; Delete duplicate colors. |
b005bf702615
(list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents:
20443
diff
changeset
|
686 (let ((l list)) |
b005bf702615
(list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents:
20443
diff
changeset
|
687 (while (cdr l) |
b005bf702615
(list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents:
20443
diff
changeset
|
688 (if (facemenu-color-equal (car l) (car (cdr l))) |
b005bf702615
(list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents:
20443
diff
changeset
|
689 (setcdr l (cdr (cdr l))) |
42948
74d5b26ad460
(list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents:
42488
diff
changeset
|
690 (setq l (cdr l))))) |
74d5b26ad460
(list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents:
42488
diff
changeset
|
691 ;; Don't show more than what the display can handle. |
74d5b26ad460
(list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents:
42488
diff
changeset
|
692 (let ((lc (nthcdr (1- (display-color-cells)) list))) |
74d5b26ad460
(list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents:
42488
diff
changeset
|
693 (if lc |
74d5b26ad460
(list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents:
42488
diff
changeset
|
694 (setcdr lc nil)))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
695 (with-output-to-temp-buffer "*Colors*" |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
696 (save-excursion |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
697 (set-buffer standard-output) |
19558
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
698 (let (s) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
699 (while list |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
700 (setq s (point)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
701 (insert (car list)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
702 (indent-to 20) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
703 (put-text-property s (point) 'face |
19558
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
704 (cons 'background-color (car list))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
705 (setq s (point)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
706 (insert " " (car list) "\n") |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
707 (put-text-property s (point) 'face |
19558
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
708 (cons 'foreground-color (car list))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
709 (setq list (cdr list))))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
710 |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
711 (defun facemenu-color-equal (a b) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
712 "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
|
713 A and B should be strings naming colors. |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
25278
diff
changeset
|
714 This function queries the display system to find out what the color |
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
25278
diff
changeset
|
715 names mean. It returns nil if the colors differ or if it can't |
11465
9fa2f8b87890
(list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents:
11372
diff
changeset
|
716 determine the correct answer." |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
717 (cond ((equal a b) t) |
26736
a0674327c167
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
25278
diff
changeset
|
718 ((equal (color-values a) (color-values b))))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
719 |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
720 (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
|
721 "Add FACE to text between START and END. |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
722 If START is nil or START to END is empty, add FACE to next typed character |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
723 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
|
724 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
|
725 that will be removed from the list. |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
726 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
|
727 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
|
728 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
729 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
|
730 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
|
731 effect. See `facemenu-remove-face-function'." |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
732 (interactive "*xFace: \nr") |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
733 (if (and (eq face 'default) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
734 (not (eq facemenu-remove-face-function t))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
735 (if facemenu-remove-face-function |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
736 (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
|
737 (if (and start (< start end)) |
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
738 (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
|
739 (setq self-insert-face 'default |
e16dc69d909a
(facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents:
13923
diff
changeset
|
740 self-insert-face-command this-command))) |
13923
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
741 (if facemenu-add-face-function |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
742 (save-excursion |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
743 (if end (goto-char end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
744 (save-excursion |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
745 (if start (goto-char start)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
746 (insert-before-markers |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
747 (funcall facemenu-add-face-function face end))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
748 (if facemenu-end-add-face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
749 (insert (if (stringp facemenu-end-add-face) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
750 facemenu-end-add-face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
751 (funcall facemenu-end-add-face face))))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
752 (if (and start (< start end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
753 (let ((part-start start) part-end) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
754 (while (not (= part-start end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
755 (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
|
756 nil end)) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
757 (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
|
758 (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
|
759 (if (null prev) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
760 face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
761 (facemenu-active-faces |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
762 (cons face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
763 (if (listp prev) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
764 prev |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
765 (list prev))))))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
766 (setq part-start part-end))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
767 (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
|
768 (cons face (if (listp self-insert-face) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
769 self-insert-face |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
770 (list self-insert-face))) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
771 face) |
35e379a3952e
(facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents:
13495
diff
changeset
|
772 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
|
773 |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
774 (defun facemenu-active-faces (face-list &optional frame) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
775 "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
|
776 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
|
777 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
|
778 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
|
779 use the selected frame. If t, then the global, non-frame faces are used." |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
780 (let* ((mask-atts (copy-sequence |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
781 (if (consp (car face-list)) |
42488
cbf9d3debb0a
(facemenu-active-faces):
Richard M. Stallman <rms@gnu.org>
parents:
41799
diff
changeset
|
782 (face-attributes-as-vector (car face-list)) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
783 (or (internal-lisp-face-p (car face-list) frame) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
784 (check-face (car face-list)))))) |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
785 (active-list (list (car face-list))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
786 (face-list (cdr face-list)) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
787 (mask-len (length mask-atts))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
788 (while face-list |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
789 (if (let ((face-atts |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
790 (if (consp (car face-list)) |
42488
cbf9d3debb0a
(facemenu-active-faces):
Richard M. Stallman <rms@gnu.org>
parents:
41799
diff
changeset
|
791 (face-attributes-as-vector (car face-list)) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
792 (or (internal-lisp-face-p (car face-list) frame) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
793 (check-face (car face-list))))) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
794 (i mask-len) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
795 (useful nil)) |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
796 (while (> (setq i (1- i)) 1) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
797 (and (not (memq (aref face-atts i) '(nil unspecified))) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
798 (memq (aref mask-atts i) '(nil unspecified)) |
13495
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
799 (aset mask-atts i (setq useful t)))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
800 useful) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
801 (setq active-list (cons (car face-list) active-list))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
802 (setq face-list (cdr face-list))) |
fcfb5f397b49
(facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents:
13433
diff
changeset
|
803 (nreverse active-list))) |
9494
9a4ed505445e
(facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents:
8953
diff
changeset
|
804 |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
805 (defun facemenu-get-face (symbol) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
806 "Make sure FACE exists. |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
807 If not, create it and add it to the appropriate menu. Return the SYMBOL." |
19686
a6ea17425718
(facemenu-get-face): Just warn when given an
Richard M. Stallman <rms@gnu.org>
parents:
19558
diff
changeset
|
808 (let ((name (symbol-name symbol)) |
a6ea17425718
(facemenu-get-face): Just warn when given an
Richard M. Stallman <rms@gnu.org>
parents:
19558
diff
changeset
|
809 foreground) |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
810 (cond ((facep symbol)) |
19686
a6ea17425718
(facemenu-get-face): Just warn when given an
Richard M. Stallman <rms@gnu.org>
parents:
19558
diff
changeset
|
811 (t (make-face symbol)))) |
a6ea17425718
(facemenu-get-face): Just warn when given an
Richard M. Stallman <rms@gnu.org>
parents:
19558
diff
changeset
|
812 symbol) |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
813 |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
814 (defun facemenu-add-new-face (face-or-color &optional menu) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
815 "Add FACE-OR-COLOR (a face or a color) to the appropriate Face menu. |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
816 If MENU is nil, then FACE-OR-COLOR is a face to be added |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
817 to `facemenu-face-menu'. If MENU is `facemenu-foreground-menu' |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
818 or `facemenu-background-menu', FACE-OR-COLOR is a color |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
819 to be added to the specified menu. |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
820 |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
821 This is called whenever you create a new face." |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
822 (let* (name |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
823 symbol |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
824 docstring |
40280
e14f2ec78074
(facemenu-add-new-face): Fix variable names.
Miles Bader <miles@gnu.org>
parents:
40275
diff
changeset
|
825 (key (cdr (assoc face-or-color facemenu-keybindings))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
826 function menu-val) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
827 (if (symbolp face-or-color) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
828 (setq name (symbol-name face-or-color) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
829 symbol face-or-color) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
830 (setq name face-or-color |
40280
e14f2ec78074
(facemenu-add-new-face): Fix variable names.
Miles Bader <miles@gnu.org>
parents:
40275
diff
changeset
|
831 symbol (intern name))) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
832 (cond ((eq menu 'facemenu-foreground-menu) |
17555
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
833 (setq docstring |
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
834 (format "Select foreground color %s for subsequent insertion." |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
835 name))) |
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
836 ((eq menu 'facemenu-background-menu) |
17555
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
837 (setq docstring |
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
838 (format "Select background color %s for subsequent insertion." |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
839 name))) |
17555
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
840 (t |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
841 (setq menu 'facemenu-face-menu) |
17555
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
842 (setq docstring |
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
843 (format "Select face `%s' for subsequent insertion." |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
844 name)))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
845 (cond ((eq t facemenu-unlisted-faces)) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
846 ((memq symbol facemenu-unlisted-faces)) |
19558
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
847 ;; test against regexps in facemenu-unlisted-faces |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
848 ((let ((unlisted facemenu-unlisted-faces) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
849 (matched nil)) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
850 (while (and unlisted (not matched)) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
851 (if (and (stringp (car unlisted)) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
852 (string-match (car unlisted) name)) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
853 (setq matched t) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
854 (setq unlisted (cdr unlisted)))) |
56079fac4d24
(facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents:
19009
diff
changeset
|
855 matched)) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
856 (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
|
857 (setq function (intern (concat "facemenu-set-" name))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
858 (fset function |
17555
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
859 `(lambda () |
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
860 ,docstring |
6e2928cff18e
(facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents:
17505
diff
changeset
|
861 (interactive) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
862 (facemenu-set-face (quote ,symbol)))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
863 (define-key 'facemenu-keymap key (cons name function)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
864 (define-key menu key (cons name function))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
865 ((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
|
866 (lambda (m) (and (listp m) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
867 (symbolp (car m)) |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
868 (face-equal (car m) symbol))) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
869 (cdr (symbol-function menu)))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
870 (t ; No keyboard equivalent. Figure out where to put it: |
40275
113233ecd44a
(facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents:
35633
diff
changeset
|
871 (setq key (vector symbol) |
10520
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
872 function 'facemenu-set-face-from-menu |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
873 menu-val (symbol-function menu)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
874 (if (and facemenu-new-faces-at-end |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
875 (> (length menu-val) 3)) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
876 (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
|
877 (car (nth (- (length menu-val) 3) menu-val))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
878 (define-key menu key (cons name function)))))) |
3d30caa4b459
(facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents:
10238
diff
changeset
|
879 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
|
880 |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
881 (defun facemenu-complete-face-list (&optional oldlist) |
15358
91b8056dcd35
(facemenu-complete-face-list): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
14901
diff
changeset
|
882 "Return list of all faces that look different. |
9623
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
883 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
|
884 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
|
885 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
|
886 order." |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
887 (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
|
888 (facemenu-iterate |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
889 (lambda (new-face) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
890 (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
|
891 (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
|
892 nil) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
893 (nreverse (face-list))) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
894 list)) |
fe1c170fa35a
(facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents:
9494
diff
changeset
|
895 |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
896 (defun facemenu-iterate (func list) |
8743 | 897 "Apply FUNC to each element of LIST until one returns non-nil. |
898 Returns the non-nil value it found, or nil if all were nil." | |
30092
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
899 (while (and list (not (funcall func (car list)))) |
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
900 (setq list (cdr list))) |
6d383cf4bb99
Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29050
diff
changeset
|
901 (car list)) |
8743 | 902 |
903 (facemenu-update) | |
904 | |
905 ;;; facemenu.el ends here |