annotate lisp/facemenu.el @ 16865:0e79ed2e445b

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