Fix doom/what-face not handling face plist specs

This commit is contained in:
Henrik Lissner 2017-06-10 15:32:55 +02:00
parent f1c34fba72
commit ca222c1b75
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -3,21 +3,36 @@
;;;###autoload ;;;###autoload
(defun doom/what-face (&optional pos) (defun doom/what-face (&optional pos)
"Lists all faces at point. Overlay faces are denoted with an asterix." "Lists all faces at point. Overlay faces are denoted with an asterix."
(interactive "d") (interactive)
(let ((pos (or pos (point))) (unless pos
faces) (setq pos (point)))
(when-let (face (get-text-property pos 'face)) (let ((faces (let ((face (get-text-property pos 'face)))
(dolist (f (if (listp face) face (list face))) (if (keywordp (car-safe face))
(push (propertize (symbol-name f) 'face f) faces))) (list face)
(dolist (ov (overlays-at pos (1+ pos))) (cl-loop for f in (if (listp face) face (list face))
(let ((face (overlay-get ov 'face))) collect f))))
(dolist (f (if (listp face) face (list face))) (overlays (cl-loop for ov in (overlays-at pos (1+ pos))
(push (propertize (concat (symbol-name f) "*") 'face f) faces)))) nconc (cl-loop with face = (overlay-get ov 'face)
(if (called-interactively-p 'any) for f in (if (listp face) face (list face))
(message "%s %s" collect f))))
(cond ((called-interactively-p 'any)
(message "%s %s; %s"
(propertize "Faces:" 'face 'font-lock-comment-face) (propertize "Faces:" 'face 'font-lock-comment-face)
(if faces (string-join faces ", ") "n/a")) (if faces
(mapcar #'substring-no-properties faces)))) (cl-loop for face in faces
if (listp face)
concat (format "'%s " face)
else
concat (concat (propertize (symbol-name face) 'face face) " "))
"n/a ")
(if overlays
(cl-loop for ov in overlays
concat (concat (propertize (symbol-name ov) 'face ov) " "))
"n/a")))
(t
(and (or faces overlays)
(list faces overlays))))))
;;;###autoload ;;;###autoload
(defun doom-active-minor-modes () (defun doom-active-minor-modes ()