all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Search function that ignores some characters
@ 2011-12-09 19:09 tony-au
  2011-12-09 19:34 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: tony-au @ 2011-12-09 19:09 UTC (permalink / raw
  To: Emacs-devel


Hello,
I would like to implement a search function that ignores some characters
(like these
characters { '.', ',' , 'X'}). So if I search "word", the function should
not
only find "word" but also "wor.d", "wo,rd.", "w,,o..X,r..d", and so
on. That means I want to search w[.,X]*o[.,X]*r[.,X]d as a regexp.

The function my-regexp produces the regexp and insert it into the buffer 
(defun my-regexp (&optional regexp-p no-recursive-edit)
  (interactive "P\n")
  (setq str (read-from-minibuffer
	     "the word: "))
  (insert-before-markers
   (mapconcat (lambda (c) (regexp-quote (string c))) str "[.,X]*"))
  )

But then I have to kill the produced regexp from the buffer and insert it
into the minibuffer of "C-M-s" (Regexp I-search). 
This is not really comfortable. How can directly insert the regexp (in the
example: w[.,X]*o[.,X]*r[.,X]d) into the minibuffer of (Regexp I-search)?

-- 
View this message in context: http://old.nabble.com/Search-function-that-ignores-some-characters-tp32944985p32944985.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Search function that ignores some characters
  2011-12-09 19:09 Search function that ignores some characters tony-au
@ 2011-12-09 19:34 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2011-12-09 19:34 UTC (permalink / raw
  To: 'tony-au', Emacs-devel

> I want to search w[.,X]*o[.,X]*r[.,X]d as a regexp.

If you use that particular regexp a lot, you can save it as the value of a
register, and use `M-e' followed by `C-x r i' in regexp isearch to use it as the
search pattern.


(If you use Icicles, you can also assign the pattern to a variable and then use
`C-=' to insert it after hitting `M-e' in isearch.
http://www.emacswiki.org/emacs/Icicles_-_Inserting_a_Regexp_from_a_Variable_or_R
egister) 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-09 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-09 19:09 Search function that ignores some characters tony-au
2011-12-09 19:34 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.