From: Stefan Monnier <monnier@iro.umontreal.ca>
To: storm@cua.dk (Kim F. Storm)
Cc: Dan Nicolaescu <dann@ics.uci.edu>, emacs-devel@gnu.org
Subject: Re: [Dan Nicolaescu] S-arrow_keys not working in cua-selection-mode anymore
Date: Wed, 14 Nov 2007 10:14:07 -0500 [thread overview]
Message-ID: <jwvpryc27hc.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87d4uduk2u.fsf@kfs-lx.testafd.dk> (Kim F. Storm's message of "Wed, 14 Nov 2007 12:45:29 +0100")
>>> CUA normally works by looking for a shift modifier on the event,
>>> but it has special code to handle a non-windowing system:
>>
>>> ((if window-system
>>> (memq 'shift (event-modifiers
>>> (aref (this-single-command-raw-keys) 0)))
>>> (or
>>> (memq 'shift (event-modifiers
>>> (aref (this-single-command-keys) 0)))
>>> ;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home.
>>> (and (boundp 'local-function-key-map)
>>> local-function-key-map
>>> (let ((ev (lookup-key local-function-key-map
>>> (this-single-command-raw-keys))))
>>> (and (vector ev)
>>> (symbolp (setq ev (aref ev 0)))
>>> (string-match "S-" (symbol-name ev)))))))
>>
>>
>> Oh, indeed, sorry for not catching this. It should use input-decode-map
>> rather than local-function-key-map.
> Ok. Could someone please make the change (trunk only!!). Thanks!
I'll do it.
>> It may be even better to *also*
>> check local-function-key-map (after input-decode-map), but it shouldn't
>> be necessary.
> Huh? It may be better ... but not necessary ??
Since until Emacs-23, function-key-map was used for such things, some
users may have added decoding entries to their function-key-map.
For this reason it may be better to check that map as well. But it's
probably not very important. Also it may be undesirable (before
function-key-map, the keys are kind of like X11's
this-single-command-raw-keys, whereas after function-key-map, they may
be somewhat different: removal of shift could be implemented in
function-key-map for example).
>> This said, I'm not quite sure I understand enough of the above code:
>> why does it need to behave differently depending on window-system?
> The problem is to get around the implicit translation of "Shift-XXX" to
> "XXX" if "Shift-XXX" has no specific binding.
> On a window-system, this-single-command-raw-keys returns the untranslated
> keys, so I can use it to check directly if user pressed a shifted key.
> The problem is (or was??) how to test for a shifted function key
> on a non-window system.
> Suppose S-up sends "ESC A B" in xterm.
> Then this-single-command-raw-keys returns [27 65 66].
> This is not useful.
> And this-single-command-keys returns [up].
> This is not useful either.
> So the only way is to go back to the raw key sequence and look it up
> in the function key translation map to see if the result is a shifted key.
> If you have a better way of checking this, I'm listening :-)
I understand the need for the tty version of the code, but I'm wondering
why that branch can't be used equally well for the window-system case.
I.e. I suggest the code below instead:
((or
(memq 'shift (event-modifiers
(aref (this-single-command-keys) 0)))
;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home.
(let ((ev (lookup-key input-decode-map
(this-single-command-raw-keys))))
(if (vector ev)
(and (symbolp (setq ev (aref ev 0)))
(string-match "S-" (symbol-name ev)))
(memq 'shift (event-modifiers
(aref (this-single-command-raw-keys) 0))))))
Stefan
next prev parent reply other threads:[~2007-11-14 15:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-13 14:32 [Dan Nicolaescu] S-arrow_keys not working in cua-selection-mode anymore Kim F. Storm
2007-11-13 15:20 ` Stefan Monnier
2007-11-14 11:45 ` Kim F. Storm
2007-11-14 15:14 ` Stefan Monnier [this message]
2007-11-15 12:52 ` Kim F. Storm
2007-11-15 16:36 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvpryc27hc.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
--cc=storm@cua.dk \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.