annotate lisp/packages/edit-faces.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (if current-menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (set (make-local-variable 'current-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (copy-sequence current-menubar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (add-submenu nil edit-faces-menu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (let ((map edit-faces-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (define-key map "<" 'ef-smaller)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (define-key map ">" 'ef-larger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (define-key map "c" 'ef-copy-other-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (define-key map "C" 'ef-copy-this-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (define-key map "s" 'ef-smaller)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (define-key map "l" 'ef-larger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key map "b" 'ef-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (define-key map "i" 'ef-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (define-key map "e" 'ef-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (define-key map "f" 'ef-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (define-key map "u" 'ef-underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (define-key map "t" 'ef-truefont)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (define-key map "F" 'ef-foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (define-key map "B" 'ef-background)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (define-key map "D" 'ef-doc-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (define-key map "d" 'ef-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (define-key map "n" 'ef-next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (define-key map "p" 'ef-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (define-key map " " 'ef-next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (define-key map "\C-?" 'ef-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (define-key map "g" 'edit-faces) ; refresh display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (define-key map "q" 'ef-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (define-key map "\C-c\C-c" 'bury-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun edit-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Alter face characteristics by editing a list of defined faces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 Pops up a buffer containing a list of defined faces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 Editing commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 \\{edit-faces-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (pop-to-buffer (get-buffer-create "*Edit Faces*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (reset-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; face-list returns faces in a random order so we sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; alphabetically by the name in order to insert some logic into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; the ordering.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (let ((flist (sort (face-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (string-lessp (symbol-name x) (symbol-name y))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (ef-update-face-description t) ; insert header line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (while (setq face (car flist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (ef-update-face-description face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (setq flist (cdr flist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (edit-faces-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun ef-foreground-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (ef-foreground (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun ef-background-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (ef-background (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defun ef-font-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (ef-font (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defun ef-doc-string-callback (event extent user-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (ef-doc-string (ef-face-arg (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (extent-object extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defun ef-update-face-description (face &optional replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "Given a face, inserts a description of that face into the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Inserts a descriptive header if passed `t'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (let ((face-name-fmt "%-25s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (foreground-fmt "%-15s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (background-fmt "%-15s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (font-fmt "%s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 fg bg font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if (eq face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (insert-face (format (concat face-name-fmt " " foreground-fmt " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 background-fmt " " font-fmt "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "Face" "Foreground" "Background" "Font Spec")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 'underline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (or replace (setq replace face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (if (re-search-forward (concat "^" (symbol-name replace) " ") nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (delete-region (point) (progn (forward-line 2) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq fg (face-foreground-instance face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 bg (face-background-instance face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 font (face-font-instance face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (let ((st (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (fn #'(lambda (str callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (let ((st1 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (insert str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (add-list-mode-item st1 (point) nil callback)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (funcall fn (format face-name-fmt (symbol-name face)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (funcall fn (format foreground-fmt (color-instance-name fg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 'ef-foreground-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (funcall fn (format background-fmt (color-instance-name bg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 'ef-background-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (funcall fn (format font-fmt (font-instance-name font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 'ef-font-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (insert "\n (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (funcall fn (or (face-doc-string face) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 'ef-doc-string-callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (insert ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (add-nonduplicable-text-properties st (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 `(face ,face eface ,face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 start-open t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (and replace (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ))
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 (defun ef-face-arg (&optional pos buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (if (and (not pos) (not buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (and current-mouse-event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (mouse-event-p current-mouse-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (mouse-set-point current-mouse-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (or buffer (setq buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (or pos (setq pos (point buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (let ((face (or (get-char-property pos 'eface buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (and (> pos (point-min buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (get-char-property (1- pos) 'eface buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (or face (error "There is no face to edit on this line."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defun ef-delete (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 "Delete the face on the current line from the *Edit Faces* buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 The face is not altered. The buffer can be regenerated again with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 M-x edit-faces."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (and current-mouse-event (mouse-event-p current-mouse-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (mouse-set-point current-mouse-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (let ( ;; is this worth the bother? (fwd (> arg 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (count (abs arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (while (not (zerop (prog1 count (setq count (1- count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq ex (text-property-bounds (point) 'eface nil 'at))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (or ex (error "There is no face to delete on this line."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (delete-region (car ex) (cdr ex))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (delete-blank-lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defun ef-next (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Move forward ARG entries in the face table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (let ((bounds (next-text-property-bounds arg (point) 'eface)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (if bounds (goto-char (car bounds))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (goto-char (if (> arg 0) (point-max) (point-min))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defun ef-prev (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 "Move forward ARG entries in the face table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (ef-next (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defun ef-smaller (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (make-face-smaller face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (defun ef-larger (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (make-face-larger face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defun ef-face-font-indirect (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (let ((font (face-font-instance face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (or font (face-font-instance 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defun ef-face-bold-p (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (let ((font (ef-face-font-indirect face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (not (not (string-match "-bold-" (font-instance-name font))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun ef-face-italic-p (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (let ((font (ef-face-font-indirect face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (not (not (string-match "-[io]-" (font-instance-name font))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun ef-bold (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (ef-face-bold-p face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (make-face-unbold face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (make-face-bold face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun ef-italic (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (if (ef-face-italic-p face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (make-face-unitalic face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (make-face-italic face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun ef-underline (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (set-face-underline-p face (not (face-underline-p face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (defun ef-truefont (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (interactive (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (let ((font (face-font-instance face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (name (symbol-name face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (message "True font for `%s': %s" name (font-instance-truename font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (message "The face `%s' does not have its own font." name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defun ef-foreground (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (set-face-foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (read-color (format "Foreground color for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (color-instance-name (face-foreground-instance face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defun ef-background (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (set-face-background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (read-color (format "Background color for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (color-instance-name (face-background-instance face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defun ef-doc-string (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (set-face-doc-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (read-string (format "Doc string for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (face-doc-string face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (ef-update-face-description face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defun ef-copy-other-face (src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (let* ((f (ef-face-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (name (symbol-name f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (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
312 (copy-face src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (ef-update-face-description dst dst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defun ef-copy-this-face (src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (let* ((f (ef-face-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (name (symbol-name f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (list f (read-face (format "Copy `%s' onto what face?: " name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (copy-face src dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (ef-update-face-description dst dst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defun ef-font (face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (list (ef-face-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let* ((ofont (face-font-instance face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (font (read-string (format "Font for `%s': " (symbol-name face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (font-instance-name (face-font-instance face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 others)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; 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
331 ;; 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
332 ;; change should be global.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (set-face-font face (if (and (string= font "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (not (eq face 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 nil font))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (ef-update-face-description face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq others (delq nil (mapcar (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (and (equal (face-font-instance f) ofont)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (face-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if (and others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (y-or-n-p "Make the same font change for other faces? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (while others
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (setq face (car others)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 others (cdr others))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (set-face-font face font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (ef-update-face-description face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (defun ef-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (or (one-window-p t 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (kill-buffer "*Edit Faces*"))