help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keyboard regexp shortcuts


From: Scott Frazer
Subject: Re: keyboard regexp shortcuts
Date: Fri, 17 Aug 2012 14:04:25 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0

On 8/17/12 10:20 AM, Perry Smith wrote:
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


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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]