Emacs region highlighting

六眼飞鱼酱① 提交于 2019-12-30 09:58:09

问题


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


回答1:


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

Both MarkerPens and Highlight provide functions to highlight a region.




回答2:


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".



来源:https://stackoverflow.com/questions/491257/emacs-region-highlighting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!