0

Are there tools for highlighting by context? When writing my configuration code, I constantly get into the difficulty of figuring out where in the different block of code I am modifying. Looking for any modes that could highlight the section around the cursor that forms part of a syntactic structure. For instance, highlight the pcase section when modifying that section.

Drew
  • 75,699
  • 9
  • 109
  • 225
Dilna
  • 1,173
  • 3
  • 10

1 Answers1

0

You don't specify what you mean by "highlighting".

If you mean select as the active region (which also lets C-x C-x take you to its start/end), then this can help:

If you use library thing-cmds.el (code) then you can select lists that enclose point using command select-enclosing-list-backward (bound to C-M-B if you use command thgcmd-bind-keys).

Repeating the command selects wider and wider enclosing lists. E.g., you're somewhere inside a pcase sexp. You repeat C-M-B till it selects the pcase sexp.


If you mean highlight so the highlighting (face) remains, then first use C-M-B as above, then use a highlighting command to highlight the region. If you use library highlight.el (code) then you can use command hlt-highlight-region to do that. It's bound by default to C-x X h x. (All keys defined by the library are on keymap hlt-map, which is bound by default to prefix key C-x X.)

Drew
  • 75,699
  • 9
  • 109
  • 225
  • Not highlighting that remains, but is done near the cursor (highlighting nearby context), which gets deactivated and focused somewhere else as the cursor is moved through the code. For elisp I have found `highlight-sexp`. – Dilna Jun 19 '22 at 19:14
  • 1. Put all info to specify your question into the question. Don't flesh out your question in comments. 2. Don't change/evolve the question, especially after there are answers to the it as originally posed. Instead, pose a new question. – Drew Jun 19 '22 at 21:38
  • If you want to always have a sexp at point highlighted (till you turn off the mode), then maybe that's what you want. If you instead want to highlight a sexp at point on demand (and repeat to widen the sexp at point that's used) then what I described might be what you want. – Drew Jun 19 '22 at 21:40
  • 1
    That's an interesting though, will try it. – Dilna Jun 20 '22 at 02:49
  • 1
    @Dilna if this answered your question, please mark it as an answer for future users of the site. If your solution required modifications from this, please add your own answer to the question, then mark it as an answer for future users of the site. Thank you. – Trevoke Jul 15 '23 at 00:48