reddit / emacs

face picker?

o__J_O · 2022-12-25 18:53
Hi, I am spending a lot of time trying to track down the variable for a face which needs tweaking. Is there a recommended way to figure it out? For example, is there an emacs **face picker**? :) Similar to a **color picker** but a method that would allow me to pick the text under my mouse and expose the corresponding face variable? I am including a couple of screenshots of faces I would like to change. Thanks a lot! \*\*\* Edit 1 \*\*\* * screenshots - [https://imgur.com/a/BHLVJHT](https://imgur.com/a/BHLVJHT) \*\*\* Edit 2 \*\*\* I was able to web search to create a `face-picker` function - see below. I wrote it because I have cases where the font flips after N seconds. I need to figure out how to get the font where one cannot put point. I might create a separate post for it. (defun face-picker () (interactive) (describe-face (face-at-point))) (global-set-key (kbd "C-c f" ) 'face-picker)
mickeyp · 2022-12-25 19:01
`M-x customize-apropos-faces` to search. Customizing the group of the major mode is usually enough: `M-x customize-group`. Or, `C-u C-=` on the face to reveal them all, if they're overlays and so on. Otherwise M-x customize-face. It should proffer the ones on point as options. Hit RET.
cradlemann · 2022-12-25 19:06
`describe-face`
ieure · 2022-12-25 19:51
This. Also `list-faces-display`.
00-11 · 2022-12-25 20:54
(I don't see any screenshots.) 1. If you can put the cursor on a char or buffer position that shows the face you're interested in then use `C-u C-x = RET` and see what face(s) it lists (near the bottom). 2. If you can't put the cursor on the face (or even if you can), you can use `M-x list-faces-display`.
o__J_O · 2022-12-25 22:04
Ugh, sorry about the missing images ... [https://imgur.com/a/BHLVJHT](https://imgur.com/a/BHLVJHT) Thank you! I'm going to give your suggestions a try!
o__J_O · 2022-12-25 22:24
Thank you for your response. * `M-x customize-apropos-faces` requires that I supply a REGEX for a face candidate. In one of my cases, it's a breadcrumb but the matching face samples don't match the background that I'd like to tweak. Is it possibly inherited from `font-lock-string-face`? When I `describe variable: font-lock-string-face` only the `Foreground` is set. * `M-x customize-group` presents many modes. I know that the breadcrumbs are part of `lsp-mode`. When I select the mode, I get oodles of options. I narrow down to those variables with "face". Still many, many faces. :) Nothing obvious. * I can't place `point` on the breadcrumb line so I can't use `C-u C-x = RET` :\\ \*\*\* Edit \*\*\* * Fixed markdown.
o__J_O · 2022-12-25 22:27
The default answer to the above is "default" Nothing relevant is provided. Next I tried ? and I received over 974 options to select. Hmmm.
o__J_O · 2022-12-25 22:29
~~I get 970 options to view .. :\\ ... however, none of them seem (it's hard to tell scrolling through them all) to match the breadcrumbs I'm trying to affect. I wonder if there's some inheritance coming in to play ....~~ I don't know what I was doing wrong before but you are 100% correct: `describe-face` I confirmed that `list-faces-display` gives me over 900 results. It seems every possible face. :[
[deleted] · 2022-12-26 01:10
[deleted]
CorysInTheHouse69 · 2022-12-26 03:19
`describe-face` is exactly this
o__J_O · 2022-12-26 03:25
Hi, `M-: (thing-at-point 'word)` is very cool. I get the following dump: #("stdout" 0 6 (fontified t face (tree-sitter-hl-face:variable highlight) xref-item #s(xref-item #(" run_stdout = run_stdout.rstrip()" 0 12 ... 12 22 ... 22 23 ... 23 24 ... 24 36 ... 36 42 ... 42 43 ... 43 44 ...) #s(xref-file-location "/home/is/here/file.py" 230 12)) mouse-face highlight keymap (keymap (mouse-2 . xref-select-and-show-xref) (mouse-1 . xref-goto-xref)) help-echo "mouse-2: display in another window, RET or mouse-1: follow reference")) If I parse the above correctly, it looks like the variable I need to check is `tree-sitter-hl-face` Does that sound right? For my other Use Case, I cannot put point on the breadcrumb line. It is acting like a mode line. Any idea how to get its font variable? Thank you so much!
o__J_O · 2022-12-26 03:28
Unfortunately I get over 900 faces dumped. Unfortunately it's not clear to me how to narrow it down to the face in question. `M-: (thing-at-point 'word)` seems to be the trick for when I can move `point`. My breadcrumb line acts line a mode line so I can't move `point` to it.
CorysInTheHouse69 · 2022-12-26 03:36
`describe-face` shouldn’t dump faces. It should bring up a search for what face you want, defaulting to the face at point
o__J_O · 2022-12-26 03:48
Hi, You're right. I made a mistake. Sorry about that. What's tricky is if I move point to the area in question, after X seconds, the font changes. I tried to run `describe-face` before the font changed but I don't think it got captured right. It says `tree-sitter-hl-face` and the sample is the after timeout value, What's interesting is that the dump also says it inherits `font-lock-variable-name-face` I think I have something to go on for this Use Case. Any thoughts on how I can do the same when I can't place `point` on a line (e.g. my breadcrumb line - acts like a mode line)?
CorysInTheHouse69 · 2022-12-26 03:52
One workaround would be to temporarily set `describe-face` to an immediate keybind to get it. In terms of getting the face of a modeline you might be out of luck. Best bet is looking at the source code, which is very easy because it’s emacs
o__J_O · 2022-12-26 03:54
Good thinking on the bind. While not an elisp hacker, I can recognize patterns. And can read comments. :)
DefiantAverage1 · 2022-12-26 06:55
If you can put your cursor on the face, `describe-char` will tell you all the faces applied
republic_of_mao · 2022-12-26 08:07
the title to this post is terrifying...
7890yuiop · 2022-12-27 01:26
> I can't place point on the breadcrumb line so I can't use `C-u C-x = RET` :\ I don't use lsp-mode, but perhaps it's using the header line for this? If so, then start with `C-h v header-line-format` in that buffer, and drill down from there as appropriate. Or evaluate `(format-mode-line header-line-format)` and inspect the result.