Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

keyboard regexp shortcuts

22 views
Skip to first unread message

Perry Smith

unread,
Aug 17, 2012, 10:20:20 AM8/17/12
to Emacs help
Very often, I do a regex search (M-C-s) of \_<foo\_> because I don't want to find bad_foo_dog.

Typing the \ _ < and \ _ > is tedious. Can someone suggest a way to make that easier?

Thank you,
Perry

signature.asc

Scott Frazer

unread,
Aug 17, 2012, 2:04:25 PM8/17/12
to help-gn...@gnu.org
Here's what I use:

(defun my-isearch-word ()
"Surround current input with word/symbol delimiters and turn on regexp matching if necessary."
(interactive)
(unless isearch-regexp
(isearch-toggle-regexp))
(setq isearch-string (concat "\\_<" isearch-string "\\_>")
isearch-message (mapconcat 'isearch-text-char-description isearch-string ""))
(isearch-search-and-update))

(define-key isearch-mode-map (kbd "M-w") 'my-isearch-word)



Jambunathan K

unread,
Aug 17, 2012, 2:54:37 PM8/17/12
to Scott Frazer, help-gn...@gnu.org
In development version of Emacs, there is a better way.

,---- NEWS
| * Editing Changes in Emacs 24.3
|
| ** Search changes
|
| *** Global `M-s _' starts a symbol (identifier) incremental search,
| and `M-s _' in Isearch toggles symbol search mode.
| `M-s c' in Isearch toggles search case-sensitivity.
`----



>
>
>
>

--

0 new messages