Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In emacs 24.1, when you do Ctrl-Y in an interactive search, it yanks the kill buffer into the search string ("it pastes the clipboard contents" in any-other-app's language) and tries to match it.

In the last 20 versions or so, pressing Ctrl-Y matches the rest of the current line. I have two very common use cases:

  1. Match this line, revert the buffer, and search for the line

  2. (less often:) Where else is this text in the buffer?

I tried modifying /lisp/isearch.el, switching the bindings for isearch-yank-line (which I want) and isearch-yank-kill (which I'm fine binding to the ridiculous \M-s\C-e key sequence). But I don't think this file even gets picked up. But I don't think this file even gets loaded. If I explicitly load it, I still get the 24.1 behavior.

Here's my change:

(add-hook 'isearch-mode-hook
   (lambda ()
     (define-key isearch-mode-map    "\C-y" 'isearch-yank-line)
     (define-key isearch-mode-map "\M-s\C-e" 'isearch-yank-kill)

No change in the behavior. I even tried hacking isearch.el, still no change.

This is on Windows btw, but I suspect it doesn't matter.

Could someone tell me how I can restore the old binding?

share|improve this question

what works for me is taking your hook and combining it with my own isearch-mode-hook.

(you could put this in ~/.emacs … i go a bit further and keep separate modes in ~/.emacs.el/.modes.el, then byte-compile that file, then (load ".modes" t t) to keep things a bit less cluttered.)

(setq isearch-mode-hook
      '(lambda nil
     (define-key isearch-mode-map "\C-y"   'isearch-yank-line)
     (define-key isearch-mode-map "\C-f"   'isearch-repeat-forward)
     (define-key isearch-mode-map "\C-t"    'isearch-toggle-regexp)))

works like a charm. thanks for helping my get my ^Y back

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.