diff options
| author | Dmitry Gutov | 2022-08-15 02:22:59 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2022-08-15 02:22:59 +0300 |
| commit | ee3a674c7c9e39fe7ff296ce1f9830fc45520de8 (patch) | |
| tree | e8ba1e7be54314f208454e80e3d31044c913f3eb /lisp/faces.el | |
| parent | fe0e53d963899a16e0dd1bbc1ba10a6b59f7989e (diff) | |
| parent | 0a8e88fd83db5398d36064a7f87cff5b57da7284 (diff) | |
| download | emacs-scratch/font_lock_large_files.tar.gz emacs-scratch/font_lock_large_files.zip | |
Merge branch 'master' into scratch/font_lock_large_filesscratch/font_lock_large_files
Diffstat (limited to 'lisp/faces.el')
| -rw-r--r-- | lisp/faces.el | 33 |
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. |
| 2051 | If it has more than one face, return the first one. | 2051 | This function is meant to be used as a conveniency function for |
| 2052 | If THING is non-nil try first to get a face name from the buffer. | 2052 | providing defaults when prompting the user for a face name. |
| 2053 | IF MULTIPLE is non-nil, return a list of all faces. | 2053 | |
| 2054 | Return nil if there is no face." | 2054 | If TEXT is non-nil, return the text at point if it names an |
| 2055 | existing face. | ||
| 2056 | |||
| 2057 | Otherwise, look at the faces in effect at point as text | ||
| 2058 | properties or overlay properties, and return one of these face | ||
| 2059 | names. | ||
| 2060 | |||
| 2061 | IF MULTIPLE is non-nil, return a list of faces. | ||
| 2062 | |||
| 2063 | Return nil if there is no face at point. | ||
| 2064 | |||
| 2065 | This function is not meant for handling faces programatically; to | ||
| 2066 | do 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)))) |