mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-27 10:54:40 +00:00
Clarify face-at-point doc string and add (thing-at-point 'face)
* lisp/faces.el (face-at-point): Say what this function does. * lisp/thingatpt.el (thing-at-point-face-at-point): Add `face' type (bug#57087). (thing-at-point-provider-alist, thing-at-point): Mention it in the doc strings.
This commit is contained in:
parent
c0d761bf7f
commit
829b131e5b
@ -2046,18 +2046,29 @@ as backgrounds."
|
|||||||
(when msg (message "Color: `%s'" color))
|
(when msg (message "Color: `%s'" color))
|
||||||
color))
|
color))
|
||||||
|
|
||||||
(defun face-at-point (&optional thing multiple)
|
(defun face-at-point (&optional text multiple)
|
||||||
"Return the face of the character after point.
|
"Return a face name from point in the current buffer.
|
||||||
If it has more than one face, return the first one.
|
This function is meant to be used as a conveniency function for
|
||||||
If THING is non-nil try first to get a face name from the buffer.
|
providing defaults when prompting the user for a face name.
|
||||||
IF MULTIPLE is non-nil, return a list of all faces.
|
|
||||||
Return nil if there is no face."
|
If TEXT is non-nil, return the text at point if it names an
|
||||||
|
existing face.
|
||||||
|
|
||||||
|
Otherwise, look at the faces in effect at point as text
|
||||||
|
properties or overlay properties, and return one of these face
|
||||||
|
names.
|
||||||
|
|
||||||
|
IF MULTIPLE is non-nil, return a list of faces.
|
||||||
|
|
||||||
|
Return nil if there is no face at point.
|
||||||
|
|
||||||
|
This function is not meant for handling faces programatically; to
|
||||||
|
do that, use `get-text-property' and `get-char-property'."
|
||||||
(let (faces)
|
(let (faces)
|
||||||
(if thing
|
(when text
|
||||||
;; Try to get a face name from the buffer.
|
;; Try to get a face name from the buffer.
|
||||||
(let ((face (intern-soft (thing-at-point 'symbol))))
|
(when-let ((face (thing-at-point 'face)))
|
||||||
(if (facep face)
|
(push face faces)))
|
||||||
(push face faces))))
|
|
||||||
;; Add the named faces that the `read-face-name' or `face' property uses.
|
;; Add the named faces that the `read-face-name' or `face' property uses.
|
||||||
(let ((faceprop (or (get-char-property (point) 'read-face-name)
|
(let ((faceprop (or (get-char-property (point) 'read-face-name)
|
||||||
(get-char-property (point) 'face))))
|
(get-char-property (point) 'face))))
|
||||||
|
@ -74,7 +74,7 @@ question.
|
|||||||
|
|
||||||
\"things\" include `symbol', `list', `sexp', `defun', `filename',
|
\"things\" include `symbol', `list', `sexp', `defun', `filename',
|
||||||
`existing-filename', `url', `email', `uuid', `word', `sentence',
|
`existing-filename', `url', `email', `uuid', `word', `sentence',
|
||||||
`whitespace', `line', and `page'.")
|
`whitespace', `line', `face' and `page'.")
|
||||||
|
|
||||||
;; Basic movement
|
;; Basic movement
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ positions of the thing found."
|
|||||||
THING should be a symbol specifying a type of syntactic entity.
|
THING should be a symbol specifying a type of syntactic entity.
|
||||||
Possibilities include `symbol', `list', `sexp', `defun',
|
Possibilities include `symbol', `list', `sexp', `defun',
|
||||||
`filename', `existing-filename', `url', `email', `uuid', `word',
|
`filename', `existing-filename', `url', `email', `uuid', `word',
|
||||||
`sentence', `whitespace', `line', `number', and `page'.
|
`sentence', `whitespace', `line', `number', `face' and `page'.
|
||||||
|
|
||||||
When the optional argument NO-PROPERTIES is non-nil,
|
When the optional argument NO-PROPERTIES is non-nil,
|
||||||
strip text properties from the return value.
|
strip text properties from the return value.
|
||||||
@ -361,6 +361,15 @@ E.g.:
|
|||||||
|
|
||||||
(put 'existing-filename 'thing-at-point 'thing-at-point-file-at-point)
|
(put 'existing-filename 'thing-at-point 'thing-at-point-file-at-point)
|
||||||
|
|
||||||
|
;; Faces
|
||||||
|
|
||||||
|
(defun thing-at-point-face-at-point (&optional _lax _bounds)
|
||||||
|
"Return the name of the face at point as a symbol."
|
||||||
|
(when-let ((face (thing-at-point 'symbol)))
|
||||||
|
(and (facep face) (intern face))))
|
||||||
|
|
||||||
|
(put 'face 'thing-at-point 'thing-at-point-face-at-point)
|
||||||
|
|
||||||
;; URIs
|
;; URIs
|
||||||
|
|
||||||
(defvar thing-at-point-beginning-of-url-regexp nil
|
(defvar thing-at-point-beginning-of-url-regexp nil
|
||||||
|
Loading…
Reference in New Issue
Block a user