|
From: | Steven Degutis |
Subject: | Re: Is there an easier way to jump to the same word? |
Date: | Thu, 11 Apr 2013 09:13:40 -0500 |
Hi Steven,
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
[Prev in Thread] | Current Thread | [Next in Thread] |