From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>
Cc: 10022@debbugs.gnu.org
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 [thread overview]
Message-ID: <80F2D45C3F624FCC918B30031333293C@us.oracle.com> (raw)
In-Reply-To: <jwv39dtl6vz.fsf-monnier+emacs@gnu.org>
> 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.
next prev parent reply other threads:[~2011-11-13 20:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-12 1:01 bug#10022: 24.0.91; `isearch-mouse-2' relies on `x-get-selection' - NG for Windows etc Drew Adams
2011-11-12 3:03 ` Stefan Monnier
2011-11-12 7:06 ` Drew Adams
2011-11-12 15:04 ` Stefan Monnier
2011-11-13 20:22 ` Drew Adams [this message]
2011-11-18 17:30 ` Stefan Monnier
2011-11-18 18:02 ` Drew Adams
2011-11-18 19:13 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=80F2D45C3F624FCC918B30031333293C@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=10022@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).