In my .emacs I have this neat piece of code which I found on PerlMonks a while ago. It allows me to list all occurrences of the current isearch-string by typing Ctrl-o while searching.
I-search is really, truly useful (and along with having dabbrev-expand bound to Alt-Space is something I'd like to have working in all programs I use). The function above is a nice twist.
One thing I've wanted for a long time though is to be able to I-search (using Ctrl-w to expand the search string until I found the proper match) and then copy the string into the clipboard (or killing it in Emacs-speak).
I wouldn't be surprised if it's possible to actually do that already, but I haven't found anything after quite a bit of searching. So I hacked together this by adapting the occurence code:
;; Kill from isearch
(defun isearch-kill-string ()
"Make the current isearch-string the latest kill in the kill ring."
(interactive)
(let ((case-fold-search isearch-case-fold-search))
(kill-new (if isearch-regexp isearch-string (regexp-quote isearch-string)))))
Feel free to code review the elisp, I'm sure it can be improved in one way or the other.
(define-key isearch-mode-map (kbd "C-k") 'isearch-kill-string)
Re:intent?
jplindstrom on 2006-11-07T10:59:01
Good point! I was looking for the equivalent of isearch-other-end but couldn't find anything among all the names.
Thanks!