4

font-lock-mode sets font lock for the entire buffer -- normally to provide syntax highlighting. Sometimes though, when I'm preparing a tutorial, I want to call attention out to certain lines. It would be great if I could underline them (M-o u with active region), but it has no effect with font-lock-mode.

How can I use or emulate M-o (facemenu-keymap) with font-lock-mode?

Sean Allred
  • 6,921
  • 18
  • 86

1 Answers1

5

Instead of the hack of using font-lock-face (which also means no highlighting unless font-lock is turned on), you can just use library Highlight (highlight.el).

It lets you highlight arbitrary text in many ways, using either text properties or overlays, and its highlighting is independent of font-lock highlighting. IOW, it gives you an easy way to keep font lock's hands off of your highlighting. You can even save such highlighting persistently, if you like.

Tobias
  • 33,167
  • 1
  • 37
  • 77
Drew
  • 77,472
  • 10
  • 114
  • 243
  • +1 Just out of curiosity, how does that package manage to work regardless of font-lock-mode? Does it just decide between font-lock-face and face depending on the situation, or is there some other trick? – Malabarba Dec 09 '14 at 13:46
  • @Malabarba: It uses property font-lock-ignore to tell font-lock: "Hands off!". Font lock should never have been allowed to, in effect, "take over" all uses of property face. See this thread on [email protected], where I proposed adding this feature to Emacs. – Drew Dec 09 '14 at 17:20