0

With the following, how can I call the function interactively so that I can also call describe-face at current point?

(defun laxy-descface (face)
  "Describe the typeface properties of FACE."

  (interactive
   (list
    (let* ( (cseq '("mode-line-inactive" "mode-line")) )
      (completing-read "Face: " cseq nil t "mode-line"))))

  (describe-face face))
0

1 Answer 1

1

I am not sure how would be your preferred design, but I would suggest the following:

(defun laxy-descface (face)
  "Describe the typeface properties of FACE."

  (interactive
   (list
    (let* ((fap (face-at-point))
           (cseq (append (when fap (list fap)) '("mode-line-inactive" "mode-line")) ))
      (completing-read "Face: " cseq nil t))))

  (describe-face face))

Anyway, the essential part is that you can use (face-at-point) to get the face at point.

However, if e.g. hl-line-mode is active, then you will not get the actual text its face properties. In that case you can use (plist-get (text-properties-at (point)) 'face) instead of (face-at-point).

11
  • I want to display the face properties by selecting from a list. Either for current point, or else for mode-line-inactive or mode-line. Have seen that one can do (describe-face 'default) but do not know how appropriate it would be.
    – Dilna
    Commented Aug 9, 2022 at 8:51
  • 1
    If user wants face-at-point, the function should ensure that it always displays face property at point.
    – Dilna
    Commented Aug 9, 2022 at 10:05
  • How should the function know if the user wants face-at-point? The function would have a different name? Or you would use a universal-argument? Or it determines by the face-at-point (if the text under point has a face property). Please try to think about what you want exactly first, and try to write down your question as clearly as possible, so that we do not have to guess in our answers, and can give the correct answer at once (to the correct question). Commented Aug 9, 2022 at 10:13
  • 1
    face-at-point can also be called like this: (face-at-point nil t) to return a list of faces, which might be useful if there is more than one.
    – NickD
    Commented Aug 9, 2022 at 13:50
  • 1
    @Ephram: the problem with almost all your questions is that you don't specify enough, so when somebody provides an answer to the question, you then try to fill the gaps with more questions in the comments. That is a bad model for this site: I've complained to you about that before and I will keep complaining, until you stop doing that: ask a well defined question, get a well-defined answer, accept it and move on.
    – NickD
    Commented Aug 9, 2022 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.