aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLute Kamstra2005-07-01 08:30:30 +0000
committerLute Kamstra2005-07-01 08:30:30 +0000
commitb97c98ad01e66166679c23cc5e6a9a1a018f7bd8 (patch)
tree0fd72ef601ee00bd2326d022fd9a0e1030b0a099
parent11bc6e51a0868393ca6879cd4b122e8d78d67c11 (diff)
downloademacs-b97c98ad01e66166679c23cc5e6a9a1a018f7bd8.tar.gz
emacs-b97c98ad01e66166679c23cc5e6a9a1a018f7bd8.zip
(facemenu-unlisted-faces): Delete foreground and background color
faces. (facemenu-set-foreground, facemenu-set-background): Use facemenu-set-face-from-menu. (facemenu-set-face-from-menu): Treat face names that start with "fg:" or "bg:" as special. (facemenu-add-new-color): Don't create faces. Simplify.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/facemenu.el72
2 files changed, 49 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 407f779999a..0aaf512a1bb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12005-07-01 Lute Kamstra <lute@gnu.org>
2
3 * facemenu.el (facemenu-unlisted-faces): Delete foreground and
4 background color faces.
5 (facemenu-set-foreground, facemenu-set-background): Use
6 facemenu-set-face-from-menu.
7 (facemenu-set-face-from-menu): Treat face names that start with
8 "fg:" or "bg:" as special.
9 (facemenu-add-new-color): Don't create faces. Simplify.
10
12005-06-30 Richard M. Stallman <rms@gnu.org> 112005-06-30 Richard M. Stallman <rms@gnu.org>
2 12
3 * emacs-lisp/crm.el (crm-do-completion): Handle minibuffer prompt. 13 * emacs-lisp/crm.el (crm-do-completion): Handle minibuffer prompt.
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index 43c275e4a2f..acbb4d80f6a 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -135,8 +135,7 @@ just before \"Other\" at the end."
135 `(modeline region secondary-selection highlight scratch-face 135 `(modeline region secondary-selection highlight scratch-face
136 ,(purecopy "^font-lock-") ,(purecopy "^gnus-") ,(purecopy "^message-") 136 ,(purecopy "^font-lock-") ,(purecopy "^gnus-") ,(purecopy "^message-")
137 ,(purecopy "^ediff-") ,(purecopy "^term-") ,(purecopy "^vc-") 137 ,(purecopy "^ediff-") ,(purecopy "^term-") ,(purecopy "^vc-")
138 ,(purecopy "^widget-") ,(purecopy "^custom-") ,(purecopy "^vm-") 138 ,(purecopy "^widget-") ,(purecopy "^custom-") ,(purecopy "^vm-"))
139 ,(purecopy "^fg:") ,(purecopy "^bg:"))
140 "*List of faces not to include in the Face menu. 139 "*List of faces not to include in the Face menu.
141Each element may be either a symbol, which is the name of a face, or a string, 140Each element may be either a symbol, which is the name of a face, or a string,
142which is a regular expression to be matched against face names. Matching 141which is a regular expression to be matched against face names. Matching
@@ -366,8 +365,9 @@ typing a character to insert cancels the specification."
366 (region-beginning)) 365 (region-beginning))
367 (if (and mark-active (not current-prefix-arg)) 366 (if (and mark-active (not current-prefix-arg))
368 (region-end)))) 367 (region-end))))
369 (facemenu-add-face (facemenu-add-new-color color 'facemenu-foreground-menu) 368 (facemenu-set-face-from-menu
370 start end)) 369 (facemenu-add-new-color color 'facemenu-foreground-menu)
370 start end))
371 371
372;;;###autoload 372;;;###autoload
373(defun facemenu-set-background (color &optional start end) 373(defun facemenu-set-background (color &optional start end)
@@ -388,31 +388,41 @@ typing a character to insert cancels the specification."
388 (region-beginning)) 388 (region-beginning))
389 (if (and mark-active (not current-prefix-arg)) 389 (if (and mark-active (not current-prefix-arg))
390 (region-end)))) 390 (region-end))))
391 (facemenu-add-face (facemenu-add-new-color color 'facemenu-background-menu) 391 (facemenu-set-face-from-menu
392 start end)) 392 (facemenu-add-new-color color 'facemenu-background-menu)
393 start end))
393 394
394;;;###autoload 395;;;###autoload
395(defun facemenu-set-face-from-menu (face start end) 396(defun facemenu-set-face-from-menu (face start end)
396 "Set the FACE of the region or next character typed. 397 "Set the FACE of the region or next character typed.
397This function is designed to be called from a menu; the face to use 398This function is designed to be called from a menu; FACE is determined
398is the menu item's name. 399using the event type of the menu entry. If FACE is a symbol whose
400name starts with \"fg:\" or \"bg:\", then this functions sets the
401foreground or background to the color specified by the rest of the
402symbol's name. Any other symbol is considered the name of a face.
399 403
400If the region is active (normally true except in Transient Mark mode) 404If the region is active (normally true except in Transient Mark mode)
401and there is no prefix argument, this command sets the region to the 405and there is no prefix argument, this command sets the region to the
402requested face. 406requested face.
403 407
404Otherwise, this command specifies the face for the next character 408Otherwise, this command specifies the face for the next character
405inserted. Moving point or switching buffers before 409inserted. Moving point or switching buffers before typing a character
406typing a character to insert cancels the specification." 410to insert cancels the specification."
407 (interactive (list last-command-event 411 (interactive (list last-command-event
408 (if (and mark-active (not current-prefix-arg)) 412 (if (and mark-active (not current-prefix-arg))
409 (region-beginning)) 413 (region-beginning))
410 (if (and mark-active (not current-prefix-arg)) 414 (if (and mark-active (not current-prefix-arg))
411 (region-end)))) 415 (region-end))))
412 (barf-if-buffer-read-only) 416 (barf-if-buffer-read-only)
413 (if start 417 (facemenu-add-face
414 (facemenu-add-face face start end) 418 (let ((fn (symbol-name face)))
415 (facemenu-add-face face))) 419 (if (string-match "\\`\\([fb]\\)g:\\(.+\\)" fn)
420 (list (list (if (string= (match-string 1 fn) "f")
421 :foreground
422 :background)
423 (match-string 2 fn)))
424 face))
425 start end))
416 426
417;;;###autoload 427;;;###autoload
418(defun facemenu-set-invisible (start end) 428(defun facemenu-set-invisible (start end)
@@ -708,7 +718,7 @@ This is called whenever you create a new face."
708(defun facemenu-add-new-color (color menu) 718(defun facemenu-add-new-color (color menu)
709 "Add COLOR (a color name string) to the appropriate Face menu. 719 "Add COLOR (a color name string) to the appropriate Face menu.
710MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'. 720MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'.
711Create the appropriate face and return it. 721Return the event type (a symbol) of the added menu entry.
712 722
713This is called whenever you use a new color." 723This is called whenever you use a new color."
714 (let (symbol docstring) 724 (let (symbol docstring)
@@ -718,30 +728,26 @@ This is called whenever you use a new color."
718 (setq docstring 728 (setq docstring
719 (format "Select foreground color %s for subsequent insertion." 729 (format "Select foreground color %s for subsequent insertion."
720 color) 730 color)
721 symbol (intern (concat "fg:" color))) 731 symbol (intern (concat "fg:" color))))
722 (set-face-foreground (make-face symbol) color))
723 ((eq menu 'facemenu-background-menu) 732 ((eq menu 'facemenu-background-menu)
724 (setq docstring 733 (setq docstring
725 (format "Select background color %s for subsequent insertion." 734 (format "Select background color %s for subsequent insertion."
726 color) 735 color)
727 symbol (intern (concat "bg:" color))) 736 symbol (intern (concat "bg:" color))))
728 (set-face-background (make-face symbol) color))
729 (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'"))) 737 (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'")))
730 (cond ((facemenu-iterate ; check if equivalent face is already in the menu 738 (unless (facemenu-iterate ; Check if color is already in the menu.
731 (lambda (m) (and (listp m) 739 (lambda (m) (and (listp m)
732 (symbolp (car m)) 740 (eq (car m) symbol)))
733 (stringp (cadr m)) 741 (cdr (symbol-function menu)))
734 (string-equal (cadr m) color))) 742 ;; Color is not in the menu. Figure out where to put it.
735 (cdr (symbol-function menu)))) 743 (let ((key (vector symbol))
736 (t ; No keyboard equivalent. Figure out where to put it: 744 (function 'facemenu-set-face-from-menu)
737 (let ((key (vector symbol)) 745 (menu-val (symbol-function menu)))
738 (function 'facemenu-set-face-from-menu) 746 (if (and facemenu-new-faces-at-end
739 (menu-val (symbol-function menu))) 747 (> (length menu-val) 3))
740 (if (and facemenu-new-faces-at-end 748 (define-key-after menu-val key (cons color function)
741 (> (length menu-val) 3)) 749 (car (nth (- (length menu-val) 3) menu-val)))
742 (define-key-after menu-val key (cons color function) 750 (define-key menu key (cons color function)))))
743 (car (nth (- (length menu-val) 3) menu-val)))
744 (define-key menu key (cons color function))))))
745 symbol)) 751 symbol))
746 752
747(defun facemenu-complete-face-list (&optional oldlist) 753(defun facemenu-complete-face-list (&optional oldlist)