From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Dan Nicolaescu] S-arrow_keys not working in cua-selection-mode anymore Date: Wed, 14 Nov 2007 10:14:07 -0500 Message-ID: References: <87fxzab4if.fsf@kfs-lx.testafd.dk> <87d4uduk2u.fsf@kfs-lx.testafd.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1195053297 20507 80.91.229.12 (14 Nov 2007 15:14:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Nov 2007 15:14:57 +0000 (UTC) Cc: Dan Nicolaescu , emacs-devel@gnu.org To: storm@cua.dk (Kim F. Storm) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 14 16:15:00 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IsJwl-0001nG-Qb for ged-emacs-devel@m.gmane.org; Wed, 14 Nov 2007 16:14:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IsJwZ-0000qD-2y for ged-emacs-devel@m.gmane.org; Wed, 14 Nov 2007 10:14:19 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IsJwT-0000m1-7C for emacs-devel@gnu.org; Wed, 14 Nov 2007 10:14:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IsJwR-0000hf-4r for emacs-devel@gnu.org; Wed, 14 Nov 2007 10:14:11 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IsJwQ-0000hR-Vc for emacs-devel@gnu.org; Wed, 14 Nov 2007 10:14:10 -0500 Original-Received: from tomts20.bellnexxia.net ([209.226.175.74] helo=tomts20-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IsJwQ-00049w-RC for emacs-devel@gnu.org; Wed, 14 Nov 2007 10:14:11 -0500 Original-Received: from pastel.home ([70.53.194.136]) by tomts20-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20071114151409.WJZJ8273.tomts20-srv.bellnexxia.net@pastel.home> for ; Wed, 14 Nov 2007 10:14:09 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id E28968118; Wed, 14 Nov 2007 10:14:07 -0500 (EST) In-Reply-To: <87d4uduk2u.fsf@kfs-lx.testafd.dk> (Kim F. Storm's message of "Wed, 14 Nov 2007 12:45:29 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83194 Archived-At: >>> 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