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

Lines Matching +defs:facemenu +defs:unlisted +defs:faces

0 ;;; facemenu.el --- create a face menu for interactively adding fonts to text
7 ;; Keywords: faces
28 ;; This file defines a menu of faces (bold, italic, etc) which allows you to
29 ;; set the face used for a region of the buffer. Some faces also have
57 ;; (setq facemenu-keybindings
63 ;; (facemenu-update)
64 ;; (setq facemenu-keymap global-map)
65 ;; (define-key global-map [?\H-c] 'facemenu-set-foreground) ; set fg color
66 ;; (define-key global-map [?\H-C] 'facemenu-set-background) ; set bg color
68 ;; The order of the faces that appear in the menu and their keybindings can be
69 ;; controlled by setting the variables `facemenu-keybindings' and
70 ;; `facemenu-new-faces-at-end'. List faces that you want to use in documents
71 ;; in `facemenu-listed-faces'.
78 ;; There is at present no way to display what the faces look like in
81 ;; `list-faces-display' shows the faces in a different order than
95 ;;;###autoload (define-key global-map "\M-o" 'facemenu-keymap)
96 ;;;###autoload (autoload 'facemenu-keymap "facemenu" "Keymap for face-changing commands." t 'keymap)
99 (define-key global-map [C-down-mouse-2] 'facemenu-menu)
100 (define-key global-map "\M-o" 'facemenu-keymap)
102 (defgroup facemenu nil
104 :group 'faces
105 :prefix "facemenu-")
107 (defcustom facemenu-keybindings
113 "Alist of interesting faces and keybindings.
116 the binding is made in `facemenu-keymap'.
118 The faces specifically mentioned in this list are put at the top of
119 the menu, in the order specified. All other faces which are defined
120 in `facemenu-listed-faces' are listed after them, but get no
123 If you change this variable after loading facemenu.el, you will need to call
124 `facemenu-update' to make it take effect."
126 :group 'facemenu)
128 (defcustom facemenu-new-faces-at-end t
129 "*Where in the menu to insert newly-created faces.
133 :group 'facemenu)
135 (defvar facemenu-unlisted-faces
140 "*List of faces that are of no interest to the user.")
141 (make-obsolete-variable 'facemenu-unlisted-faces 'facemenu-listed-faces
144 (defcustom facemenu-listed-faces nil
145 "*List of faces to include in the Face menu.
147 The \"basic \" faces in `facemenu-keybindings' are automatically
150 This value takes effect when you load facemenu.el. If the
151 list includes symbols which are not defined as faces, they
153 those faces adds them to the menu then. You can call
154 `facemenu-update' to recalculate the menu contents, such as
157 If this variable is t, all faces that you apply to text
158 using the face menu commands (even by name), and all faces
161 you define some faces, so that they will be added. However,
162 if the value is no longer t and you call `facemenu-update',
163 it will remove any faces not explicitly in the list."
164 :type '(choice (const :tag "List all faces" t)
167 :group 'facemenu
171 (defvar facemenu-face-menu
173 (define-key map "o" (cons "Other..." 'facemenu-set-face))
175 "Menu keymap for faces.")
177 (defalias 'facemenu-face-menu facemenu-face-menu)
178 (put 'facemenu-face-menu 'menu-enable '(facemenu-enable-faces-p))
181 (defvar facemenu-foreground-menu
183 (define-key map "o" (cons "Other..." 'facemenu-set-foreground))
187 (defalias 'facemenu-foreground-menu facemenu-foreground-menu)
188 (put 'facemenu-foreground-menu 'menu-enable '(facemenu-enable-faces-p))
191 (defvar facemenu-background-menu
193 (define-key map "o" (cons "Other..." 'facemenu-set-background))
197 (defalias 'facemenu-background-menu facemenu-background-menu)
198 (put 'facemenu-background-menu 'menu-enable '(facemenu-enable-faces-p))
200 ;;; Condition for enabling menu items that set faces.
201 (defun facemenu-enable-faces-p ()
205 (defvar facemenu-special-menu
208 'facemenu-remove-special))
210 'facemenu-set-intangible))
212 'facemenu-set-invisible))
214 'facemenu-set-read-only))
218 (defalias 'facemenu-special-menu facemenu-special-menu)
221 (defvar facemenu-justification-menu
231 (defalias 'facemenu-justification-menu facemenu-justification-menu)
234 (defvar facemenu-indentation-menu
247 (defalias 'facemenu-indentation-menu facemenu-indentation-menu)
251 (defvar facemenu-menu nil
254 (setq facemenu-menu (make-sparse-keymap "Text Properties"))
256 (let ((map facemenu-menu))
258 (define-key map [df] (cons (purecopy "Display Faces") 'list-faces-display))
262 'facemenu-remove-all))
264 'facemenu-remove-face-props))
267 (let ((map facemenu-menu))
269 'facemenu-indentation-menu))
271 'facemenu-justification-menu))
274 'facemenu-special-menu))
276 'facemenu-background-menu))
278 'facemenu-foreground-menu))
280 'facemenu-face-menu)))
282 (defalias 'facemenu-menu facemenu-menu)
284 (defvar facemenu-keymap
286 (define-key map "o" (cons (purecopy "Other...") 'facemenu-set-face))
290 requested in `facemenu-keybindings'.")
291 (defalias 'facemenu-keymap facemenu-keymap)
294 (defcustom facemenu-add-face-function nil
297 return a string which is inserted. It may set `facemenu-end-add-face'."
300 :group 'facemenu)
302 (defcustom facemenu-end-add-face nil
309 :group 'facemenu)
311 (defcustom facemenu-remove-face-function nil
312 "When non-nil, this is a function called to remove faces.
314 May also be t meaning to use `facemenu-add-face-function'."
318 :group 'facemenu)
322 (defvar facemenu-color-alist nil
326 (defun facemenu-update ()
333 (facemenu-iterate 'facemenu-add-new-face
334 (facemenu-complete-face-list facemenu-keybindings)))
337 (defun facemenu-set-face (face &optional start end)
343 to the faces to use for the next character
348 the list of faces to be used. For any other value of FACE,
350 of faces to be used, and removing any faces further
352 preceding faces (including FACE).
354 This command can also add FACE to the menu of faces,
355 if `facemenu-listed-faces' says to do that."
363 (facemenu-add-new-face face)
364 (facemenu-add-face face start end))
367 (defun facemenu-set-foreground (color &optional start end)
380 (facemenu-read-color "Foreground color: "))
385 (facemenu-set-face-from-menu
386 (facemenu-add-new-color color 'facemenu-foreground-menu)
390 (defun facemenu-set-background (color &optional start end)
403 (facemenu-read-color "Background color: "))
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)
434 (facemenu-add-face
445 (defun facemenu-set-invisible (start end)
448 `facemenu-remove-special'."
453 (defun facemenu-set-intangible (start end)
456 `facemenu-remove-special'."
461 (defun facemenu-set-read-only (start end)
464 `facemenu-remove-special'."
469 (defun facemenu-remove-face-props (start end)
477 (defun facemenu-remove-all (start end)
484 (defun facemenu-remove-special (start end)
494 (defun facemenu-read-color (&optional prompt)
498 (or facemenu-color-alist
566 This function uses the predicate `facemenu-color-equal' to compare
573 (if (and (facemenu-color-equal (car (car l)) (car (car (cdr l))))
582 (defun facemenu-color-equal (a b)
591 (defun facemenu-add-face (face &optional start end)
595 FACE will be consed onto it, and other faces that are completely hidden by
597 If `facemenu-add-face-function' and maybe `facemenu-end-add-face' are non-nil,
602 effect. See `facemenu-remove-face-function'."
605 (not (eq facemenu-remove-face-function t)))
606 (if facemenu-remove-face-function
607 (funcall facemenu-remove-face-function start end)
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)))))
632 (facemenu-active-faces
649 (unless (facemenu-enable-faces-p)
650 (message "Font-lock mode will override any faces you set in this buffer")))
652 (defun facemenu-active-faces (face-list &optional frame)
653 "Return from FACE-LIST those faces that would be used for display.
656 If the optional argument FRAME is given, use the faces in that frame; otherwise
657 use the selected frame. If t, then the global, non-frame faces are used."
683 (defun facemenu-add-new-face (face)
684 "Add FACE (a face) to the Face menu if `facemenu-listed-faces' says so.
689 (key (cdr (assoc face facemenu-keybindings)))
696 (setq menu 'facemenu-face-menu)
701 This command was defined by `facemenu-add-new-face'."
703 (cond ((facemenu-iterate ; check if equivalent face is already in the menu
713 (setq function (intern (concat "facemenu-set-" name)))
718 (facemenu-set-face
724 (define-key 'facemenu-keymap key (cons name function))
727 ((or (eq t facemenu-listed-faces)
728 (memq symbol facemenu-listed-faces))
730 function 'facemenu-set-face-from-menu
732 (if (and facemenu-new-faces-at-end
737 nil) ; Return nil for facemenu-iterate
739 (defun facemenu-add-new-color (color menu)
741 MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'.
748 (cond ((eq menu 'facemenu-foreground-menu)
753 ((eq menu 'facemenu-background-menu)
758 (t (error "MENU should be `facemenu-foreground-menu' or `facemenu-background-menu'")))
759 (unless (facemenu-iterate ; Check if color is already in the menu.
765 (function 'facemenu-set-face-from-menu)
767 (if (and facemenu-new-faces-at-end
774 (defun facemenu-complete-face-list (&optional oldlist)
775 "Return list of all faces that look different.
776 Starts with given ALIST of faces, and adds elements only if they display
778 The faces on ALIST will end up at the end of the returned list, in reverse
781 (facemenu-iterate
789 (defun facemenu-iterate (func list)
796 (facemenu-update)
798 (provide 'facemenu)
801 ;;; facemenu.el ends here