From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: does emacs support incremental searching for partial matches? Date: Wed, 23 Feb 2011 10:53:39 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1298482852 32662 80.91.229.12 (23 Feb 2011 17:40:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 23 Feb 2011 17:40:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 23 18:40:46 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PsIhg-0001C4-Mj for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Feb 2011 18:40:44 +0100 Original-Received: from localhost ([127.0.0.1]:45909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsIhg-0006ae-5L for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Feb 2011 12:40:44 -0500 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Injection-Info: mx02.eternal-september.org; posting-host="QnW9b9xvWZtaXtFnkrsihQ"; logging-data="1344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fY3+EaG4bp27Zz5mTwmQC" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:UZue0Dm2xktYr/sjtTnS9ibmONA= sha1:13q1dS7l4c6c3XSVKZ0BzCiRPz8= Original-Xref: usenet.stanford.edu gnu.emacs.help:185238 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79390 Archived-At: > 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 ;-)"