aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-04-15 22:05:52 +0000
committerRichard M. Stallman2002-04-15 22:05:52 +0000
commit9bf4c4e564de382e51e270279dee07e042b25d64 (patch)
treef21b6e216163fd0e4b91648f1f18d8a03529881c
parent538af1cd6706acf50f6dfe81b096f39c8c3b690d (diff)
downloademacs-9bf4c4e564de382e51e270279dee07e042b25d64.tar.gz
emacs-9bf4c4e564de382e51e270279dee07e042b25d64.zip
(facemenu-add-new-face): Use this only for faces. Delete arg MENU.
(facemenu-add-new-color): New function. (facemenu-set-foreground, facemenu-set-background): Use facemenu-add-new-color.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/facemenu.el83
2 files changed, 64 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7baa9808f67..e0dec296a54 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12002-04-15 Richard M. Stallman <rms@gnu.org>
2
3 * facemenu.el (facemenu-add-new-face): Use this only for faces.
4 Delete arg MENU.
5 (facemenu-add-new-color): New function.
6 (facemenu-set-foreground, facemenu-set-background):
7 Use facemenu-add-new-color.
8
12002-04-15 Eli Zaretskii <eliz@is.elta.co.il> 92002-04-15 Eli Zaretskii <eliz@is.elta.co.il>
2 10
3 * ediff-init.el (ediff-current-diff-face-A) 11 * ediff-init.el (ediff-current-diff-face-A)
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index b6a93bb09f4..e8a935b2286 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -363,7 +363,7 @@ typing a character to insert cancels the specification."
363 (region-end)))) 363 (region-end))))
364 (unless (color-defined-p color) 364 (unless (color-defined-p color)
365 (message "Color `%s' undefined" color)) 365 (message "Color `%s' undefined" color))
366 (facemenu-add-new-face color 'facemenu-foreground-menu) 366 (facemenu-add-new-color color 'facemenu-foreground-menu)
367 (facemenu-add-face (list (list :foreground color)) start end)) 367 (facemenu-add-face (list (list :foreground color)) start end))
368 368
369;;;###autoload 369;;;###autoload
@@ -387,7 +387,7 @@ typing a character to insert cancels the specification."
387 (region-end)))) 387 (region-end))))
388 (unless (color-defined-p color) 388 (unless (color-defined-p color)
389 (message "Color `%s' undefined" color)) 389 (message "Color `%s' undefined" color))
390 (facemenu-add-new-face color 'facemenu-background-menu) 390 (facemenu-add-new-color color 'facemenu-background-menu)
391 (facemenu-add-face (list (list :background color)) start end)) 391 (facemenu-add-face (list (list :background color)) start end))
392 392
393;;;###autoload 393;;;###autoload
@@ -805,37 +805,24 @@ If not, create it and add it to the appropriate menu. Return the SYMBOL."
805 (t (make-face symbol)))) 805 (t (make-face symbol))))
806 symbol) 806 symbol)
807 807
808(defun facemenu-add-new-face (face-or-color &optional menu) 808(defun facemenu-add-new-face (face)
809 "Add FACE-OR-COLOR (a face or a color) to the appropriate Face menu. 809 "Add FACE (a face) to the Face menu.
810If MENU is nil, then FACE-OR-COLOR is a face to be added
811to `facemenu-face-menu'. If MENU is `facemenu-foreground-menu'
812or `facemenu-background-menu', FACE-OR-COLOR is a color
813to be added to the specified menu.
814 810
815This is called whenever you create a new face." 811This is called whenever you create a new face."
816 (let* (name 812 (let* (name
817 symbol 813 symbol
818 docstring 814 menu docstring
819 (key (cdr (assoc face-or-color facemenu-keybindings))) 815 (key (cdr (assoc face facemenu-keybindings)))
820 function menu-val) 816 function menu-val)
821 (if (symbolp face-or-color) 817 (if (symbolp face)
822 (setq name (symbol-name face-or-color) 818 (setq name (symbol-name face)
823 symbol face-or-color) 819 symbol face)
824 (setq name face-or-color 820 (setq name face
825 symbol (intern name))) 821 symbol (intern name)))
826 (cond ((eq menu 'facemenu-foreground-menu) 822 (setq menu 'facemenu-face-menu)
827 (setq docstring 823 (setq docstring
828 (format "Select foreground color %s for subsequent insertion." 824 (format "Select face `%s' for subsequent insertion."
829 name))) 825 name))
830 ((eq menu 'facemenu-background-menu)
831 (setq docstring
832 (format "Select background color %s for subsequent insertion."
833 name)))
834 (t
835 (setq menu 'facemenu-face-menu)
836 (setq docstring
837 (format "Select face `%s' for subsequent insertion."
838 name))))
839 (cond ((eq t facemenu-unlisted-faces)) 826 (cond ((eq t facemenu-unlisted-faces))
840 ((memq symbol facemenu-unlisted-faces)) 827 ((memq symbol facemenu-unlisted-faces))
841 ;; test against regexps in facemenu-unlisted-faces 828 ;; test against regexps in facemenu-unlisted-faces
@@ -877,6 +864,48 @@ This is called whenever you create a new face."
877 (define-key menu key (cons name function)))))) 864 (define-key menu key (cons name function))))))
878 nil) ; Return nil for facemenu-iterate 865 nil) ; Return nil for facemenu-iterate
879 866
867(defun facemenu-add-new-color (color &optional menu)
868 "Add COLOR (a color name string) to the appropriate Face menu.
869MENU should be `facemenu-foreground-menu' or
870`facemenu-background-menu'.
871
872This is called whenever you use a new color."
873 (let* (name
874 symbol
875 docstring
876 function menu-val key
877 (color-p (memq menu '(facemenu-foreground-menu
878 facemenu-background-menu))))
879 (unless (stringp color)
880 (error "%s is not a color" color))
881 (setq name color
882 symbol (intern name))
883
884 (cond ((eq menu 'facemenu-foreground-menu)
885 (setq docstring
886 (format "Select foreground color %s for subsequent insertion."
887 name)))
888 ((eq menu 'facemenu-background-menu)
889 (setq docstring
890 (format "Select background color %s for subsequent insertion."
891 name))))
892 (cond ((facemenu-iterate ; check if equivalent face is already in the menu
893 (lambda (m) (and (listp m)
894 (symbolp (car m))
895 (stringp (cadr m))
896 (string-equal (cadr m) color)))
897 (cdr (symbol-function menu))))
898 (t ; No keyboard equivalent. Figure out where to put it:
899 (setq key (vector symbol)
900 function 'facemenu-set-face-from-menu
901 menu-val (symbol-function menu))
902 (if (and facemenu-new-faces-at-end
903 (> (length menu-val) 3))
904 (define-key-after menu-val key (cons name function)
905 (car (nth (- (length menu-val) 3) menu-val)))
906 (define-key menu key (cons name function))))))
907 nil) ; Return nil for facemenu-iterate
908
880(defun facemenu-complete-face-list (&optional oldlist) 909(defun facemenu-complete-face-list (&optional oldlist)
881 "Return list of all faces that look different. 910 "Return list of all faces that look different.
882Starts with given ALIST of faces, and adds elements only if they display 911Starts with given ALIST of faces, and adds elements only if they display