unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch for more useful C-x } and C-x { behavior
@ 2012-05-05  2:25 Deniz Dogan
  2012-05-05  3:15 ` Drew Adams
  2012-05-05  3:21 ` Leo
  0 siblings, 2 replies; 7+ messages in thread
From: Deniz Dogan @ 2012-05-05  2:25 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

"Inspired" by C-x + and C-x -, I wrote a patch which lets the user 
repeat the { or } character to continue enlarging/shrinking the selected 
window's width.

The patch needs a much better docstring, I'm just too lazy to write one. 
  I have access to commit, but I wanted to check it with you guys first.

Comments?

Deniz

[-- Attachment #2: window-patch.patch --]
[-- Type: text/plain, Size: 1673 bytes --]

=== modified file 'lisp/window.el'
--- lisp/window.el	2012-05-04 23:16:47 +0000
+++ lisp/window.el	2012-05-05 02:23:30 +0000
@@ -5173,19 +5173,41 @@
       (let ((window-min-height (min 2 height))) ; One text line plus a modeline.
 	(window-resize window delta)))))

+(defun enlarge-window-horizontally-1 (delta)
+  "Make selected window DELTA columns wider."
+  (let ((first t)
+	(step t)
+	(ev last-command-event)
+	(echo-keystrokes nil)
+        (enlarge-char (if (> delta 0) ?} ?{))
+        (shrink-char (if (> delta 0) ?{ ?})))
+    (while step
+      (let ((base (event-basic-type ev)))
+	(setq step (cond ((or first (eq base enlarge-char))
+                          delta)
+                         ((eq base shrink-char)
+                          (- delta)))))
+      (when step
+        (if (> 0 step)
+            (enlarge-window step t)
+          (shrink-window (- step) t))
+	(setq first nil)
+	(setq ev (read-event "},{ for further adjustment: "))))
+    (push ev unread-command-events)))
+
 (defun enlarge-window-horizontally (delta)
   "Make selected window DELTA columns wider.
 Interactively, if no argument is given, make selected window one
 column wider."
   (interactive "p")
-  (enlarge-window delta t))
+  (enlarge-window-horizontally-1 delta))

 (defun shrink-window-horizontally (delta)
   "Make selected window DELTA columns narrower.
 Interactively, if no argument is given, make selected window one
 column narrower."
   (interactive "p")
-  (shrink-window delta t))
+  (enlarge-window-horizontally-1 (- delta)))

 (defun count-screen-lines (&optional beg end count-final-newline window)
   "Return the number of screen lines in the region.

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

end of thread, other threads:[~2012-05-05 17:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-05  2:25 Patch for more useful C-x } and C-x { behavior Deniz Dogan
2012-05-05  3:15 ` Drew Adams
2012-05-05 13:16   ` Deniz Dogan
2012-05-05 14:21     ` Drew Adams
2012-05-05 17:21       ` Deniz Dogan
2012-05-05 17:47         ` Drew Adams
2012-05-05  3:21 ` Leo

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).