Function: facemenu-add-face
facemenu-add-face is an interactive and byte-compiled function defined
in facemenu.el.gz.
Signature
(facemenu-add-face FACE &optional START END)
Documentation
Add FACE to text between START and END.
If START is nil or START to END is empty, add FACE to next typed character
instead. For each section of that region that has a different face property,
FACE will be consed onto it, and other faces that are completely hidden by
that will be removed from the list.
If facemenu-add-face-function and maybe facemenu-end-add-face are non-nil,
they are used to set the face information.
As a special case, if FACE is default, then the region is left with NO face
text property. Otherwise, selecting the default face would not have any
effect. See facemenu-remove-face-function.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/facemenu.el.gz
(defun facemenu-add-face (face &optional start end)
"Add FACE to text between START and END.
If START is nil or START to END is empty, add FACE to next typed character
instead. For each section of that region that has a different face property,
FACE will be consed onto it, and other faces that are completely hidden by
that will be removed from the list.
If `facemenu-add-face-function' and maybe `facemenu-end-add-face' are non-nil,
they are used to set the face information.
As a special case, if FACE is `default', then the region is left with NO face
text property. Otherwise, selecting the default face would not have any
effect. See `facemenu-remove-face-function'."
(interactive (list (progn
(barf-if-buffer-read-only)
(read-face-name "Use face" (face-at-point t)))
(if (and mark-active (not current-prefix-arg))
(region-beginning))
(if (and mark-active (not current-prefix-arg))
(region-end))))
(cond
((and (eq face 'default)
(not (eq facemenu-remove-face-function t)))
(if facemenu-remove-face-function
(funcall facemenu-remove-face-function start end)
(if (and start (< start end))
(remove-list-of-text-properties start end '(face))
(facemenu-set-self-insert-face 'default))))
(facemenu-add-face-function
(save-excursion
(if end (goto-char end))
(save-excursion
(if start (goto-char start))
(insert-before-markers
(funcall facemenu-add-face-function face end)))
(if facemenu-end-add-face
(insert (if (stringp facemenu-end-add-face)
facemenu-end-add-face
(funcall facemenu-end-add-face face))))))
((and start (< start end))
(let ((part-start start) part-end)
(while (not (= part-start end))
(setq part-end (next-single-property-change part-start 'face
nil end))
(let ((prev (get-text-property part-start 'face)))
(put-text-property part-start part-end 'face
(if (null prev)
face
(facemenu-active-faces
(cons face
(if (face-list-p prev)
prev
(list prev)))
;; Specify the selected frame
;; because nil would mean to use
;; the new-frame default settings,
;; and those are usually nil.
(selected-frame)))))
(setq part-start part-end))))
(t
(facemenu-set-self-insert-face
(if (eq last-command (cdr facemenu-self-insert-data))
(cons face (if (listp (car facemenu-self-insert-data))
(car facemenu-self-insert-data)
(list (car facemenu-self-insert-data))))
face))))
(unless (facemenu-enable-faces-p)
(message "Font-lock mode will override any faces you set in this buffer")))