annotate lisp/facemenu.el @ 12488:71aa23be0228

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