When I search with C-s, I can paste a search term (copied outside of emacs frame) with either M-y or mouse-2 click focused inside echoarea. In xemacs it is enough to mouse-2 click inside the main buffer to get the yank happen inside the echoarea. In emacs I have to mouse-2 click inside the tiny echoarea for this to work.

Is there a way to configure emacs to get mouse-2 click in the main frame to replicate M-y-functionality when isearch (C-s) is activated?

The only related custom configuration I have is:

;; paste where the mouse clicks
(setq mouse-yank-at-point nil)

but it doesn't seem to have any impact on what I'm trying to accomplish here.

I suppose I need to get mouse-2 to be re-bound to isearch-yank-kill when in isearch, but I don't know how to do that.

And I read the explanation about echoarea not being a minibuffer, but I don't have enough emacs knowledge to do anything useful with it.

2 Answers 2


You can do this if you use Isearch+. User option isearchp-mouse-2-flag is t by default, giving you that behavior.

Someone who doesn't want the behavior can just customize the option to nil. C-h v isearchp-mouse-2-flag tells you:

isearchp-mouse-2-flag is a variable defined in isearch+.el.

Its value is t


Non-nil means clicking mouse-2 during Isearch yanks the selection.

In that case, you can select text with the mouse, then hit C-s to search for it.

If the value is nil, yank only if the mouse-2 click is in the echo area. If not in the echo area, invoke whatever mouse-2 is bound to outside of Isearch.

You can customize this variable.

  • Thank you, @Drew. I can't make it to work though. I created .emacs with just (require 'isearch) (eval-after-load "isearch" '(require 'isearch+)) (eval-after-load "isearch" '(require 'isearch-prop)) and it doesn't do what you suggested. No loading errors, other than isearch-prop.el: ‘condition-case-no-debug’ is an obsolete alias (as of 24.1); use ‘condition-case-unless-debug’ instead. [3 times]. If I do C-h v there is no isearchp-mouse-2-flag. I do see other isearchp- symbols, so the package loaded. emacs-26.1 here. And isearchp-mouse-2-flag is in isearch+.el file.
    – stason
    Aug 29, 2018 at 18:23
  • 1. The condition-case* thing is a benign warning - ignore it. 2. You don't need to explicitly require isearch - it is loaded by Emacs. 3. You don't need the explicit eval-after* thing for isearch-prop - that library is loaded automatically if you load isearch+.el. 4. You don't need isearch-prop.el at all, for this question. 5. You can see that isearchp-mouse-2-flag is defined in isearch+.el. 6. Try just emacs -Q (no init file), then M-x load-library isearch+. I'm sure you'll have the variable - check its spelling. (The library needs to be in your load-path, of course.)
    – Drew
    Aug 29, 2018 at 19:51
  • Thank you for all the items, @Drew - I have tried all to no avail. I load the library just fine as with (6). After peforming (6) I do 1. copy a word outside of emacs 2. Hit C-s followed by mouse-2 click inside the main frame results in yank/paste of the copied word inside the main frame, same as it was before loading isearch+.
    – stason
    Aug 29, 2018 at 20:37
  • C-h v shows isearchp-mouse-2-flag to be set to t, but it doesn't work. It neither searches for the mouse selected word before hitting C-s (as the doc suggests), nor it allows pasting inside the frame to do the same, instead it just activates mouse-2 which just yanks it into the main frame.
    – stason
    Aug 29, 2018 at 21:55
  • Not sure what you mean by speaking of frames, here. In the same window, do this: (1) Select some text with the mouse. (2) C-s. (3) Click mouse-2. The selected text will be added to the search string. That's all. You get the same effect by selecting text, then M-w (copy it to the kill-ring), then C-s, then M-y.
    – Drew
    Aug 29, 2018 at 21:57

After studying isearch.el for some time I solved this by adding to my emacs config file:

;; override isearch-mouse-2, which requires clicking in the echo area
;; to yank, to have the same behavior clicking anywhere in the main
;; buffer
(define-key isearch-mode-map [mouse-2] 'isearch-yank-x-selection)

Now it behaves like xemacs. Fantastic!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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