[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG f
From: |
Drew Adams |
Subject: |
bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc. |
Date: |
Sun, 13 Nov 2011 12:22:51 -0800 |
> Steps to reproduce it, please.
As I said in the OP:
"No, I am not certain this is a bug - you decide.
...
Consider this only an FYI."
In case it helps, digging into this more shows that setting the X selection
explicitly is necessary for the code to work also with older Emacs versions.
That is not necessary for Emacs 24.
FWIW, I use this, which gives users the option to not have to move the mouse to
the echo area to yank the selection. Option `isearchp-mouse-2-flag' is t by
default.
(defun isearch-mouse-2 (click)
"Handle `mouse-2' in Isearch mode.
If `isearchp-mouse-2-flag' is non-nil, yank the X selection.
If `isearchp-mouse-2-flag' is nil, yank it only if the `mouse-2' click
is in the echo area. Otherwise, invoke whatever `mouse-2' is bound to
outside of Isearch."
(interactive "e")
(if (not isearchp-mouse-2-flag)
(let ((win (posn-window (event-start click)))
(overriding-terminal-local-map nil)
(binding
(key-binding (this-command-keys-vector) t)))
(if (and (window-minibuffer-p win)
(not (minibuffer-window-active-p win))) ; In echo area
(isearchp-set-sel-and-yank)
(when (functionp binding) (call-interactively binding))))
(when (/= (region-beginning) (region-end))
(isearchp-set-sel-and-yank))))
(defun isearchp-set-sel-and-yank ()
"Set X selection and yank it into echo area."
(x-set-selection 'PRIMARY (buffer-substring-no-properties
(region-beginning) (region-end)))
(deactivate-mark)
(isearch-yank-x-selection))
If it were not for needing the code to work with older Emacs versions, all that
would be needed would be this:
(defun isearch-mouse-2 (click)
"..."
(interactive "e")
(if (not isearchp-mouse-2-flag)
(let ((win (posn-window (event-start click)))
(overriding-terminal-local-map nil)
(binding
(key-binding (this-command-keys-vector) t)))
(if (and (window-minibuffer-p win)
(not (minibuffer-window-active-p win))) ; In echo area
(isearch-yank-x-selection)
(when (functionp binding) (call-interactively binding))))
(when (/= (region-beginning) (region-end))
(let ((select-active-regions t))
(deactivate-mark)
(isearch-yank-x-selection)))))
The binding of `select-active-region' is needed, however. Without that (and
with a customized setting of nil), `get-x-selection' returns nil - the problem I
mentioned earlier.
HTH.