joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.81k stars 311 forks source link

Add a face for other fields #735

Open fniessen opened 8 years ago

fniessen commented 8 years ago

Would it be possible to add a face (yas-other-fields-highlight-face or such) and to highlight all non-selected fields?

The idea would be that:

  1. $1 gets highlighted with yas-field-highlight-face, while $2 and $3 get highlighted with yas-other-fields-highlight-face; then
  2. $2 gets highlighted with yas-field-highlight-face, while $1 and $3 get highlighted with yas-other-fields-highlight-face; then
  3. $3 gets highlighted with yas-field-highlight-face, while $1 and $2 get highlighted with yas-other-fields-highlight-face.

That would make the variable elements in the template stand out a lot more.

Thanks a lot!

npostavs commented 8 years ago

Sounds doable. I'm thinking to do it in a slightly simpler way: give all of $1, $2, $3 yas-field-face (this would probably use the :box attribute by default), and the current field will additionally get yas-field-highlight-face (as it does now).

joaotavora commented 8 years ago

@npostavs, how would you do it? with an overlay? Those would have to be cleaned up, remember. Anything else might clash with the syntax highlighting, be it font-lock or simple text properties.

Yasnippet has once worked like this (before 0.6 though, I think), but I found it was distracting and clashed with the natural syntax highlighting. This way was much simpler, and also imitated TextMate better.

npostavs commented 8 years ago

Uh, I had thought fields already have overlays on them, but if not, this might indeed involve more complexity than I'd want to add for such a feature.

Yasnippet has once worked like this (before 0.6 though, I think), but I found it was distracting and clashed with the natural syntax highlighting. This way was much simpler, and also imitated TextMate better.

Eclipse uses :box style "highlighting" of fields, I think it looks reasonable.

fniessen commented 8 years ago

Thanks for improving this. I'll love it!

joaotavora commented 8 years ago

@fniessen, if it were up to me (but it isn't anymore) I wouldn't get my hopes up. Adding this feature needlessly bloats yasnippet's sensitive engine.