emacs-devel
[Top][All Lists]
Advanced

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

Re: Additional cleanup around xterm-mouse


From: Jared Finder
Subject: Re: Additional cleanup around xterm-mouse
Date: Thu, 19 Nov 2020 00:03:30 -0800
User-agent: Roundcube Webmail/1.3.15

On 2020-11-18 9:40 am, Eli Zaretskii wrote:
Date: Sun, 15 Nov 2020 22:29:20 -0800
From: Jared Finder <jared@finder.org>
Cc: emacs-devel@gnu.org

Creating such an alternative function doesn't appear too bad if you're
okay with having the same run-with-idle-timer pattern that read-key
uses. I do not think it can be xterm specific as it needs to apply all of input-decode-map to be able to return function keys such as [f1] on a
native Linux term or an xterm.  (This is important for
widget-key-sequence-read-event.)

I don't think I follow.  All the places where you need changes are
related to handling mouse events, so why cannot it be specific to
xt-mouse?

There is a bug in widget-key-sequence-read-event's usage of keyboard events specifically.

The function widget-key-sequence-read-event currently does not correctly translate function keys for the terminal. It has code that attempts to apply function-key-map, but does not apply input-decode-map, so it can not read function keys. (Additionally, it should be using local-function-key-map now.) Try the following steps.

Git revision: d5ac66
TERM env var: linux

Run "emacs -Q"
M-x load-library RET outline RET
M-x customize-variable RET outline-minor-mode-prefix RET
Move the cursor into the editable field.
C-q (runs the command widget-key-sequence-read-event)
Press f1.

I get the untranslated escape code sequence for [f1] put in.
I should get [f1].

Changing to read-key fixes this as read-key goes through read-key-sequence which applies input-decode-map. However, to get the same intended functionality requires some new parameters, which I also add in my patch.

And as a point of history, widget-key-sequence-read-event appears to have been added in Jan 2006, and input-decode-map was added in Oct 2007.

An alternative is to just use read-key as is in most cases and make my
change a parameter / special variable. Most of my patch's changes work fine with the existing behavior of read-key. Only the following changes
do not:

* lisp/vc/ediff-wind.el (ediff-get-window-by-clicking)
==> As coded, expects the first mouse event returned by read-event to be
a down-mouse-X event, which it then follows by another call to
read-event to get the mouse-X event. It could be easily changed to only
look for the up event.

* lisp/strokes.el (strokes-read-stroke, strokes-read-complex-stroke)
* lisp/textmodes/artist.el (artist-mode-draw-poly)
==> These both expect to detect a mix of down-mouse-X and mouse-X
events.

* lisp/wid-edit.el (widget-key-sequence-read-event)
==> This w/o changes to read-key, but with a behavior change.  With no
changes to read-key it returns just a single up event.  Currently on
other environments you get both a down and up event (e.g. <down-mouse-1>
<mouse-1>).

I think I like this latter alternative better.  It is slightly less
elegant, but simpler and less risky.  Can you show a draft of a patch
along those lines?

Attached. I added additional parameters to read-key. only strokes.el, artist.el, and wid-edit.el use the additional parameters. Let me know what you think of this structure. There's still further cleanup to do (add docs, clean up parameter names, etc.), that I'll do after you're happy with the structure.

  -- MJF

Attachment: 0001-WIP-Make-libraries-work-with-xterm-mouse-mode.patch
Description: Text Data


reply via email to

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