all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Make `C-x {' and `C-x }' repeatable
@ 2013-05-20 19:59 Gauthier Östervall
  2013-05-21  9:58 ` Vitalie Spinu
                   ` (2 more replies)
  0 siblings, 3 replies; 51+ messages in thread
From: Gauthier Östervall @ 2013-05-20 19:59 UTC (permalink / raw)
  To: emacs-devel

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  <gauthier@ostervall.se>
+
+	* window.el (window-size-adjust): New function.
+
 2013-04-29  Leo Liu  <sdl.web@gmail.com>

 	* 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
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWUR/XcIAA/JfgH74WPf///+n
ho7////6YAkK7fS3YOIhVusmxkEqACmjWEiiJkxDKPTRppPVHpPU/VGQZI0GRoMIMCB5QSiJk0MS
aegonoQ0NDQNAAaAAGQGg5hNAaA0aMI0GI0xMmJoMI0DIBkwEpoUKaNT1N6gGpg0hgABqZkIwhoZ
oTAOYTQGgNGjCNBiNMTJiaDCNAyAZMBJEEyCMJNT01PJpMmNQT0k2EnpkgNAAabRK6mNCpOOvNw/
OIe/dNMDz+/5GP6nDKPHn45+VmllrIPBUm1m4uQt3tbOqpYhDglwOvchbLk+9SIm0crpRhHhgZOW
rUZ5CqssSQoh2dsEB87ObMs5sMOy89x49p/GqG68xIs5uTEfC1Corm0aJWgQjKwBYkxGVuVmTJKS
Cpdmy+RTBmujjTpNTI7nJnUYsLmtuZuvHyK+Z838rpjofnMsh9ll/PXruCQbxjgNl+MjHWYjPbrL
PfdaRrhyhImt5hzK2llPVWWRxFs3y0ZYWaKXZWFm/hatpRXPCLCOFQTb+nLm+VmkqxarFbdAZB0I
FUBRx02V7TN3ZYrYWwO/bn3ddT0w34eo85PfOmnZ8xSnlBmSZgY+S+IuCyJ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CpaR5LFhRLQtTa4xSsSZqsKhGXlFFa9TnWgy
OcHDEww5XkiJ0iUSJoAvuFofZohHrFsN+omtbJhM7APlOpJBiRw1CNgp4H7hCHh+9wIvITnvFYg1
UAejiKS3INafigcC7aOG05PEdmTkYqDG5ZFDaCptDM4mpVfsJqtQiGuu8yQR7i7kinChIIj+u4Q=



^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2013-06-13 20:44 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-20 19:59 [PATCH] Make `C-x {' and `C-x }' repeatable Gauthier Östervall
2013-05-21  9:58 ` Vitalie Spinu
2013-05-21 13:53   ` Gauthier Östervall
2013-05-21 18:34 ` Juri Linkov
2013-05-22 17:44   ` Drew Adams
2013-05-22 18:55     ` Juri Linkov
2013-05-22 21:39       ` Drew Adams
2013-05-22 22:08         ` Stefan Monnier
2013-05-22 23:53           ` Drew Adams
2013-05-23  0:18             ` chad
2013-05-23 16:19               ` Drew Adams
2013-05-23 16:48                 ` Stefan Monnier
2013-05-23 19:52                   ` Drew Adams
2013-05-24  4:53                     ` Stephen J. Turnbull
2013-05-24 15:55                       ` Drew Adams
2013-05-24 17:00                         ` Stephen J. Turnbull
2013-05-22 21:47       ` Stefan Monnier
2013-05-22 22:24         ` Stefan Monnier
2013-05-22 23:53         ` Drew Adams
2013-05-23 22:30         ` Juri Linkov
2013-05-24  3:58           ` Stefan Monnier
2013-05-22 19:05 ` Stefan Monnier
2013-05-23 12:21   ` Gauthier Östervall
2013-05-23 13:41     ` Stefan Monnier
2013-05-23 22:04       ` Juri Linkov
2013-05-24  9:38         ` Alan Mackenzie
2013-05-24 20:31           ` Juri Linkov
2013-05-25 20:01             ` Alan Mackenzie
2013-05-25 20:40               ` Juri Linkov
2013-06-02 21:05                 ` isearch-allow-prefix [Was: [PATCH] Make `C-x {' and `C-x }' repeatable] Alan Mackenzie
2013-06-04 18:03                   ` Juri Linkov
2013-06-04 21:24                     ` Alan Mackenzie
2013-06-05  8:23                       ` Juri Linkov
2013-06-05 21:02                         ` Alan Mackenzie
2013-06-06  6:07                           ` isearch-allow-move [Was: isearch-allow-prefix] Juri Linkov
2013-06-06 12:45                             ` Stefan Monnier
2013-06-06 15:07                               ` Juri Linkov
2013-06-06 15:43                                 ` Drew Adams
2013-06-06 16:39                                 ` Stefan Monnier
2013-06-07  7:07                                   ` Juri Linkov
2013-06-06 20:07                             ` Alan Mackenzie
2013-06-07  6:59                               ` Juri Linkov
2013-06-07 10:30                                 ` Alan Mackenzie
2013-06-07 19:30                                   ` Juri Linkov
2013-06-09 20:09                                     ` Juri Linkov
2013-06-11 19:35                                       ` Juri Linkov
2013-06-07 20:04                               ` Juri Linkov
2013-06-09 12:07         ` [PATCH] set-temporary-overlay-map improvement and make windresize exit on other commands Vitalie Spinu
2013-06-09 16:03           ` Stefan Monnier
2013-06-09 17:12             ` Vitalie Spinu
2013-06-13 20:44               ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.