inspired by the comments already provided (Charles’s answer doesn’t work the way I would like to), I added a new function to the isearch / isearch-regexp mode map, which puts only the match string in the annihilation ring (whereas Charles's sentence kills from the current point to the end matching string):
(defun hack-isearch-kill () "Push current matching string into kill ring." (interactive) (kill-new (buffer-substring (point) isearch-other-end)) (isearch-done)) (define-key isearch-mode-map (kbd "Mw") 'hack-isearch-kill)
The good thing about the isearch / isearch-regexp approach (which you can enable with Cs and CMs respectively) is that you can see your search string grow and you can copy it with Mw once you are satisfied (and go back to where you used to be with Cu C-Space ).
This works for me with Emacs 23.1. I don't know if this will work in all situations. In any case, I hope you find this useful :)
UPDATE: going through emacswiki, I came across KillISearchMatch , which offers more or less the same (plus a few more tips ...).
Cheers, Daniel
danielpoe
source share