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: [PATCH] Make `C-x {' and `C-x }' repeatable Date: Wed, 22 May 2013 10:44:54 -0700 (PDT) Message-ID: References: <87mwrombc3.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369244728 30652 80.91.229.3 (22 May 2013 17:45:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 May 2013 17:45:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Juri Linkov , =?iso-8859-1?B?R2F1dGhpZXIg1nN0ZXJ2YWxs?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 22 19:45:27 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UfD6M-0006YQ-Op for ged-emacs-devel@m.gmane.org; Wed, 22 May 2013 19:45:26 +0200 Original-Received: from localhost ([::1]:48273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfD6M-0006ju-Dz for ged-emacs-devel@m.gmane.org; Wed, 22 May 2013 13:45:26 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfD69-0006jR-AE for emacs-devel@gnu.org; Wed, 22 May 2013 13:45:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfD5w-0000e4-7i for emacs-devel@gnu.org; Wed, 22 May 2013 13:45:13 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:34800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfD5w-0000df-0D for emacs-devel@gnu.org; Wed, 22 May 2013 13:45:00 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4MHiuei016766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 22 May 2013 17:44:57 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4MHitlE028569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 22 May 2013 17:44:56 GMT Original-Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4MHitk9028557; Wed, 22 May 2013 17:44:55 GMT In-Reply-To: <87mwrombc3.fsf@mail.jurta.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.7 (607090) [OL 12.0.6668.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:159729 Archived-At: Juri's suggestion is a good one. There is another way to do this (which I have mentioned before): ;; Needs library `repeat.el'. Either autoload it or add (require 'repeat) ;; to a command that needs it. ;;;### (autoload 'repeat-command "repeat" t nil) (defun repeat-command (command) ; To be added to `repeat.el'. "Repeat COMMAND." (let ((repeat-message-function 'ignore)) (setq last-repeatable-command command) (repeat nil))) You can then make a repeatable command from any ordinary command.=20 E.g., window-sizing: (defun window-widen (arg) "...." (interactive "P") (repeat-command 'enlarge-window-horizontally)) (defun window-narrow (arg) "...." (interactive "P") (repeat-command 'shrink-window-horizontally)) (defun window-heighten (arg) "...." (interactive "P") (repeat-command 'enlarge-window)) (defun window-shorten (arg) "...." (interactive "P") (repeat-command 'shrink-window)) Bind to any keys you like. E.g., replace non-repeatable cmds: (define-key ctl-x-map [(?})] 'window-widen) (define-key ctl-x-map [(?{)] 'window-narrow) (define-key ctl-x-map [(?^)] 'window-heighten) (define-key ctl-x-map [(?-)] 'window-shorten) And you can put them all on a `window-size-map' keymap, as Juri suggested: (defvar window-size-map (make-sparse-keymap) "...") (define-key window-size-map [right] 'window-widen) (define-key window-size-map [left] 'window-narrow) (define-key window-size-map [up] 'window-heighten) (define-key window-size-map [down] 'window-shorten) (global-set-key [f2] window-size-map) Juri's suggestion too, of course, does not prevent you from having separate= repeatable and non-repeatable commands. E.g., (defun window-widen (arg) ; Repeatable `enlarge-window-horizontally' "...." (interactive "p") (enlarge-window-horizontally arg) (set-temporary-overlay-map window-size-map)) An advantage of Juri's suggestion over the `repeat-command' approach is tha= t it is not just for repeating a particular command. You can easily switch= from `right' to `left' or `down'. E.g., `f2 right right down down left'. = With the `repeat-command' approach you cannot: it recognizes only one comm= and; it is really about repetition. An advantage of the `repeat-command' approach over Juri's suggestion is tha= t the prefix arg that you give at the outset is used for each repeated step= . With Juri's suggestion, a prefix arg is available for only the first step. = Typically you want to repeatedly increase/decrease by the same amount. Yo= u cannot even provide a separate prefix arg for each step (which would be a= nnoying in general but might have a use in some contexts). With Juri's suggestion you can make the first use of a command use a step s= ize of 6, but repeating it puts you back to a step size of 1. Perhaps ther= e is a simple fix to make Juri's suggestion behave better in this respect. --- I take advantage of this thread to point out bug #14095, which I think is r= elevant here and which has so far gotten no response. It is a regression i= ntroduced at the same time as that of bug #122232 (which was fixed). The c= hange that introduced both problems is the use of `set-temporary-overlay-ma= p' (also pertinent to Juri's suggestion here). I want to have a repeatable command bound to a key on `isearch-mode-map'. = E.g., I bind repeatable command `isearchp-yank-line' to `C-y C-e', so I can= successively yank multiple lines into the search string. E.g., during Ise= arch: C-y C-e C-e C-e ... That works with the older `repeat.el' code. It is broken now because of a = change to `repeat-repeat-char' so that it uses `set-temporary-overlay-map '= . This is because the temporary (overlay) map is overruled by `overriding(= -terminal)-local-map', which Isearch uses. I would really like to see this bug fixed. Users should be able to use rep= eatable keys on `isearch-mode-map'.