[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: does emacs support incremental searching for partial matches?
From: |
Stefan Monnier |
Subject: |
Re: does emacs support incremental searching for partial matches? |
Date: |
Wed, 23 Feb 2011 10:53:39 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> Hi Drew, thank you for your help!
> Sometimes I would be able to know the .* part, for example, I want to
> match WindowsMemoryCacheManagement by using 'memcache'. With regular
> expression, I have to specify .*m.*e.*m.*c.*a.*c.*h.*e.*
> Is there any command or plugin I can use?
It shouldn't be too difficult to write up a quick hack to do it, using
isearch-search-fun-function. Something like
(defconst my-isearch-re "[^\n\s\t]*?")
(defun my-isearch-search-fun ()
(if isearch-forward
(lambda (text bound noerror)
(re-search-forward (mapconcat 'string text my-isearch-re)
bound noerror))
(lambda (text bound noerror)
(re-search-backward (mapconcat 'string text my-isearch-re)
bound noerror))))
(defun my-search-end ()
(kill-local-variable 'isearch-search-fun-function)
(remove-hook 'isearch-mode-end-hook #'my-search-end 'local))
(defun my-isearch ()
"Like isearch but lets you omit chars."
(interactive)
(add-hook 'isearch-mode-end-hook #'my-search-end nil 'local)
(set (make-local-variable 'isearch-search-fun-function)
#'my-isearch-search-fun)
(isearch-forward))
-- Stefan "who actually tested his code this time ;-)"