Skip to content

@pipping /gist:8547615
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(defmacro sacha/def-wordsearch (name docstring skip-syntax-function re-search-function)
`(defun ,name ()
,docstring
(interactive)
(let ((cur (point)))
(,skip-syntax-function "w_")
(let ((current-word (current-word)))
(message "Searching for word: %s" current-word)
(goto-char
(if (,re-search-function
(concat "\\_<" (regexp-quote current-word) "\\_>") nil t)
(match-beginning 0)
cur))))))
(sacha/def-wordsearch sacha/search-word-forward
"Find the next occurrence of the current word."
skip-syntax-forward re-search-forward)
(sacha/def-wordsearch sacha/search-word-backward
"Find the previous occurrence of the current word."
skip-syntax-backward re-search-backward)
(global-set-key '[M-up] 'sacha/search-word-backward)
(global-set-key '[M-down] 'sacha/search-word-forward)
@pipping
Owner

Note: This also turns the body of both functions into a macro and introduces a call to message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.