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) >