[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: |
Fri, 11 Nov 2011 17:01:06 -0800 |
No, I am not certain this is a bug - you decide.
In `isearch-mode-map', `isearch-mouse-2' is bound to `mouse-2' and
`down-mouse-2' is bound to nil.
`isearch-mouse-2':
(defun isearch-mouse-2 (click)
"Handle mouse-2 in Isearch mode.
For a click in the echo area, invoke `isearch-yank-x-selection'.
Otherwise invoke whatever the calling mouse-2 command sequence
is bound to outside of Isearch."
(interactive "e")
(let* ((w (posn-window (event-start click)))
(overriding-terminal-local-map nil)
(binding (key-binding (this-command-keys-vector) t)))
(if (and (window-minibuffer-p w)
(not (minibuffer-window-active-p w))) ; in echo area
(isearch-yank-x-selection)
(when (functionp binding)
(call-interactively binding)))))
I globally bind `down-mouse-2' to a command of mine,
`mouse-flash-position-or-M-x', which highlights the yank position (or
calls `M-x' in the echo area). The highlighting intentionally happens
only while the mouse button is pressed.
Because of this global binding, I need to change the `isearch-mode-map'
binding of `down-mouse-2' to `ignore'. Dunno whether a binding of
`ignore' makes better sense for vanilla Emacs here too (e.g., in case
someone binds `down-mouse-2' globally).
However, that is not sufficient, to be able to use `mouse-2' with
Isearch. Perhaps because of some selection setting I have, with my
setup (on MS Windows) `x-get-selection' just returns nil.
That means that `isearch-mouse-2' barfs when it calls
`isearch-yank-selection'. That function tries to yank the string
returned by `x-get-selection', but that function returns nil, not a
string. The PRIMARY selection is not set, at least in my context.
This function apparently depend ons it being set. Seems like a
bug, to me.
To fix this, I use a hack like this in `isearch-mouse-2'. Dunno
what the right fix for vanilla Emacs would be.
(when (and transient-mark-mode (/= (region-beginning) (region-end)))
(x-set-selection 'PRIMARY (buffer-substring-no-properties
(region-beginning) (region-end)))
(deactivate-mark)
(isearch-yank-x-selection))
Consider this only an FYI. I suspect there is a problem, and that the
`isearch-mouse-2' code should not depend on the PRIMARY selection being
set, but you decide.
In GNU Emacs 24.0.91.1 (i386-mingw-nt5.1.2600) of 2011-11-07 on MARVIN
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.6) --no-opt --cflags
-I"D:/devel/emacs/libs/libXpm-3.5.8/include"
-I"D:/devel/emacs/libs/libXpm-3.5.8/src"
-I"D:/devel/emacs/libs/libpng-dev_1.4.3-1/include"
-I"D:/devel/emacs/libs/zlib-dev_1.2.5-2/include"
-I"D:/devel/emacs/libs/giflib-4.1.4-1/include"
-I"D:/devel/emacs/libs/jpeg-6b-4/include"
-I"D:/devel/emacs/libs/tiff-3.8.2-1/include"
-I"D:/devel/emacs/libs/gnutls-2.10.1/include" --ldflags
-L"D:/devel/emacs/libs/gnutls-2.10.1/lib"'
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc.,
Drew Adams <=
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Stefan Monnier, 2011/11/11
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Drew Adams, 2011/11/12
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Stefan Monnier, 2011/11/12
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Drew Adams, 2011/11/13
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Stefan Monnier, 2011/11/18
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Drew Adams, 2011/11/18
- bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc., Stefan Monnier, 2011/11/18