From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vitalie Spinu Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Make `C-x {' and `C-x }' repeatable Date: Tue, 21 May 2013 11:58:36 +0200 Organization: EUR Message-ID: <87fvxgac37.fsf@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369130336 2767 80.91.229.3 (21 May 2013 09:58:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 May 2013 09:58:56 +0000 (UTC) Cc: emacs-devel@gnu.org To: Gauthier =?utf-8?Q?=C3=96stervall?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 21 11:58:56 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 1UejLM-00048m-BG for ged-emacs-devel@m.gmane.org; Tue, 21 May 2013 11:58:56 +0200 Original-Received: from localhost ([::1]:42339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UejLL-0003cz-Vw for ged-emacs-devel@m.gmane.org; Tue, 21 May 2013 05:58:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UejLC-0003b6-Uh for emacs-devel@gnu.org; Tue, 21 May 2013 05:58:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UejL5-0001VU-TA for emacs-devel@gnu.org; Tue, 21 May 2013 05:58:46 -0400 Original-Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:59571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UejL5-0001VO-Jl for emacs-devel@gnu.org; Tue, 21 May 2013 05:58:39 -0400 Original-Received: by mail-wg0-f53.google.com with SMTP id m15so237399wgh.20 for ; Tue, 21 May 2013 02:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=ued34wlY0bGnllYJl3aUIJ8UzI95QbRcDkd4vL8VIC4=; b=XuWZH2taWOKIc1zMCLhnmTb0uOXC68cxCaMng9+NwvXFdCWHImfVVYzEPHaVdgnHW8 l1Cf4qMzo2mMuR8ntZh7BCtyqwl8qKB8W5EbQT3fd1XZ859jPGNGs1+zZ/iUszMt/+MU 3/Gj/9dQpxqMXWnCPC6Sn6dg5T2apmnxHxfNIpQEBv6KLcw8B5GDmqe7A2CcY61PDOiM 7l9WK18S61p3AZjgscfG4xS0PvwWMgLFvorYBkpSF0Od8Ruz32sF+u2TlQsMbXcM7n2f tqCfXl+FfPdE+c0r0mAhC1YMhjG6Jmt/esAUoN3VzNB0y2B9oQny6DgAJjIDzHhStLHE TnjA== X-Received: by 10.180.88.231 with SMTP id bj7mr22085519wib.5.1369130318767; Tue, 21 May 2013 02:58:38 -0700 (PDT) Original-Received: from localhost (dhcp-077-249-018-128.chello.nl. [77.249.18.128]) by mx.google.com with ESMTPSA id ay7sm20649576wib.9.2013.05.21.02.58.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 May 2013 02:58:37 -0700 (PDT) In-Reply-To: ("Gauthier =?utf-8?Q?=C3=96stervall=22's?= message of "Mon, 20 May 2013 21:59:06 +0200") User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::235 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:159705 Archived-At: I think this is a very nice idea. Similar change would make sense for C-x ^. Vitalie >> Gauthier =C3=96stervall >> on Mon, 20 May 2013 21:59:06 +0200 wrote: > Ever since I started using emacs and tried to say good bye to my > mouse, I have felt that the resizing of windows with `C-x }' and > `C-x {' is too cumbersome to use. > - Typing `C-x }' several times in a row is not practical. > - I always undershoot when using things of the form `M-10 C-x }' > - I alway overshoot when using `C-x } C-x zzzzz' > This branch makes `C-x {' and `C-x }' behave similarly to `C-x > C-+' (text-scale-adjust). After the original `C-x }' (or `C-x > {'), additional `{' and `}' continue to resize the window, until > the user enters another character. > The change is in lisp/window.el, which has dynamic scoping. I > understand that this new function would be better with lexical > binding, allowing for a clean closure. However I do not feel > confident enough (yet) with dynamic scoping to change the file's > binding mode by myself. > Please tell me if I should have done that differently, and I'll > try to implement it. I'd be happy to see window.el get lexical > binding, and use a closure instead of a macro. If the patch is > acceptable as is, it would be very nice to see it integrated. > Note that this is my first patch to GNU Emacs and with bzr. I > might for example have missed indentation conventions (no tabs in > the new function, only spaces), but I could not find info about > tabbing conventions on the wiki or gnu.org (a link would be > welcome, if available). Please guide me if I missed other > standard things. > https://code.launchpad.net/~gauthier-i/emacs/resize-window-repeatlp:~gau= thier-i/emacs/resize-window-repeat > Launchpad says that the branch is "Updating" and "empty", and has > been saying so for days. Weeks, really. The code seems to be > there though. Tell me if it's not reachable for you, and if you > have suggestions for how to fix it, it'd be nice. > Otherwise, here's the bundle: > # Bazaar merge directive format 2 (Bazaar 0.90) > # revision_id: gauthier@ostervall.se-20130520193632-fm01gjdl38ux3egc > # target_branch: file:///media/sf_prog/emacs/trunk/ > # testament_sha1: 6d88925597179e2c8c55153d5f9c62703d6ecd68 > # timestamp: 2013-05-20 21:51:05 +0200 > # base_revision_id: rgm@gnu.org-20130430101735-ccy06l3ndx4vrj18 > # > # Begin patch > =3D=3D=3D modified file 'lisp/ChangeLog' (properties changed: -x to +x) > --- lisp/ChangeLog 2013-04-29 20:09:18 +0000 > +++ lisp/ChangeLog 2013-05-20 19:36:32 +0000 > @@ -1,3 +1,7 @@ > +2013-05-20 Gauthier Ostervall > + > + * window.el (window-size-adjust): New function. > + > 2013-04-29 Leo Liu > * progmodes/octave.el (octave-font-lock-keywords): Handle 'end' in > =3D=3D=3D modified file 'lisp/window.el' (properties changed: -x to +x) > --- lisp/window.el 2013-04-13 14:37:20 +0000 > +++ lisp/window.el 2013-05-07 12:13:36 +0000 > @@ -6025,6 +6025,48 @@ > (interactive "p") > (shrink-window delta t)) > +;;;###autoload (define-key ctl-x-map [(?{)] 'window-size-adjust) > +;;;###autoload (define-key ctl-x-map [(?})] 'window-size-adjust) > +;;;###autoload > +(defun window-size-adjust (inc) > + "Adjust the width or height of the current window by INC. > + > +INC may be passed as a numeric prefix argument. > + > +The actual adjustment made depends on the final component of the > +key-binding used to invoke the command, with all modifiers removed: > + > + { Decrease the window width by one step > + } Increase the window width by one step > + > +When adjusting with `{' or `}', continue to read input events and > +further adjust the windows width as long as the input event read > +\(with all modifiers removed) is `{' or `}'. > + > +This command is a special-purpose wrapper around the > +`enlarge-window-horizontally' command which makes repetition convenient > +even when it is bound in a non-top-level keymap. For binding in > +a top-level keymap, `enlarge-window-horzontally' or > +`shrink-window-horizontally' may be more appropriate." > + (interactive "p") > + (let ((ev last-command-event) > + (echo-keystrokes nil)) > + (let* ((base (event-basic-type ev)) > + (step > + (pcase base > + (?{ (- inc)) > + (?} inc) > + (t inc)))) > + (enlarge-window-horizontally step) > + (message "Use {,} for further adjustment") > + (set-temporary-overlay-map > + (let ((map (make-sparse-keymap))) > + (dolist (mods '(())) > + (dolist (key '(?{ ?})) > + (define-key map (vector (append mods (list key))) > + `(lambda () (interactive) (window-size-adjust (abs ,inc)= ))))) > + map))))) > + > (defun count-screen-lines (&optional beg end count-final-newline window) > "Return the number of screen lines in the region. > The number of screen lines may be different from the number of actual l= ines, > @@ -6734,8 +6776,8 @@ > (define-key ctl-x-map "3" 'split-window-right) > (define-key ctl-x-map "o" 'other-window) > (define-key ctl-x-map "^" 'enlarge-window) > -(define-key ctl-x-map "}" 'enlarge-window-horizontally) > -(define-key ctl-x-map "{" 'shrink-window-horizontally) > +(define-key ctl-x-map "}" 'window-size-adjust) > +(define-key ctl-x-map "{" 'window-size-adjust) > (define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer) > (define-key ctl-x-map "+" 'balance-windows) > (define-key ctl-x-4-map "0" 'kill-buffer-and-window) > # Begin bundle > IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWUR/XcIAA/JfgH74WPf/= //+n > ho7////6YAkK7fS3YOIhVusmxkEqACmjWEiiJkxDKPTRppPVHpPU/VGQZI0GRoMIMCB5QSiJ= k0MS > aegonoQ0NDQNAAaAAGQGg5hNAaA0aMI0GI0xMmJoMI0DIBkwEpoUKaNT1N6gGpg0hgABqZkI= whoZ > oTAOYTQGgNGjCNBiNMTJiaDCNAyAZMBJEEyCMJNT01PJpMmNQT0k2EnpkgNAAabRK6mNCpOO= vNw/ > OIe/dNMDz+/5GP6nDKPHn45+VmllrIPBUm1m4uQt3tbOqpYhDglwOvchbLk+9SIm0crpRhHh= gZOW > rUZ5CqssSQoh2dsEB87ObMs5sMOy89x49p/GqG68xIs5uTEfC1Corm0aJWgQjKwBYkxGVuVm= TJKS > Cpdmy+RTBmujjTpNTI7nJnUYsLmtuZuvHyK+Z838rpjofnMsh9ll/PXruCQbxjgNl+MjHWYj= PbrL > PfdaRrhyhImt5hzK2llPVWWRxFs3y0ZYWaKXZWFm/hatpRXPCLCOFQTb+nLm+VmkqxarFbdA= ZB0I > FUBRx02V7TN3ZYrYWwO/bn3ddT0w34eo85PfOmnZ8xSnlBmSZgY+S+IuCyJKxBcQX1txgdQT= A5fe > 9evXaqh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