aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/faces.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/faces.el')
-rw-r--r--lisp/faces.el33
1 files changed, 22 insertions, 11 deletions
diff --git a/lisp/faces.el b/lisp/faces.el
index c7acbf57587..390ddbf606a 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2046,18 +2046,29 @@ as backgrounds."
2046 (when msg (message "Color: `%s'" color)) 2046 (when msg (message "Color: `%s'" color))
2047 color)) 2047 color))
2048 2048
2049(defun face-at-point (&optional thing multiple) 2049(defun face-at-point (&optional text multiple)
2050 "Return the face of the character after point. 2050 "Return a face name from point in the current buffer.
2051If it has more than one face, return the first one. 2051This function is meant to be used as a conveniency function for
2052If THING is non-nil try first to get a face name from the buffer. 2052providing defaults when prompting the user for a face name.
2053IF MULTIPLE is non-nil, return a list of all faces. 2053
2054Return nil if there is no face." 2054If TEXT is non-nil, return the text at point if it names an
2055existing face.
2056
2057Otherwise, look at the faces in effect at point as text
2058properties or overlay properties, and return one of these face
2059names.
2060
2061IF MULTIPLE is non-nil, return a list of faces.
2062
2063Return nil if there is no face at point.
2064
2065This function is not meant for handling faces programatically; to
2066do that, use `get-text-property' and `get-char-property'."
2055 (let (faces) 2067 (let (faces)
2056 (if thing 2068 (when text
2057 ;; Try to get a face name from the buffer. 2069 ;; Try to get a face name from the buffer.
2058 (let ((face (intern-soft (thing-at-point 'symbol)))) 2070 (when-let ((face (thing-at-point 'face)))
2059 (if (facep face) 2071 (push face faces)))
2060 (push face faces))))
2061 ;; Add the named faces that the `read-face-name' or `face' property uses. 2072 ;; Add the named faces that the `read-face-name' or `face' property uses.
2062 (let ((faceprop (or (get-char-property (point) 'read-face-name) 2073 (let ((faceprop (or (get-char-property (point) 'read-face-name)
2063 (get-char-property (point) 'face)))) 2074 (get-char-property (point) 'face))))