From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Gauthier_=D6stervall?= Newsgroups: gmane.emacs.devel Subject: [PATCH] Make `C-x {' and `C-x }' repeatable Date: Mon, 20 May 2013 21:59:06 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1369079979 24006 80.91.229.3 (20 May 2013 19:59:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 May 2013 19:59:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 20 21:59:39 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 1UeWF9-0003O6-Fv for ged-emacs-devel@m.gmane.org; Mon, 20 May 2013 21:59:39 +0200 Original-Received: from localhost ([::1]:48222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeWF9-0002W6-6y for ged-emacs-devel@m.gmane.org; Mon, 20 May 2013 15:59:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeWF3-0002TL-Pu for emacs-devel@gnu.org; Mon, 20 May 2013 15:59:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UeWF0-0005h5-Jy for emacs-devel@gnu.org; Mon, 20 May 2013 15:59:33 -0400 Original-Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:50589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeWF0-0005gf-BA for emacs-devel@gnu.org; Mon, 20 May 2013 15:59:30 -0400 Original-Received: by mail-we0-f178.google.com with SMTP id q56so237937wes.9 for ; Mon, 20 May 2013 12:59:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=99nBjcJRkuor1LKQAkbzs4TpYCSD333MaMm5BDymkbc=; b=Ghmya5up+vX1Ceb7tjwigpdYt05soiP8n1+plicvza5ap0aNA942+W6DoWmVXwd9kd kTlg/fersPTH2ytqQrJ4nKvgWfOLcqpz8oELmBSZuGSqex2H3gI4dXoBc1Cjzr7ajZdb sU8wKLDTLJvOy++9Wz2Z4/WVl6CqNmoVviI6VuzL1f75SLrt6iIEq4poaLz4TkS3hxS9 GR/oDW/PXcbmhn5DfzzMLzNR6oH45gfyr6dLUmlPf26bS1wcrs47kOWU9tQNXmMBBSgM PiQpB+Fvr3kCvv2rTy8+FT1d60GnRjgoGAkpyiST+TquWRB+QDAobkjeqImuXbw8hi/B G1Sg== X-Received: by 10.180.37.229 with SMTP id b5mr17322509wik.29.1369079966455; Mon, 20 May 2013 12:59:26 -0700 (PDT) Original-Received: by 10.180.97.104 with HTTP; Mon, 20 May 2013 12:59:06 -0700 (PDT) X-Originating-IP: [83.248.165.178] X-Gm-Message-State: ALoCoQnfQgZ5YACCpQZSRkOVkskWXnD0B3pbBKqmZNyMrUEtIkYLngVIm+LAJmKU4NTAhHTp200N X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::232 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:159692 Archived-At: 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-repeat lp:~gauthier-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 === 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 === 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 lines, @@ -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 IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQ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