From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: htbest2000 Newsgroups: gmane.emacs.help Subject: Re: How do I highlight word at point? Date: Mon, 20 Oct 2008 20:43:50 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1224382569.209484@nntp.acecape.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1224598849 5492 80.91.229.12 (21 Oct 2008 14:20:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 14:20: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 Tue Oct 21 16:21:47 2008 connect(): Connection refused 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 1KsI7G-0007Gv-GC for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 16:21:46 +0200 Original-Received: from localhost ([127.0.0.1]:37291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsI6A-0006C6-SK for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 10:20:38 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!l42g2000hsc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Original-NNTP-Posting-Host: 220.191.185.66 Original-X-Trace: posting.google.com 1224560631 11545 127.0.0.1 (21 Oct 2008 03:43:51 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 21 Oct 2008 03:43:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l42g2000hsc.googlegroups.com; posting-host=220.191.185.66; posting-account=vjPv_woAAACRbHlAUee1GeafN1KLQK6P User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:163626 X-Mailman-Approved-At: Tue, 21 Oct 2008 10:20:13 -0400 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:58979 Archived-At: On 10=D4=C219=C8=D5, =C9=CF=CE=E710=CA=B116=B7=D6, Wei Weng wrote: > The title pretty much said it. :) > > Thanks > Wei place the following code into your .emacs file and ; code begin (defvar my-highlight-current-word-color-index 0 "the color index increaser") (defvar my-highlight-current-word-color-list (list 'hi-yellow 'hi-pink 'hi-blue 'hi-green 'hi-red) "color list") (defun my-highlight-current-word () "highlight current word" (interactive) (highlight-regexp (current-word) (nth my-highlight-current-word-color-index my-highlight-current-word-color-list)) (incf my-highlight-current-word-color-index) (when (=3D my-highlight-current-word-color-index 4) (setq my-highlight-current-word-color-index 0))) (defun my-unhighlight-current-word () "un-highlight current word" (interactive) (unhighlight-regexp (current-word))) ;ESC-C-f8 to highlight ;ESC-ESC-C-f8 to unhighlight (global-set-key (quote [27 C-f8]) (quote ht-highlight-current-word)) (global-set-key (quote [27 27 C-f8]) (quote ht-unhighlight-current- word)) ; code end ESC-C-f8 or M-x my-highlight-current-word to highlight word in cursor, ESC-ESC-C-f8 or M-x my-unhighlight-current-word to un-highlight the color will be varied if you repeat highlight operate.