annotate lisp/facemenu.el @ 48283:2c1a49c60af1

#
author André Spiegel <spiegel@gnu.org>
date Wed, 13 Nov 2002 12:40:27 +0000
parents 345d4d775bf0
children 37645a051842
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 12269
diff changeset
1 ;;; facemenu.el --- create a face menu for interactively adding fonts to text
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14154
diff changeset
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
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25141
diff changeset
5 ;; Author: Boris Goldowsky <boris@gnu.org>
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: faces
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14154
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14154
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14154
diff changeset
23 ;; Boston, MA 02111-1307, USA.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14154
diff changeset
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
43902
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
29 ;; keybindings, which are shown in the menu.
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
30 ;;
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
31 ;; 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
32 ;; commands.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;; Usage:
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
35 ;; 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
36 ;; 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
37 ;; 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
38 ;; 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
39 ;; modifications before inserting or typing anything.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;;
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; 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
42 ;; 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
43 ;; M-g i = "set italic", M-g b = "set bold", etc.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;; Customization:
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; 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
47 ;; 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
48 ;; 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
49 ;; 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
50 ;; into my .xinitrc:
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
51 ;; xmodmap -e "add Mod3 = Alt_L"
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
52 ;; Or, I can make it into a Hyper key with this:
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; 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
54 ;; 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
55 ;; Then you can define your keybindings with code like this in your .emacs:
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; (setq facemenu-keybindings
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; '((default . [?\H-d])
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; (bold . [?\H-b])
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; (italic . [?\H-i])
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
60 ;; (bold-italic . [?\H-l])
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; (underline . [?\H-u])))
17505
c2640d101ca9 (facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents: 17073
diff changeset
62 ;; (facemenu-update)
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; (setq facemenu-keymap global-map)
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
64 ;; (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
65 ;; (define-key global-map [?\H-C] 'facemenu-set-background) ; set bg color
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
67 ;; 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
68 ;; controlled by setting the variables `facemenu-keybindings' and
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
69 ;; `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
70 ;; (eg, `region') in `facemenu-unlisted-faces'.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;;; Known Problems:
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
73 ;; 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
74 ;; 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
75 ;; do the intuitive thing.
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
76 ;;
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; There is at present no way to display what the faces look like in
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; the menu itself.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; `list-faces-display' shows the faces in a different order than
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; this menu, which could be confusing. I do /not/ sort the list
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; alphabetically, because I like the default order: it puts the most
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; basic, common fonts first.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;;
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; Please send me any other problems, comments or ideas.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;;; Code:
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
43295
ce2590f06ba0 2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 42948
diff changeset
89 (eval-when-compile
ce2590f06ba0 2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 42948
diff changeset
90 (require 'help)
ce2590f06ba0 2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 42948
diff changeset
91 (require 'button))
ce2590f06ba0 2002-02-14 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 42948
diff changeset
92
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
93 ;;; Provide some binding for startup:
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
94 ;;;###autoload (define-key global-map "\M-g" 'facemenu-keymap)
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
95 ;;;###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
96
c2640d101ca9 (facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents: 17073
diff changeset
97 ;; Global bindings:
c2640d101ca9 (facemenu-update): Don't make global bindings here.
Richard M. Stallman <rms@gnu.org>
parents: 17073
diff changeset
98 (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
99 (define-key global-map "\M-g" 'facemenu-keymap)
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
101 (defgroup facemenu nil
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
102 "Create a face menu for interactively adding fonts to text"
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
103 :group 'faces
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
104 :prefix "facemenu-")
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
105
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
106 (defcustom facemenu-keybindings
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 '((default . "d")
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (bold . "b")
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (italic . "i")
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
110 (bold-italic . "l") ; {bold} intersect {italic} = {l}
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (underline . "u"))
41799
c849509c5a16 Remove unnecessary spaces.
Pavel Janík <Pavel@Janik.cz>
parents: 40280
diff changeset
112 "Alist of interesting faces and keybindings.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 Each element is itself a list: the car is the name of the face,
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 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
115 the binding is made in `facemenu-keymap'.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 The faces specifically mentioned in this list are put at the top of
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 the menu, in the order specified. All other faces which are defined,
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 except for those in `facemenu-unlisted-faces', are listed after them,
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 but get no keyboard equivalents.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 If you change this variable after loading facemenu.el, you will need to call
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
123 `facemenu-update' to make it take effect."
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
124 :type '(repeat (cons face string))
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
125 :group 'facemenu)
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
127 (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
128 "*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
129 This should be nil to put them at the top of the menu, or t to put them
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
130 just before \"Other\" at the end."
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
131 :type 'boolean
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
132 :group 'facemenu)
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
133
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
134 (defcustom facemenu-unlisted-faces
34331
7b91d8c3787f (facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents: 30092
diff changeset
135 `(modeline region secondary-selection highlight scratch-face
7b91d8c3787f (facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents: 30092
diff changeset
136 ,(purecopy "^font-lock-") ,(purecopy "^gnus-") ,(purecopy "^message-")
7b91d8c3787f (facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents: 30092
diff changeset
137 ,(purecopy "^ediff-") ,(purecopy "^term-") ,(purecopy "^vc-")
7b91d8c3787f (facemenu-unlisted-faces): Fix value.
Dave Love <fx@gnu.org>
parents: 30092
diff changeset
138 ,(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
139 "*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
140 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
141 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
142 faces will not be added to the menu.
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
143
13495
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
144 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
145 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
146 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
147 call `facemenu-update' to recalculate the menu contents.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
149 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
150 temporarily turning off the feature that automatically adds faces to the menu
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
151 when they are created."
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
152 :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
153 (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
154 (repeat (choice symbol regexp)))
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
155 :group 'facemenu)
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
156
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
157 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
158 (defvar facemenu-face-menu
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
159 (let ((map (make-sparse-keymap "Face")))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
160 (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
161 map)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
162 "Menu keymap for faces.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
163 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
164 (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
165
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
166 ;;;###autoload
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
167 (defvar facemenu-foreground-menu
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
168 (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
169 (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
170 map)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
171 "Menu keymap for foreground colors.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
172 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
173 (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
174
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
175 ;;;###autoload
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
176 (defvar facemenu-background-menu
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
177 (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
178 (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
179 map)
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
180 "Menu keymap for background colors.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
181 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
182 (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
183
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
184 ;;;###autoload
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
185 (defvar facemenu-special-menu
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
186 (let ((map (make-sparse-keymap "Special")))
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
187 (define-key map [?s] (cons (purecopy "Remove Special")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
188 'facemenu-remove-special))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
189 (define-key map [?t] (cons (purecopy "Intangible")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
190 'facemenu-set-intangible))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
191 (define-key map [?v] (cons (purecopy "Invisible")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
192 'facemenu-set-invisible))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
193 (define-key map [?r] (cons (purecopy "Read-Only")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
194 'facemenu-set-read-only))
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
195 map)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
196 "Menu keymap for non-face text-properties.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
197 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
198 (defalias 'facemenu-special-menu facemenu-special-menu)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
199
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
200 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
201 (defvar facemenu-justification-menu
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
202 (let ((map (make-sparse-keymap "Justification")))
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
203 (define-key map [?c] (cons (purecopy "Center") 'set-justification-center))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
204 (define-key map [?b] (cons (purecopy "Full") 'set-justification-full))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
205 (define-key map [?r] (cons (purecopy "Right") 'set-justification-right))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
206 (define-key map [?l] (cons (purecopy "Left") 'set-justification-left))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
207 (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
208 map)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
209 "Submenu for text justification commands.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
210 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
211 (defalias 'facemenu-justification-menu facemenu-justification-menu)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
212
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
213 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
214 (defvar facemenu-indentation-menu
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
215 (let ((map (make-sparse-keymap "Indentation")))
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
216 (define-key map [decrease-right-margin]
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
217 (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
218 (define-key map [increase-right-margin]
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
219 (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
220 (define-key map [decrease-left-margin]
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
221 (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
222 (define-key map [increase-left-margin]
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
223 (cons (purecopy "Indent More") 'increase-left-margin))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
224 map)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
225 "Submenu for indentation commands.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
226 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
227 (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
228
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
229 ;; 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
230 ;;;###autoload
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
231 (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
232 "Facemenu top-level menu keymap.")
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
233 ;;;###autoload
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
234 (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
235 ;;;###autoload
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
236 (let ((map facemenu-menu))
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
237 (define-key map [dc] (cons (purecopy "Display Colors") 'list-colors-display))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
238 (define-key map [df] (cons (purecopy "Display Faces") 'list-faces-display))
45869
fb2ae7bd271d (facemenu-map): Rename to Describe Text
Richard M. Stallman <rms@gnu.org>
parents: 45207
diff changeset
239 (define-key map [dp] (cons (purecopy "Describe Properties")
fb2ae7bd271d (facemenu-map): Rename to Describe Text
Richard M. Stallman <rms@gnu.org>
parents: 45207
diff changeset
240 'describe-text-properties))
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
241 (define-key map [ra] (cons (purecopy "Remove Text Properties")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
242 'facemenu-remove-all))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
243 (define-key map [rm] (cons (purecopy "Remove Face Properties")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
244 'facemenu-remove-face-props))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
245 (define-key map [s1] (list (purecopy "--"))))
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
246 ;;;###autoload
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
247 (let ((map facemenu-menu))
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
248 (define-key map [in] (cons (purecopy "Indentation")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
249 'facemenu-indentation-menu))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
250 (define-key map [ju] (cons (purecopy "Justification")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
251 'facemenu-justification-menu))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
252 (define-key map [s2] (list (purecopy "--")))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
253 (define-key map [sp] (cons (purecopy "Special Properties")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
254 'facemenu-special-menu))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
255 (define-key map [bg] (cons (purecopy "Background Color")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
256 'facemenu-background-menu))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
257 (define-key map [fg] (cons (purecopy "Foreground Color")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
258 'facemenu-foreground-menu))
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
259 (define-key map [fc] (cons (purecopy "Face")
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
260 'facemenu-face-menu)))
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
261 ;;;###autoload
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
262 (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
263
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
264 (defvar facemenu-keymap
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
265 (let ((map (make-sparse-keymap "Set face")))
27494
6a6704c5e3b4 Purecopy various strings.
Dave Love <fx@gnu.org>
parents: 26736
diff changeset
266 (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
267 map)
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
268 "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
269 `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
270 requested in `facemenu-keybindings'.")
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
271 (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
272
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
273
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
274 (defcustom facemenu-add-face-function nil
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
275 "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
276 This function is passed the FACE to set and END of text to change, and must
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
277 return a string which is inserted. It may set `facemenu-end-add-face'."
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
278 :type '(choice (const :tag "None" nil)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
279 function)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
280 :group 'facemenu)
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
281
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
282 (defcustom facemenu-end-add-face nil
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
283 "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
284 This function is passed the FACE to set, and must return a string which is
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
285 inserted."
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
286 :type '(choice (const :tag "None" nil)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
287 string
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
288 function)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
289 :group 'facemenu)
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
290
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
291 (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
292 "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
293 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
294 May also be t meaning to use `facemenu-add-face-function'."
19009
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
295 :type '(choice (const :tag "None" nil)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
296 (const :tag "Use add-face" t)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
297 function)
1493fc19f324 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18476
diff changeset
298 :group 'facemenu)
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
299
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
300 ;;; Internal Variables
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
301
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
302 (defvar facemenu-color-alist nil
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
303 ;; 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
304 "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
305 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
306
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (defun facemenu-update ()
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
308 "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
309 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
310 variables."
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (interactive)
9494
9a4ed505445e (facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents: 8953
diff changeset
312
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
313 ;; 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
314 (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
315 (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
316
9a4ed505445e (facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents: 8953
diff changeset
317 ;;;###autoload
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (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
319 "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
320 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
321 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
322
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
323 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
324
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
325 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
326 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
327 requested face.
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
328
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
329 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
330 inserted. Moving point or switching buffers before
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
331 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
332 (interactive (list (progn
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
333 (barf-if-buffer-read-only)
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
334 (read-face-name "Use face"))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
335 (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
336 (region-beginning))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
337 (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
338 (region-end))))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
339 (facemenu-add-new-face face)
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
340 (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
341
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
342 ;;;###autoload
9494
9a4ed505445e (facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents: 8953
diff changeset
343 (defun facemenu-set-foreground (color &optional start end)
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
344 "Set the foreground COLOR of the region or next character typed.
43902
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
345 This command reads the color in the minibuffer.
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
346
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
347 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
348 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
349 requested face.
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
350
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
351 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
352 inserted. Moving point or switching buffers before
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
353 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
354 (interactive (list (progn
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
355 (barf-if-buffer-read-only)
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
356 (facemenu-read-color "Foreground color: "))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
357 (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
358 (region-beginning))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
359 (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
360 (region-end))))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
361 (unless (color-defined-p color)
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
362 (message "Color `%s' undefined" color))
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
363 (facemenu-add-new-color color 'facemenu-foreground-menu)
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
364 (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
365
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
366 ;;;###autoload
9494
9a4ed505445e (facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents: 8953
diff changeset
367 (defun facemenu-set-background (color &optional start end)
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
368 "Set the background COLOR of the region or next character typed.
43902
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
369 This command reads the color in the minibuffer.
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
370
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
371 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
372 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
373 requested face.
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
374
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
375 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
376 inserted. Moving point or switching buffers before
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
377 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
378 (interactive (list (progn
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
379 (barf-if-buffer-read-only)
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
380 (facemenu-read-color "Background color: "))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
381 (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
382 (region-beginning))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
383 (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
384 (region-end))))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
385 (unless (color-defined-p color)
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
386 (message "Color `%s' undefined" color))
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
387 (facemenu-add-new-color color 'facemenu-background-menu)
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
388 (facemenu-add-face (list (list :background color)) start end))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
390 ;;;###autoload
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (defun facemenu-set-face-from-menu (face start end)
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
392 "Set the FACE of the region or next character typed.
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 This function is designed to be called from a menu; the face to use
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 is the menu item's name.
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
395
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
396 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
397 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
398 requested face.
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
399
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
400 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
401 inserted. Moving point or switching buffers before
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
402 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
403 (interactive (list last-command-event
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
404 (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
405 (region-beginning))
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
406 (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
407 (region-end))))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
408 (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
409 (facemenu-get-face face)
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (if start
9494
9a4ed505445e (facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents: 8953
diff changeset
411 (facemenu-add-face face start end)
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
412 (facemenu-add-face face)))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
414 ;;;###autoload
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (defun facemenu-set-invisible (start end)
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 "Make the region invisible.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 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
418 `facemenu-remove-special'."
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (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
420 (add-text-properties start end '(invisible t)))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
422 ;;;###autoload
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (defun facemenu-set-intangible (start end)
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 "Make the region intangible: disallow moving into it.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 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
426 `facemenu-remove-special'."
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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 '(intangible t)))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
430 ;;;###autoload
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (defun facemenu-set-read-only (start end)
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 "Make the region unmodifiable.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 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
434 `facemenu-remove-special'."
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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 '(read-only t)))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
11091
c968d4c026b7 Doc fix + autoload cookies.
Boris Goldowsky <boris@gnu.org>
parents: 11081
diff changeset
438 ;;;###autoload
20443
76ea51acad22 (facemenu-remove-face-props): Renamed from
Karl Heuer <kwzh@gnu.org>
parents: 19686
diff changeset
439 (defun facemenu-remove-face-props (start end)
76ea51acad22 (facemenu-remove-face-props): Renamed from
Karl Heuer <kwzh@gnu.org>
parents: 19686
diff changeset
440 "Remove `face' and `mouse-face' text properties."
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (interactive "*r") ; error if buffer is read-only despite the next line.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (let ((inhibit-read-only t))
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (remove-text-properties
20443
76ea51acad22 (facemenu-remove-face-props): Renamed from
Karl Heuer <kwzh@gnu.org>
parents: 19686
diff changeset
444 start end '(face nil mouse-face nil))))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
446 ;;;###autoload
12014
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
447 (defun facemenu-remove-all (start end)
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
448 "Remove all text properties from the region."
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
449 (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
450 (let ((inhibit-read-only t))
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
451 (set-text-properties start end nil)))
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
452
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
453 ;;;###autoload
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
454 (defun facemenu-remove-special (start end)
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
455 "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
456 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
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 (remove-text-properties
e4932082046a (facemenu-special-menu): Use characters, not symbols.
Karl Heuer <kwzh@gnu.org>
parents: 11830
diff changeset
460 start end '(invisible nil intangible nil read-only nil))))
44678
dec3101535fc (list-text-properties-at): Command deleted.
Richard M. Stallman <rms@gnu.org>
parents: 44660
diff changeset
461
11081
b651fb9a8216 (list-text-properties-at): New fn.
Boris Goldowsky <boris@gnu.org>
parents: 10814
diff changeset
462 ;;;###autoload
11372
874b91f4adc4 (facemenu-read-color): Don't ignore PROMPT arg. Make arg optional.
Boris Goldowsky <boris@gnu.org>
parents: 11234
diff changeset
463 (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
464 "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
465 (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
466 (or facemenu-color-alist
46248
345d4d775bf0 Move `provide' to the end.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45869
diff changeset
467 (defined-colors))
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
468 nil t)))
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
469 (if (equal "" col)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
470 nil
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
471 col)))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
473 ;;;###autoload
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
474 (defun list-colors-display (&optional list)
11465
9fa2f8b87890 (list-colors-display): Minor clarification.
Richard M. Stallman <rms@gnu.org>
parents: 11372
diff changeset
475 "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
476 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
477 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
478 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
479 (interactive)
42948
74d5b26ad460 (list-colors-display): If the argument is nil, don't
Eli Zaretskii <eliz@gnu.org>
parents: 42488
diff changeset
480 (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
481 (setq list (defined-colors))
25138
b005bf702615 (list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents: 20443
diff changeset
482 ;; Delete duplicate colors.
b005bf702615 (list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents: 20443
diff changeset
483 (let ((l list))
b005bf702615 (list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents: 20443
diff changeset
484 (while (cdr l)
b005bf702615 (list-colors-display): Make it work on ttys.
Dave Love <fx@gnu.org>
parents: 20443
diff changeset
485 (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
486 (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
487 (setq l (cdr l)))))
45207
a8c6bd4220a5 (list-colors-display): Don't use `display-color-cells' unless the
Miles Bader <miles@gnu.org>
parents: 45021
diff changeset
488 (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color))
a8c6bd4220a5 (list-colors-display): Don't use `display-color-cells' unless the
Miles Bader <miles@gnu.org>
parents: 45021
diff changeset
489 ;; Don't show more than what the display can handle.
a8c6bd4220a5 (list-colors-display): Don't use `display-color-cells' unless the
Miles Bader <miles@gnu.org>
parents: 45021
diff changeset
490 (let ((lc (nthcdr (1- (display-color-cells)) list)))
a8c6bd4220a5 (list-colors-display): Don't use `display-color-cells' unless the
Miles Bader <miles@gnu.org>
parents: 45021
diff changeset
491 (if lc
a8c6bd4220a5 (list-colors-display): Don't use `display-color-cells' unless the
Miles Bader <miles@gnu.org>
parents: 45021
diff changeset
492 (setcdr lc nil)))))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
493 (with-output-to-temp-buffer "*Colors*"
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
494 (save-excursion
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
495 (set-buffer standard-output)
19558
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
496 (let (s)
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
497 (while list
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
498 (setq s (point))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
499 (insert (car list))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
500 (indent-to 20)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
501 (put-text-property s (point) 'face
19558
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
502 (cons 'background-color (car list)))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
503 (setq s (point))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
504 (insert " " (car list) "\n")
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
505 (put-text-property s (point) 'face
19558
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
506 (cons 'foreground-color (car list)))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
507 (setq list (cdr list)))))))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
508
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
509 (defun facemenu-color-equal (a b)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
510 "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
511 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
512 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
513 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
514 determine the correct answer."
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
515 (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
516 ((equal (color-values a) (color-values b)))))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
517
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
518 (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
519 "Add FACE to text between START and END.
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
520 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
521 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
522 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
523 that will be removed from the list.
43902
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
524 If `facemenu-add-face-function' and maybe `facemenu-end-add-face' are non-nil,
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
525 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
526
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
527 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
528 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
529 effect. See `facemenu-remove-face-function'."
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
530 (interactive "*xFace: \nr")
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
531 (if (and (eq face 'default)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
532 (not (eq facemenu-remove-face-function t)))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
533 (if facemenu-remove-face-function
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
534 (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
535 (if (and start (< start end))
e16dc69d909a (facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents: 13923
diff changeset
536 (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
537 (setq self-insert-face 'default
e16dc69d909a (facemenu-add-face): Adding default to no region
Richard M. Stallman <rms@gnu.org>
parents: 13923
diff changeset
538 self-insert-face-command this-command)))
13923
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
539 (if facemenu-add-face-function
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
540 (save-excursion
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
541 (if end (goto-char end))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
542 (save-excursion
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
543 (if start (goto-char start))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
544 (insert-before-markers
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
545 (funcall facemenu-add-face-function face end)))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
546 (if facemenu-end-add-face
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
547 (insert (if (stringp facemenu-end-add-face)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
548 facemenu-end-add-face
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
549 (funcall facemenu-end-add-face face)))))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
550 (if (and start (< start end))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
551 (let ((part-start start) part-end)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
552 (while (not (= part-start end))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
553 (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
554 nil end))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
555 (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
556 (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
557 (if (null prev)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
558 face
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
559 (facemenu-active-faces
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
560 (cons face
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
561 (if (listp prev)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
562 prev
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
563 (list prev)))))))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
564 (setq part-start part-end)))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
565 (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
566 (cons face (if (listp self-insert-face)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
567 self-insert-face
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
568 (list self-insert-face)))
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
569 face)
35e379a3952e (facemenu-read-color, list-colors-display)
Richard M. Stallman <rms@gnu.org>
parents: 13495
diff changeset
570 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
571
13495
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
572 (defun facemenu-active-faces (face-list &optional frame)
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
573 "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
574 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
575 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
576 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
577 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
578 (let* ((mask-atts (copy-sequence
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
579 (if (consp (car face-list))
42488
cbf9d3debb0a (facemenu-active-faces):
Richard M. Stallman <rms@gnu.org>
parents: 41799
diff changeset
580 (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
581 (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
582 (check-face (car face-list))))))
13495
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
583 (active-list (list (car face-list)))
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
584 (face-list (cdr face-list))
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
585 (mask-len (length mask-atts)))
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
586 (while face-list
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
587 (if (let ((face-atts
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
588 (if (consp (car face-list))
42488
cbf9d3debb0a (facemenu-active-faces):
Richard M. Stallman <rms@gnu.org>
parents: 41799
diff changeset
589 (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
590 (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
591 (check-face (car face-list)))))
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
592 (i mask-len)
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
593 (useful nil))
13495
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
594 (while (> (setq i (1- i)) 1)
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
595 (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
596 (memq (aref mask-atts i) '(nil unspecified))
13495
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
597 (aset mask-atts i (setq useful t))))
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
598 useful)
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
599 (setq active-list (cons (car face-list) active-list)))
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
600 (setq face-list (cdr face-list)))
fcfb5f397b49 (facemenu-active-faces): Replaces function
Karl Heuer <kwzh@gnu.org>
parents: 13433
diff changeset
601 (nreverse active-list)))
9494
9a4ed505445e (facemenu-read-color, facemenu-colors): New fn, var.
Richard M. Stallman <rms@gnu.org>
parents: 8953
diff changeset
602
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
603 (defun facemenu-get-face (symbol)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
604 "Make sure FACE exists.
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
605 If not, create it and add it to the appropriate menu. Return the SYMBOL."
44128
f98a45180266 (facemenu-get-face): Remove unised variable `foreground'.
Eli Zaretskii <eliz@gnu.org>
parents: 43902
diff changeset
606 (let ((name (symbol-name symbol)))
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
607 (cond ((facep symbol))
19686
a6ea17425718 (facemenu-get-face): Just warn when given an
Richard M. Stallman <rms@gnu.org>
parents: 19558
diff changeset
608 (t (make-face symbol))))
a6ea17425718 (facemenu-get-face): Just warn when given an
Richard M. Stallman <rms@gnu.org>
parents: 19558
diff changeset
609 symbol)
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
610
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
611 (defun facemenu-add-new-face (face)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
612 "Add FACE (a face) to the Face menu.
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
613
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
614 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
615 (let* (name
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
616 symbol
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
617 menu docstring
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
618 (key (cdr (assoc face facemenu-keybindings)))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
619 function menu-val)
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
620 (if (symbolp face)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
621 (setq name (symbol-name face)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
622 symbol face)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
623 (setq name face
40280
e14f2ec78074 (facemenu-add-new-face): Fix variable names.
Miles Bader <miles@gnu.org>
parents: 40275
diff changeset
624 symbol (intern name)))
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
625 (setq menu 'facemenu-face-menu)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
626 (setq docstring
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
627 (format "Select face `%s' for subsequent insertion."
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
628 name))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
629 (cond ((eq t facemenu-unlisted-faces))
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
630 ((memq symbol facemenu-unlisted-faces))
19558
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
631 ;; test against regexps in facemenu-unlisted-faces
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
632 ((let ((unlisted facemenu-unlisted-faces)
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
633 (matched nil))
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
634 (while (and unlisted (not matched))
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
635 (if (and (stringp (car unlisted))
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
636 (string-match (car unlisted) name))
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
637 (setq matched t)
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
638 (setq unlisted (cdr unlisted))))
56079fac4d24 (facemenu-unlisted-faces): Expand variable
Richard M. Stallman <rms@gnu.org>
parents: 19009
diff changeset
639 matched))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
640 (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
641 (setq function (intern (concat "facemenu-set-" name)))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
642 (fset function
17555
6e2928cff18e (facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents: 17505
diff changeset
643 `(lambda ()
6e2928cff18e (facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents: 17505
diff changeset
644 ,docstring
6e2928cff18e (facemenu-add-new-face): Rewrite to give each
Richard M. Stallman <rms@gnu.org>
parents: 17505
diff changeset
645 (interactive)
43902
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
646 (facemenu-set-face
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
647 (quote ,symbol)
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
648 (if (and mark-active (not current-prefix-arg))
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
649 (region-beginning))
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
650 (if (and mark-active (not current-prefix-arg))
e0e6df854822 (facemenu-add-new-face):
Richard M. Stallman <rms@gnu.org>
parents: 43412
diff changeset
651 (region-end)))))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
652 (define-key 'facemenu-keymap key (cons name function))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
653 (define-key menu key (cons name function)))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
654 ((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
655 (lambda (m) (and (listp m)
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
656 (symbolp (car m))
40275
113233ecd44a (facemenu-unlisted-faces): Improve doc strings
Richard M. Stallman <rms@gnu.org>
parents: 35633
diff changeset
657 (face-equal (car m) symbol)))
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
658 (cdr (symbol-function menu))))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
659 (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
660 (setq key (vector symbol)
10520
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
661 function 'facemenu-set-face-from-menu
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
662 menu-val (symbol-function menu))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
663 (if (and facemenu-new-faces-at-end
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
664 (> (length menu-val) 3))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
665 (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
666 (car (nth (- (length menu-val) 3) menu-val)))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
667 (define-key menu key (cons name function))))))
3d30caa4b459 (facemenu-keybindings, facemenu-face-menu):
Richard M. Stallman <rms@gnu.org>
parents: 10238
diff changeset
668 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
669
44611
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
670 (defun facemenu-add-new-color (color &optional menu)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
671 "Add COLOR (a color name string) to the appropriate Face menu.
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
672 MENU should be `facemenu-foreground-menu' or
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
673 `facemenu-background-menu'.
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
674
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
675 This is called whenever you use a new color."
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
676 (let* (name
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
677 symbol
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
678 docstring
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
679 function menu-val key
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
680 (color-p (memq menu '(facemenu-foreground-menu
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
681 facemenu-background-menu))))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
682 (unless (stringp color)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
683 (error "%s is not a color" color))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
684 (setq name color
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
685 symbol (intern name))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
686
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
687 (cond ((eq menu 'facemenu-foreground-menu)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
688 (setq docstring
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
689 (format "Select foreground color %s for subsequent insertion."
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
690 name)))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
691 ((eq menu 'facemenu-background-menu)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
692 (setq docstring
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
693 (format "Select background color %s for subsequent insertion."
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
694 name))))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
695 (cond ((facemenu-iterate ; check if equivalent face is already in the menu
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
696 (lambda (m) (and (listp m)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
697 (symbolp (car m))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
698 (stringp (cadr m))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
699 (string-equal (cadr m) color)))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
700 (cdr (symbol-function menu))))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
701 (t ; No keyboard equivalent. Figure out where to put it:
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
702 (setq key (vector symbol)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
703 function 'facemenu-set-face-from-menu
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
704 menu-val (symbol-function menu))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
705 (if (and facemenu-new-faces-at-end
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
706 (> (length menu-val) 3))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
707 (define-key-after menu-val key (cons name function)
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
708 (car (nth (- (length menu-val) 3) menu-val)))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
709 (define-key menu key (cons name function))))))
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
710 nil) ; Return nil for facemenu-iterate
e4a2909015d3 (facemenu-add-new-face): Use this only for faces. Delete arg MENU.
Richard M. Stallman <rms@gnu.org>
parents: 44593
diff changeset
711
9623
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
712 (defun facemenu-complete-face-list (&optional oldlist)
15358
91b8056dcd35 (facemenu-complete-face-list): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14901
diff changeset
713 "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
714 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
715 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
716 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
717 order."
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
718 (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
719 (facemenu-iterate
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
720 (lambda (new-face)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
721 (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
722 (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
723 nil)
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
724 (nreverse (face-list)))
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
725 list))
fe1c170fa35a (facemenu-get-face): Don't add to menu here.
Boris Goldowsky <boris@gnu.org>
parents: 9494
diff changeset
726
30092
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
727 (defun facemenu-iterate (func list)
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 "Apply FUNC to each element of LIST until one returns non-nil.
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 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
730 (while (and list (not (funcall func (car list))))
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
731 (setq list (cdr list)))
6d383cf4bb99 Docstrings fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29050
diff changeset
732 (car list))
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (facemenu-update)
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735
46248
345d4d775bf0 Move `provide' to the end.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45869
diff changeset
736 (provide 'facemenu)
8743
03445a867bed Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 ;;; facemenu.el ends here