[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set X primary selection with Emacs in xterm

From: Duncan Findlay
Subject: Re: Set X primary selection with Emacs in xterm
Date: Tue, 14 Jun 2022 19:43:21 -0700

On Sat, Jun 11, 2022 at 9:16 AM Jean Louis <bugs@gnu.support> wrote:
> > > > Similarly, if I select text with mark and keyboard (or mouse with
> > > > xterm-mouse-mode), I'd like it to update my local X's primary
> > > > selection so I can middle-click to paste it elsewhere. I have two
> > > > patches attached that got this working for me.
> > >
> > > For me your explained situation works without patches. I have the
> > > above settings. But I may miss something as you mention
> > > xterm-mouse-mode which I am not even using it ever. On my side it
> > > works.
> >
> > Sorry, I should have been more precise.
> >
> > I would like the primary selection to be updated with the contents of
> > the region, as described here:
> > https://www.gnu.org/software/emacs/manual/html_node/emacs/Primary-Selection.html
> >
> > This requires `select-active-regions' to be non-nil. Do you have this
> > set in your configuration?
> Yes, it is T in my configuration.
> When I select region, I can use second (among three) mouse button to
> insert selection into XTerm.

Oh, I think I see what you mean. With your configuration I can select
text in emacs with mouse and paste with mouse into emacs or other
programs, but this is handled entirely by xterm. AIUI emacs is not
made aware of the selection and has no control over this.

If I make an active region with the keyboard (e.g. C-SPC, C-p), the
text shows as highlighted in emacs, but it does not update my primary
selection buffer unless I kill it, and it cannot be pasted with the
middle mouse button until it's killed. (Text highlighted by emacs is a
different color than text highlighted by xterm with my current config;
I'm not sure if this is default.) My patch fixes this, though it's a
pretty minor issue IMO.

The bigger benefit of my patch comes with xterm-mouse-mode enabled. In
this mode, most mouse events are passed through to Emacs, and are not
handled by Xterm itself. Without my patch, selecting text with the
mouse highlights it, but it doesn't update the primary selection and
can't be pasted with middle click. With my patch, the selected text
can be pasted into other programs with middle click. Pasting from
primary selection back into Emacs with middle-click requires xterm
getSelection support (haven't tried this yet) or Shift-MiddleClick
(handled by XTerm itself), though this is unaffected by my change.

With `xterm-select-active-regions' set to nil (default), my patch will
have no effect.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]