From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steven Degutis Newsgroups: gmane.emacs.help Subject: Re: Is there an easier way to jump to the same word? Date: Thu, 11 Apr 2013 09:05:18 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6764b8cec97104da1646a3 X-Trace: ger.gmane.org 1365689157 4741 80.91.229.3 (11 Apr 2013 14:05:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Apr 2013 14:05:57 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: cfajohnson@gmail.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 11 16:05:59 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UQI8U-0004gi-LH for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Apr 2013 16:05:58 +0200 Original-Received: from localhost ([::1]:50825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQI8U-0003f3-82 for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Apr 2013 10:05:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQI7y-0003cL-Dd for help-gnu-emacs@gnu.org; Thu, 11 Apr 2013 10:05:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQI7r-0007gT-VU for help-gnu-emacs@gnu.org; Thu, 11 Apr 2013 10:05:26 -0400 Original-Received: from mail-pb0-f42.google.com ([209.85.160.42]:64926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQI7r-0007gJ-N1 for help-gnu-emacs@gnu.org; Thu, 11 Apr 2013 10:05:19 -0400 Original-Received: by mail-pb0-f42.google.com with SMTP id up7so874167pbc.15 for ; Thu, 11 Apr 2013 07:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=PtNieC30DyCPsAF2W/BrVn+oTJOHAuc4nWB9oW9Zum0=; b=BaneZFj/8HbHMRpGIOnLjVhkksMhAqyg2oARneGfO0KMHYgE8V9jHn1JOkGqberPMj Ds3nLy2nPaeVlU2R1l/rMX4y8o7LX1ffnyu7bWB4liyMZ2Vxpzgq6LG2V+TmR4+6TDUE iOlqyjY51uulEY2gYzigijJeQU2Pd6VQDfjjU5/qNK3IirjuSB4HDzDkAzlpKAIwKozn RxuLwS9tXsVhD/IIA32tVU4vW3WNch4ND1SDlF3aeNQwhnyylHgMeXXNljtEA6HmjI8/ aCrixxD5eyUN30QSneJZQBfrX6jB/0YMwA+hr2/ybXPdmzpLB+nIggNGDyaAPqepRX72 aQHA== X-Received: by 10.68.105.5 with SMTP id gi5mr8862197pbb.180.1365689118933; Thu, 11 Apr 2013 07:05:18 -0700 (PDT) Original-Received: by 10.70.24.197 with HTTP; Thu, 11 Apr 2013 07:05:18 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.42 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90098 Archived-At: --047d7b6764b8cec97104da1646a3 Content-Type: text/plain; charset=ISO-8859-1 This was the simplest and most elegant. But I didn't realize until after I tried it that I heavily rely on the highlighting that isearch-mode uses. -Steven On Thu, Apr 11, 2013 at 3:22 AM, Chris F.A. Johnson wrote: > On 2013-04-11, Chris F.A. Johnson wrote: > > On 2013-04-11, Steven Degutis wrote: > >> --047d7b67031bbb272504da0c7ba5 > >> Content-Type: text/plain; charset=ISO-8859-1 > >> > >> Often times I find that I want to jump to another occurrence of the > >> word-under-point, almost always variables or functions. I end up going > to > >> the beginning of the word with M-b, doing isearch-forward with C-s, > adding > >> all the words until the full word is the search term with C-w a bunch of > >> times, and finally C-s to jump around to other instances of it. > >> > >> Is there a better way to do this? > > > > This is what I use: > > > > (defun current-word-search () > > "search forward for word under cursor" > > (interactive) > > (word-search-forward (current-word))) > > And to search backwards: > > (defun current-word-reverse-search () > "search backwards for word under cursor" > (interactive) > (word-search-backward (current-word))) > > And, of course, they are bound to keys: > > (global-set-key (kbd "s-s") 'current-word-search) > (global-set-key (kbd "s-r") 'current-word-reverse-search) > > > -- > Chris F.A. Johnson > Author: ======================= > Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) > Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) > --047d7b6764b8cec97104da1646a3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
This was the simplest and most elegant. But I didn't r= ealize until after I tried it that I heavily rely on the highlighting that = isearch-mode uses.

-Steven


On Thu, Apr 11, 2013 at 3:22 AM, Chris F= .A. Johnson <cfajohnson@gmail.com> wrote:
On 2013-04-11, Chris F.A. Johnson wrote:
> On 2013-04-11, Steven Degutis wrote:
>> --047d7b67031bbb272504da0c7ba5
>> Content-Type: text/plain; charset=3DISO-8859-1
>>
>> Often times I find that I want to jump to another occurrence of th= e
>> word-under-point, almost always variables or functions. I end up g= oing to
>> the beginning of the word with M-b, doing isearch-forward with C-s= , adding
>> all the words until the full word is the search term with C-w a bu= nch of
>> times, and finally C-s to jump around to other instances of it. >>
>> Is there a better way to do this?
>
> =A0 =A0This is what I use:
>
> (defun current-word-search ()
> =A0 =A0 "search forward for word under cursor"
> =A0 =A0 (interactive)
> =A0 =A0 (word-search-forward (current-word)))

=A0 And to search backwards:

(defun current-word-reverse-search ()
=A0 =A0 "search backwards for word under cursor"
=A0 =A0 (interactive)
=A0 =A0 (word-search-backward (current-word)))

=A0 And, of course, they are bound to keys:

(global-set-key (kbd "s-s") 'current-word-search)
(global-set-key (kbd "s-r") 'current-word-reverse-search)


--
=A0 =A0Chris F.A. Johnson =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<http://cfajohnso= n.com>
=A0 =A0Author: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D
=A0 =A0Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) =A0 =A0Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)<= br>

--047d7b6764b8cec97104da1646a3--