|
From: | Bastien |
Subject: | Re: Is there an easier way to jump to the same word? |
Date: | Thu, 11 Apr 2013 10:04:41 +0200 |
User-agent: | Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |