From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: have cake will eat, eatcake will have - krazy key koncept kontroversy Date: Thu, 27 Aug 2009 13:41:11 -0700 Message-ID: References: <732931969EE046E8A44CE77C4FD88C64@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1251405697 7463 80.91.229.12 (27 Aug 2009 20:41:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Aug 2009 20:41:37 +0000 (UTC) To: "'Andrey Paramonov'" , Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 27 22:41:30 2009 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 1Mglmj-0003Vh-3b for ged-emacs-devel@m.gmane.org; Thu, 27 Aug 2009 22:41:29 +0200 Original-Received: from localhost ([127.0.0.1]:45405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mglmi-0003XI-HY for ged-emacs-devel@m.gmane.org; Thu, 27 Aug 2009 16:41:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mglmc-0003Tv-5j for emacs-devel@gnu.org; Thu, 27 Aug 2009 16:41:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MglmX-0003QV-O6 for emacs-devel@gnu.org; Thu, 27 Aug 2009 16:41:21 -0400 Original-Received: from [199.232.76.173] (port=55499 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MglmX-0003QK-GK for emacs-devel@gnu.org; Thu, 27 Aug 2009 16:41:17 -0400 Original-Received: from rcsinet11.oracle.com ([148.87.113.123]:53403 helo=rgminet11.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MglmX-00021S-2N for emacs-devel@gnu.org; Thu, 27 Aug 2009 16:41:17 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rgminet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n7RKfYaT004533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Aug 2009 20:41:36 GMT Original-Received: from abhmt002.oracle.com (abhmt002.oracle.com [141.146.116.11]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n7RKfCX6026035; Thu, 27 Aug 2009 20:41:13 GMT Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 Aug 2009 13:41:08 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: AconQLO3VUojAQAgS5m7IUfJmnlp4gAAI3vA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: abhmt002.oracle.com [141.146.116.11] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090201.4A96EF65.00FC:SCFSTAT5015188,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 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:114699 Archived-At: > I see the problem you are trying to solve. Yes and no. I think you see the point about using a suffix key to repeat an action. I don't think you see the point about using a prefix key (as its own suffix) to perform a (repeatable) action. [*] > 1) In many cases, user will have to hit prefix twice instead > of once (C-a C-a instead of C-a). Not just in many cases. In *all* cases where this technique is used. This is in the nature of a prefix key. If a key (e.g. C-a) performs an action on its first press, then it cannot be a prefix key. Otherwise, how could you distinguish C-a as action from C-a as prefix? How would you know whether C-a might be followed by `j' or `C-r' (assuming keys `C-a j' and `C-a C-r' were defined)? > I suggest to go the other way around: > IF there is no keymap entry that matches the key sequence > *and* the previous key has successfully executed a command > *and* the key equals to the previous key > THEN repeat the command (and keep processing the key sequence). > > For example: > C-x o will take me to other window > C-x o o o o ... will cycle me through windows > C-x C-f will work as used to > C-x C-x will exchange point and mark > C-x C-x C-x will exchange point and mark twice > C-x C-x C-x C-x will exchange point and mark three times > > This approach does not impose extra key penalty for > non-repetitive command execution. > > In Emacs 23, C-x C-= / C-x C-- (text-scale-adjust) work this > way. I find it very useful and intuitive. What you are talking about has nothing to do with prefix keys. Using the technique I mentioned, you can get the behavior you listed (C-x o, C-x o o o..., C-x C-x, etc) immediately: (defun other-window-repeat () (interactive) (repeat-command 'other-window)) (define-key ctl-x-map "o" 'other-window-repeat) The fact that you can do that in this way is only part of what I was pointing out. The real point was to be able to use this technique also for a prefix key: to be able to have a prefix key perform some action when repeated. Why? a. To have additional easily repeatable keys (giving existing prefix keys double duty). b. To have additional prefix keys (giving existing non-prefix keys double duty). Obviously, if the same key is used as both prefix and suffix, then no action can be performed the first time the key is pressed. Because it is a prefix key, C-x does nothing until you press it again (or press some another key). So we would only bind a repeatable action to a prefix key followed by itself when that action is not very useful as a one-off. I gave as examples commands that incrementally change some parameter - e.g. the height of a window, frame, font,... It's not very important that such a command do something on the very first key press, since you are going to press it multiple times. The point is that we can: a. Use an existing prefix key as its own suffix, and thus let it perform some repeatable action (starting with the first repetition). b. Convert an existing non-prefix key to a prefix key, when its one-off action isn't really needed (that is, we are mainly interested in its repeated action). Together, these allow reuse of the same key to (a) perform a repeated action by holding it pressed and (b) serve as a way station to other keys/commands, by being a prefix. Wrt (a): Think of all the prefix keys you use. We could reuse an existing prefix key such as `M-s h' to perform a repeatable action such as, I don't know, highlight-the-next-word: M-s h h h h... Would it be worth it to do that? Dunno. It all depends on the particular keys and commands. But the possibility is there. Wrt (b): Think of all the non-prefix keys you use. Some of them perform useful repeatable actions. Others do not - they are just one-offs. C-M-a is usefully repeatable; C-M-x is not. (Binding C-M-x to a command that we do not repeat is, _in itself_, a waste. But there are other reasons for that binding.) We could make a key such as C-M-a or C-M-x into a prefix key, if we wanted. (I'm not suggesting we do that.) Advantage: another prefix key. If we did that, we could still have C-M-a go to the beginning of the previous defun, in a repeatable way, just as now. The only loss would be that to get the one-off behavior of going just to the current defun, you would need to hit C-M-a twice. Would it be worth it to do that for C-M-a? Probably not. It all depends on the particular command (do we really need the one-off behavior?), the particular key binding (is it easy to repeat?), and how hard up we are for a new prefix key. But the possibility is there. [* To simplify the wording, I say use the prefix key as its own suffix, but I really mean use some tail of the prefix key as its own suffix, where the tail could be the whole prefix key. `C-x C-x' uses the whole prefix key `C-x' as a suffix. `M-s h h' uses only the tail `h' of the prefix key `M-s h' as a suffix.]