tags:

views:

490

answers:

2

Is there a way to highlight a string in a text (but not ALL such strings) in a buffer where font-lock-mode is on.

Let's imagine I have a buffer with SQL mode and I want to highlight a string in it. The following code does not work

(set-text-properties 10 20 '(face hi-yellow))

When I call

(font-lock-mode -1)

it works, but all sql highlighting disappears.

There must be a solution because it's possible to select a region and it will be highlighted but I can't figure out how to do it programmatically

+3  A: 

Have a look at http://www.emacswiki.org/emacs/HighlightTemporarily.

Both MarkerPens and Highlight provide functions to highlight a region.

danielpoe
A: 

Maybe this helps:

  • open **scratch buffer and enter:

(with-current-buffer "foo" (add-text-properties 1 10 '(comment t face highlight)))
  • then evaluate with C-j

Characters 1-10 will be highlited in buffer "foo".

kliketa