• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/

Lines Matching +defs:face +defs:background

1 ;;; facemenu.el --- create a face menu for interactively adding fonts to text
29 ;; set the face used for a region of the buffer. Some faces also have
36 ;; Selecting a face from the menu or typing the keyboard equivalent will
37 ;; change the region to use that face. If you use transient-mark-mode and the
38 ;; region is not active, the face will be remembered and used for the next
66 ;; (define-key global-map [?\H-C] 'facemenu-set-background) ; set bg color
96 ;;;###autoload (autoload 'facemenu-keymap "facemenu" "Keymap for face-changing commands." t 'keymap)
103 "Create a face menu for interactively adding fonts to text."
114 Each element is itself a list: the car is the name of the face,
125 :type '(repeat (cons face string))
136 `(modeline region secondary-selection highlight scratch-face
146 Each element should be a symbol, the name of a face.
158 using the face menu commands (even by name), and all faces
171 (defvar facemenu-face-menu
173 (define-key map "o" (cons "Other..." 'facemenu-set-face))
177 (defalias 'facemenu-face-menu facemenu-face-menu)
178 (put 'facemenu-face-menu 'menu-enable '(facemenu-enable-faces-p))
191 (defvar facemenu-background-menu
193 (define-key map "o" (cons "Other..." 'facemenu-set-background))
195 "Menu keymap for background colors.")
197 (defalias 'facemenu-background-menu facemenu-background-menu)
198 (put 'facemenu-background-menu 'menu-enable '(facemenu-enable-faces-p))
216 "Menu keymap for non-face text-properties.")
264 'facemenu-remove-face-props))
276 'facemenu-background-menu))
280 'facemenu-face-menu)))
285 (let ((map (make-sparse-keymap "Set face")))
286 (define-key map "o" (cons (purecopy "Other...") 'facemenu-set-face))
288 "Keymap for face-changing commands.
294 (defcustom facemenu-add-face-function nil
297 return a string which is inserted. It may set `facemenu-end-add-face'."
302 (defcustom facemenu-end-add-face nil
311 (defcustom facemenu-remove-face-function nil
314 May also be t meaning to use `facemenu-add-face-function'."
316 (const :tag "Use add-face" t)
332 ;; Add each defined face to the menu.
333 (facemenu-iterate 'facemenu-add-new-face
334 (facemenu-complete-face-list facemenu-keybindings)))
337 (defun facemenu-set-face (face &optional start end)
358 (read-face-name "Use face"))
363 (facemenu-add-new-face face)
364 (facemenu-add-face face start end))
373 requested face.
375 Otherwise, this command specifies the face for the next character
385 (facemenu-set-face-from-menu
390 (defun facemenu-set-background (color &optional start end)
391 "Set the background COLOR of the region or next character typed.
396 requested face.
398 Otherwise, this command specifies the face for the next character
408 (facemenu-set-face-from-menu
409 (facemenu-add-new-color color 'facemenu-background-menu)
413 (defun facemenu-set-face-from-menu (face start end)
418 foreground or background to the color specified by the rest of the
419 symbol's name. Any other symbol is considered the name of a face.
423 requested face.
425 Otherwise, this command specifies the face for the next character
434 (facemenu-add-face
435 (let ((fn (symbol-name face)))
439 :background)
441 face))
469 (defun facemenu-remove-face-props (start end)
470 "Remove `face' and `mouse-face' text properties."
474 start end '(face nil mouse-face nil))))
545 'face (cons 'background-color (car color)))
552 'face (cons 'foreground-color (car color)))
591 (defun facemenu-add-face (face &optional start end)
594 instead. For each section of that region that has a different face property,
597 If `facemenu-add-face-function' and maybe `facemenu-end-add-face' are non-nil,
598 they are used to set the face information.
600 As a special case, if FACE is `default', then the region is left with NO face
601 text property. Otherwise, selecting the default face would not have any
602 effect. See `facemenu-remove-face-function'."
604 (if (and (eq face 'default)
605 (not (eq facemenu-remove-face-function t)))
606 (if facemenu-remove-face-function
607 (funcall facemenu-remove-face-function start end)
609 (remove-text-properties start end '(face default))
610 (setq self-insert-face 'default
611 self-insert-face-command this-command)))
612 (if facemenu-add-face-function
618 (funcall facemenu-add-face-function face end)))
619 (if facemenu-end-add-face
620 (insert (if (stringp facemenu-end-add-face)
621 facemenu-end-add-face
622 (funcall facemenu-end-add-face face)))))
626 (setq part-end (next-single-property-change part-start 'face
628 (let ((prev (get-text-property part-start 'face)))
629 (put-text-property part-start part-end 'face
631 face
633 (cons face
643 (setq self-insert-face (if (eq last-command self-insert-face-command)
644 (cons face (if (listp self-insert-face)
645 self-insert-face
646 (list self-insert-face)))
647 face)
648 self-insert-face-command this-command))))
652 (defun facemenu-active-faces (face-list &optional frame)
654 This means each face attribute is not specified in a face earlier in FACE-LIST
655 and such a face is therefore active when used to display text.
659 (if (consp (car face-list))
660 (face-attributes-as-vector (car face-list))
661 (or (internal-lisp-face-p (car face-list) frame)
662 (check-face (car face-list))))))
663 (active-list (list (car face-list)))
664 (face-list (cdr face-list))
666 (while face-list
667 (if (let ((face-atts
668 (if (consp (car face-list))
669 (face-attributes-as-vector (car face-list))
670 (or (internal-lisp-face-p (car face-list) frame)
671 (check-face (car face-list)))))
675 (and (not (memq (aref face-atts i) '(nil unspecified)))
679 (setq active-list (cons (car face-list) active-list)))
680 (setq face-list (cdr face-list)))
683 (defun facemenu-add-new-face (face)
684 "Add FACE (a face) to the Face menu if `facemenu-listed-faces' says so.
685 This is called whenever you create a new face, and at other times."
689 (key (cdr (assoc face facemenu-keybindings)))
691 (if (symbolp face)
692 (setq name (symbol-name face)
693 symbol face)
694 (setq name face
696 (setq menu 'facemenu-face-menu)
698 (format "Select face `%s' for subsequent insertion.
700 apply face `%s' to the region instead.
701 This command was defined by `facemenu-add-new-face'."
703 (cond ((facemenu-iterate ; check if equivalent face is already in the menu
706 ;; Avoid error in face-equal
707 ;; when a non-face is erroneously present.
709 (face-equal (car m) symbol)))
718 (facemenu-set-face
730 function 'facemenu-set-face-from-menu
741 MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'.
753 ((eq menu 'facemenu-background-menu)
755 (format "Select background color %s for subsequent insertion."
758 (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'")))
765 (function 'facemenu-set-face-from-menu)
774 (defun facemenu-complete-face-list (&optional oldlist)
777 differently from any face already on the list.
782 (lambda (new-face)
783 (if (not (memq new-face list))
784 (setq list (cons new-face list)))
786 (nreverse (face-list)))