From: Bastien <bzg@altern.org>
To: Steven Degutis <sbdegutis@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: Is there an easier way to jump to the same word?
Date: Thu, 11 Apr 2013 10:04:41 +0200 [thread overview]
Message-ID: <87mwt5wl0m.fsf@bzg.ath.cx> (raw)
In-Reply-To: <CACeWA3izDrWBEScWa5f96bw42zR_XZuKrvFnoZmtO2R=ezYKrA@mail.gmail.com> (Steven Degutis's message of "Wed, 10 Apr 2013 21:24:17 -0500")
Hi Steven,
Steven Degutis <sbdegutis@gmail.com> writes:
> Is there a better way to do this?
I use this:
(defun next-word-at-point (previous)
"Jump to the next occurrence of the word at point."
(interactive "P")
(let* ((w (thing-at-point 'word))
(w (mapconcat
(lambda(c) (if (eq (char-syntax c) ?w)
(char-to-string c))) w ""))
(wre (concat "\\<" w "\\>"))
(s (if previous #'re-search-backward #'re-search-forward)))
(unless previous (forward-word 1))
(funcall s wre nil t)
(unless previous (re-search-backward wre nil t))))
(defun previous-word-at-point ()
"Jump to the previous occurrence of the word at point."
(interactive)
(next-word-at-point t))
(define-key global-map "\M-n" 'next-word-at-point)
(define-key global-map "\M-p" 'previous-word-at-point)
--
Bastien
next prev parent reply other threads:[~2013-04-11 8:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-11 2:24 Is there an easier way to jump to the same word? Steven Degutis
2013-04-11 7:11 ` Andreas Röhler
2013-04-11 7:35 ` Le Wang
2013-04-11 13:39 ` Jambunathan K
2013-04-11 14:09 ` Steven Degutis
2013-04-11 14:06 ` Steven Degutis
2013-04-11 8:04 ` Bastien [this message]
2013-04-11 14:13 ` Steven Degutis
2013-04-13 0:19 ` Bastien
2013-04-13 0:22 ` Steven Degutis
2013-04-11 13:42 ` Jambunathan K
2013-04-11 14:08 ` Steven Degutis
2013-04-11 17:06 ` Jambunathan K
[not found] <mailman.23929.1365647063.855.help-gnu-emacs@gnu.org>
2013-04-11 7:43 ` Chris F.A. Johnson
2013-04-11 7:57 ` Damien Wyart
2013-04-11 8:22 ` Chris F.A. Johnson
2013-04-11 14:05 ` Steven Degutis
[not found] ` <878v4omosz.fsf@casenave-pere.fr>
2013-04-12 5:50 ` Renaud Casenave-Péré
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwt5wl0m.fsf@bzg.ath.cx \
--to=bzg@altern.org \
--cc=help-gnu-emacs@gnu.org \
--cc=sbdegutis@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.