aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLute Kamstra2005-06-27 07:31:49 +0000
committerLute Kamstra2005-06-27 07:31:49 +0000
commit019b1899e5d3eee651c5e0701aa23837296b3fc7 (patch)
tree934d9927e7e650936bad0a54ce4a875a73e4de88
parent69410484f228767bdce802b93ef5b4dc73940023 (diff)
downloademacs-019b1899e5d3eee651c5e0701aa23837296b3fc7.tar.gz
emacs-019b1899e5d3eee651c5e0701aa23837296b3fc7.zip
(facemenu-unlisted-faces): Add foreground and background color faces.
(facemenu-get-face): Delete function. (facemenu-set-face-from-menu): Don't call facemenu-get-face. (facemenu-add-new-color): Make second argument mandatory. Create the approprate face and return it. Simplify. (facemenu-set-foreground, facemenu-set-background): Don't check if color is defined. Use return value of facemenu-add-new-color.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/facemenu.el75
2 files changed, 41 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 116b018abe1..152a126a5e5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12005-06-27 Lute Kamstra <lute@gnu.org>
2
3 * facemenu.el (facemenu-unlisted-faces): Add foreground and
4 background color faces.
5 (facemenu-get-face): Delete function.
6 (facemenu-set-face-from-menu): Don't call facemenu-get-face.
7 (facemenu-add-new-color): Make second argument mandatory. Create
8 the approprate face and return it. Simplify.
9 (facemenu-set-foreground, facemenu-set-background): Don't check if
10 color is defined. Use return value of facemenu-add-new-color.
11
12005-06-26 Nick Roberts <nickrob@snap.net.nz> 122005-06-26 Nick Roberts <nickrob@snap.net.nz>
2 13
3 * progmodes/gud.el (gud-filter): Add missing argument to 14 * progmodes/gud.el (gud-filter): Add missing argument to
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index 57dea40266a..18023511c20 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -1,6 +1,6 @@
1;;; facemenu.el --- create a face menu for interactively adding fonts to text 1;;; facemenu.el --- create a face menu for interactively adding fonts to text
2 2
3;; Copyright (c) 1994, 1995, 1996, 2001, 2002 Free Software Foundation, Inc. 3;; Copyright (c) 1994, 1995, 1996, 2001, 2002, 2005 Free Software Foundation, Inc.
4 4
5;; Author: Boris Goldowsky <boris@gnu.org> 5;; Author: Boris Goldowsky <boris@gnu.org>
6;; Keywords: faces 6;; Keywords: faces
@@ -135,7 +135,8 @@ 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:"))
139 "*List of faces not to include in the Face menu. 140 "*List of faces not to include in the Face menu.
140Each element may be either a symbol, which is the name of a face, or a string, 141Each element may be either a symbol, which is the name of a face, or a string,
141which is a regular expression to be matched against face names. Matching 142which is a regular expression to be matched against face names. Matching
@@ -365,10 +366,8 @@ typing a character to insert cancels the specification."
365 (region-beginning)) 366 (region-beginning))
366 (if (and mark-active (not current-prefix-arg)) 367 (if (and mark-active (not current-prefix-arg))
367 (region-end)))) 368 (region-end))))
368 (unless (color-defined-p color) 369 (facemenu-add-face (facemenu-add-new-color color 'facemenu-foreground-menu)
369 (message "Color `%s' undefined" color)) 370 start end))
370 (facemenu-add-new-color color 'facemenu-foreground-menu)
371 (facemenu-add-face (list (list :foreground color)) start end))
372 371
373;;;###autoload 372;;;###autoload
374(defun facemenu-set-background (color &optional start end) 373(defun facemenu-set-background (color &optional start end)
@@ -389,10 +388,8 @@ typing a character to insert cancels the specification."
389 (region-beginning)) 388 (region-beginning))
390 (if (and mark-active (not current-prefix-arg)) 389 (if (and mark-active (not current-prefix-arg))
391 (region-end)))) 390 (region-end))))
392 (unless (color-defined-p color) 391 (facemenu-add-face (facemenu-add-new-color color 'facemenu-background-menu)
393 (message "Color `%s' undefined" color)) 392 start end))
394 (facemenu-add-new-color color 'facemenu-background-menu)
395 (facemenu-add-face (list (list :background color)) start end))
396 393
397;;;###autoload 394;;;###autoload
398(defun facemenu-set-face-from-menu (face start end) 395(defun facemenu-set-face-from-menu (face start end)
@@ -413,7 +410,6 @@ typing a character to insert cancels the specification."
413 (if (and mark-active (not current-prefix-arg)) 410 (if (and mark-active (not current-prefix-arg))
414 (region-end)))) 411 (region-end))))
415 (barf-if-buffer-read-only) 412 (barf-if-buffer-read-only)
416 (facemenu-get-face face)
417 (if start 413 (if start
418 (facemenu-add-face face start end) 414 (facemenu-add-face face start end)
419 (facemenu-add-face face))) 415 (facemenu-add-face face)))
@@ -648,14 +644,6 @@ use the selected frame. If t, then the global, non-frame faces are used."
648 (setq face-list (cdr face-list))) 644 (setq face-list (cdr face-list)))
649 (nreverse active-list))) 645 (nreverse active-list)))
650 646
651(defun facemenu-get-face (symbol)
652 "Make sure FACE exists.
653If not, create it and add it to the appropriate menu. Return the SYMBOL."
654 (let ((name (symbol-name symbol)))
655 (cond ((facep symbol))
656 (t (make-face symbol))))
657 symbol)
658
659(defun facemenu-add-new-face (face) 647(defun facemenu-add-new-face (face)
660 "Add FACE (a face) to the Face menu. 648 "Add FACE (a face) to the Face menu.
661 649
@@ -715,47 +703,44 @@ This is called whenever you create a new face."
715 (define-key menu key (cons name function)))))) 703 (define-key menu key (cons name function))))))
716 nil) ; Return nil for facemenu-iterate 704 nil) ; Return nil for facemenu-iterate
717 705
718(defun facemenu-add-new-color (color &optional menu) 706(defun facemenu-add-new-color (color menu)
719 "Add COLOR (a color name string) to the appropriate Face menu. 707 "Add COLOR (a color name string) to the appropriate Face menu.
720MENU should be `facemenu-foreground-menu' or 708MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'.
721`facemenu-background-menu'. 709Create the appropriate face and return it.
722 710
723This is called whenever you use a new color." 711This is called whenever you use a new color."
724 (let* (name 712 (let (symbol docstring)
725 symbol 713 (unless (color-defined-p color)
726 docstring 714 (error "Color `%s' undefined" color))
727 function menu-val key
728 (color-p (memq menu '(facemenu-foreground-menu
729 facemenu-background-menu))))
730 (unless (stringp color)
731 (error "%s is not a color" color))
732 (setq name color
733 symbol (intern name))
734
735 (cond ((eq menu 'facemenu-foreground-menu) 715 (cond ((eq menu 'facemenu-foreground-menu)
736 (setq docstring 716 (setq docstring
737 (format "Select foreground color %s for subsequent insertion." 717 (format "Select foreground color %s for subsequent insertion."
738 name))) 718 color)
719 symbol (intern (concat "fg:" color)))
720 (set-face-foreground (make-face symbol) color))
739 ((eq menu 'facemenu-background-menu) 721 ((eq menu 'facemenu-background-menu)
740 (setq docstring 722 (setq docstring
741 (format "Select background color %s for subsequent insertion." 723 (format "Select background color %s for subsequent insertion."
742 name)))) 724 color)
725 symbol (intern (concat "bg:" color)))
726 (set-face-background (make-face symbol) color))
727 (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'")))
743 (cond ((facemenu-iterate ; check if equivalent face is already in the menu 728 (cond ((facemenu-iterate ; check if equivalent face is already in the menu
744 (lambda (m) (and (listp m) 729 (lambda (m) (and (listp m)
745 (symbolp (car m)) 730 (symbolp (car m))
746 (stringp (cadr m)) 731 (stringp (cadr m))
747 (string-equal (cadr m) color))) 732 (string-equal (cadr m) color)))
748 (cdr (symbol-function menu)))) 733 (cdr (symbol-function menu))))
749 (t ; No keyboard equivalent. Figure out where to put it: 734 (t ; No keyboard equivalent. Figure out where to put it:
750 (setq key (vector symbol) 735 (let ((key (vector symbol))
751 function 'facemenu-set-face-from-menu 736 (function 'facemenu-set-face-from-menu)
752 menu-val (symbol-function menu)) 737 (menu-val (symbol-function menu)))
753 (if (and facemenu-new-faces-at-end 738 (if (and facemenu-new-faces-at-end
754 (> (length menu-val) 3)) 739 (> (length menu-val) 3))
755 (define-key-after menu-val key (cons name function) 740 (define-key-after menu-val key (cons color function)
756 (car (nth (- (length menu-val) 3) menu-val))) 741 (car (nth (- (length menu-val) 3) menu-val)))
757 (define-key menu key (cons name function)))))) 742 (define-key menu key (cons color function))))))
758 nil) ; Return nil for facemenu-iterate 743 symbol))
759 744
760(defun facemenu-complete-face-list (&optional oldlist) 745(defun facemenu-complete-face-list (&optional oldlist)
761 "Return list of all faces that look different. 746 "Return list of all faces that look different.