From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: Text highlighter functiontionality Date: Thu, 23 Jul 2009 15:25:57 +0300 Organization: A noiseless patient Spider Message-ID: <87skgnlh62.fsf@iki.fi> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1248352909 23521 80.91.229.12 (23 Jul 2009 12:41:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jul 2009 12:41:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 23 14:41:43 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MTxcF-0005TE-EW for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Jul 2009 14:41:43 +0200 Original-Received: from localhost ([127.0.0.1]:37519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTxcE-0002v8-Kv for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Jul 2009 08:41:42 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!feeder.eternal-september.org!eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 29 Original-X-Trace: news.eternal-september.org U2FsdGVkX1+x21LbM2qyb8OLWkdR02XFUjx27GAcNYCbhSTLiVp/HR+bnJibzK+9Y8H6pahQ6v08aR5o1Q9kpiLlCeF/J0Xxa0biCwoibMgBZsFMrg8hlDBqwaZnZke7JAShX+6kZLTD/u8MsTk/GnDhpZhmD6fp Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Thu, 23 Jul 2009 12:32:39 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19G6wKd5hVHYgMquCU6gBS+74Uwwhey1CVphLs+1AWZZg== Cancel-Lock: sha1:7esY6EQBFqhw9gbpfCmR57OqX+A= sha1:XJjVeJ8SYBe+LyOjKtmxLRX4oUo= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:171163 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:66353 Archived-At: On 2009-07-23 04:44 (-0700), stephan zimmer wrote: > Is anyone aware of a text highlighter functionality in emacs? I would > like to highlight (possibly non-connected) portions of text in a > buffer in such a way, that the highlighting persists within one emacs > session (i.e., when I change the buffer and return to it again, the > highlighting should still be there). Sounds pretty much like "M-s h r" (highlight-regexp) to me. But if you want to mark a region and highlight it you could use a simple function to create an overlay. Here's an example function which highlights current active region. You can remove the highlighting by just editing text inside it. --8<---------------cut here---------------start------------->8--- (defun my-overlay (beg end) "Create an overlay between BEG and END. If called interactively BEG and END are the region." (interactive "r") (require 'hi-lock) (let ((ol (make-overlay beg end))) (dolist (prop '((modification-hooks (lambda (ol after &rest ignore) (when after (delete-overlay ol)))) (face . hi-yellow) (evaporate . t))) (overlay-put ol (car prop) (cdr prop))))) --8<---------------cut here---------------end--------------->8---