annotate lisp/packages/edit-faces.el @ 10:49a24b4fd526 r19-15b6

Import from CVS: tag r19-15b6
author cvs
date Mon, 13 Aug 2007 08:47:52 +0200
parents ac2d302a0011
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; edit-faces.el -- interactive face editing mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; along with XEmacs; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; #### FSF has facemenu.el. Should merge with.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Original author: Stig <stig@hackvan.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Significantly fixed up: Ben Wing <wing@666.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defvar edit-faces-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 '("Edit-Faces"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ["Copy other face..." ef-copy-other-face t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ["Copy this face..." ef-copy-this-face t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ["Make smaller" ef-smaller t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ["Make larger" ef-larger t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ["Toggle bold" ef-bold t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ["Toggle italic" ef-italic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ["Toggle underline" ef-underline t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ["Query true font" ef-truefont t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ["Set font" ef-font t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ["Set foreground" ef-foreground t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ["Set background" ef-background t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ["Set doc string" ef-doc-string t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ["Quit" ef-quit t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (or (find-face 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (progn (make-face 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (set-face-underline-p 'underline t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (define-derived-mode edit-faces-mode list-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "Edit-Faces"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Major mode for `edit-faces' buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 Editing commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 \\{edit-faces-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; auto-show-mode is too confusing in this mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq auto-show-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (setq mode-popup-menu edit-faces-menu)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
60 (if (featurep 'menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61 (if current-menubar
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
62 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
63 (set (make-local-variable 'current-menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
64 (copy-sequence current-menubar))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
65 (add-submenu nil edit-faces-menu)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (let ((map edit-faces-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (define-key map "<" 'ef-smaller)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (define-key map ">" 'ef-larger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (define-key map "c" 'ef-copy-other-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (define-key map "C" 'ef-copy-this-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (define-key map "s" 'ef-smaller)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key map "l" 'ef-larger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (define-key map "b" 'ef-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (define-key map "i" 'ef-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (define-key map "e" 'ef-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-key map "f" 'ef-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (define-key map "u" 'ef-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key map "t" 'ef-truefont)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (define-key map "F" 'ef-foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (define-key map "B" 'ef-background)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (define-key map "D" 'ef-doc-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key map "d" 'ef-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (define-key map "n" 'ef-next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (define-key map "p" 'ef-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (define-key map " " 'ef-next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (define-key map "\C-?" 'ef-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (define-key map "g" 'edit-faces) ; refresh display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (define-key map "q" 'ef-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (define-key map "\C-c\C-c" 'bury-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun edit-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Alter face characteristics by editing a list of defined faces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 Pops up a buffer containing a list of defined faces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Editing commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 \\{edit-faces-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (pop-to-buffer (get-buffer-create "*Edit Faces*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (reset-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; face-list returns faces in a random order so we sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; alphabetically by the name in order to insert some logic into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; the ordering.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (let ((flist (sort (face-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (string-lessp (symbol-name x) (symbol-name y))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (ef-update-face-description t) ; insert header line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (while (setq face (car flist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (ef-update-face-description face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq flist (cdr flist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (edit-faces-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun ef-foreground-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (ef-foreground (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun ef-background-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (ef-background (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun ef-font-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (ef-font (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defun ef-doc-string-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (ef-doc-string (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defun ef-update-face-description (face &optional replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "Given a face, inserts a description of that face into the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 Inserts a descriptive header if passed `t'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (let ((face-name-fmt "%-25s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (foreground-fmt "%-15s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (background-fmt "%-15s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (font-fmt "%s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 fg bg font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if (eq face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (insert-face (format (concat face-name-fmt " " foreground-fmt " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 background-fmt " " font-fmt "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "Face" "Foreground" "Background" "Font Spec")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (or replace (setq replace face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if (re-search-forward (concat "^" (symbol-name replace) " ") nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (delete-region (point) (progn (forward-line 2) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq fg (face-foreground-instance face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 bg (face-background-instance face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 font (face-font-instance face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let ((st (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (fn #'(lambda (str callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (let ((st1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (insert str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (add-list-mode-item st1 (point) nil callback)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (funcall fn (format face-name-fmt (symbol-name face)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (funcall fn (format foreground-fmt (color-instance-name fg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 'ef-foreground-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (funcall fn (format background-fmt (color-instance-name bg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 'ef-background-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (funcall fn (format font-fmt (font-instance-name font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 'ef-font-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (insert "\n (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (funcall fn (or (face-doc-string face) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 'ef-doc-string-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (insert ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (add-nonduplicable-text-properties st (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 `(face ,face eface ,face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 start-open t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (and replace (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun ef-face-arg (&optional pos buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if (and (not pos) (not buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (and current-mouse-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (mouse-event-p current-mouse-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (mouse-set-point current-mouse-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (or pos (setq pos (point buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let ((face (or (get-char-property pos 'eface buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (and (> pos (point-min buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (get-char-property (1- pos) 'eface buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (or face (error "There is no face to edit on this line."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun ef-delete (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Delete the face on the current line from the *Edit Faces* buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 The face is not altered. The buffer can be regenerated again with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 M-x edit-faces."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (and current-mouse-event (mouse-event-p current-mouse-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (mouse-set-point current-mouse-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (let ( ;; is this worth the bother? (fwd (> arg 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (count (abs arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (while (not (zerop (prog1 count (setq count (1- count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq ex (text-property-bounds (point) 'eface nil 'at))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (or ex (error "There is no face to delete on this line."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (delete-region (car ex) (cdr ex))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (delete-blank-lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun ef-next (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Move forward ARG entries in the face table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (let ((bounds (next-text-property-bounds arg (point) 'eface)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (if bounds (goto-char (car bounds))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (goto-char (if (> arg 0) (point-max) (point-min))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun ef-prev (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "Move forward ARG entries in the face table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (ef-next (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun ef-smaller (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (make-face-smaller face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (defun ef-larger (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (make-face-larger face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun ef-face-font-indirect (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (let ((font (face-font-instance face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (or font (face-font-instance 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defun ef-face-bold-p (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (let ((font (ef-face-font-indirect face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (not (not (string-match "-bold-" (font-instance-name font))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defun ef-face-italic-p (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (let ((font (ef-face-font-indirect face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (not (not (string-match "-[io]-" (font-instance-name font))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (defun ef-bold (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (if (ef-face-bold-p face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (make-face-unbold face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (make-face-bold face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun ef-italic (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (if (ef-face-italic-p face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (make-face-unitalic face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (make-face-italic face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (defun ef-underline (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (set-face-underline-p face (not (face-underline-p face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defun ef-truefont (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let ((font (face-font-instance face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (name (symbol-name face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (message "True font for `%s': %s" name (font-instance-truename font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (message "The face `%s' does not have its own font." name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defun ef-foreground (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (set-face-foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (read-color (format "Foreground color for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (color-instance-name (face-foreground-instance face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defun ef-background (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (set-face-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (read-color (format "Background color for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (color-instance-name (face-background-instance face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun ef-doc-string (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (set-face-doc-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (read-string (format "Doc string for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (face-doc-string face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun ef-copy-other-face (src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (let* ((f (ef-face-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (name (symbol-name f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (list (read-face (format "Make `%s' a copy of what face?: " name) t) f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (copy-face src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (ef-update-face-description dst dst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun ef-copy-this-face (src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (let* ((f (ef-face-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (name (symbol-name f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (list f (read-face (format "Copy `%s' onto what face?: " name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (copy-face src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (ef-update-face-description dst dst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun ef-font (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (let* ((ofont (face-font-instance face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (font (read-string (format "Font for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (font-instance-name (face-font-instance face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 others)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; you might think that this could be moved into the loop below, but I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; think that it's important to see the new font before asking if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; change should be global.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (set-face-font face (if (and (string= font "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (not (eq face 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 nil font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (ef-update-face-description face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (setq others (delq nil (mapcar (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (and (equal (face-font-instance f) ofont)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (and others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (y-or-n-p "Make the same font change for other faces? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (while others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (setq face (car others)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 others (cdr others))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (set-face-font face font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (ef-update-face-description face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defun ef-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (or (one-window-p t 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (kill-buffer "*Edit Faces*"))