Function: facemenu-add-new-color

facemenu-add-new-color is a byte-compiled function defined in facemenu.el.gz.

Signature

(facemenu-add-new-color COLOR MENU)

Documentation

Add COLOR (a color name string) to the appropriate Face menu.

MENU should be facemenu-foreground-menu(var)/facemenu-foreground-menu(fun) or facemenu-background-menu(var)/facemenu-background-menu(fun). Return the event type (a symbol) of the added menu entry.

This is called whenever you use a new color.

Source Code

;; Defined in /usr/src/emacs/lisp/facemenu.el.gz
  nil) ; Return nil for facemenu-iterate

(defun facemenu-add-new-color (color menu)
  "Add COLOR (a color name string) to the appropriate Face menu.
MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'.
Return the event type (a symbol) of the added menu entry.

This is called whenever you use a new color."
  (let (symbol)
    (unless (color-defined-p color)
      (error "Color `%s' undefined" color))
    (cond ((eq menu 'facemenu-foreground-menu)
	   (setq symbol (intern (concat "fg:" color))))
	  ((eq menu 'facemenu-background-menu)
	   (setq symbol (intern (concat "bg:" color))))
	  (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'")))
    (unless (facemenu-iterate ; Check if color is already in the menu.
	     (lambda (m) (and (listp m)
			      (eq (car m) symbol)))
	     (cdr (symbol-function menu)))
      ;; Color is not in the menu.  Figure out where to put it.
      (let ((key (vector symbol))
	    (function 'facemenu-set-face-from-menu)
	    (menu-val (symbol-function menu)))
	(if (and facemenu-new-faces-at-end
		 (> (length menu-val) 3))
	    (define-key-after menu-val key (cons color function)
	      (car (nth (- (length menu-val) 3) menu-val)))
	  (define-key menu key (cons color function)))))
    symbol))