From: Deniz Dogan <deniz@dogan.se>
To: emacs-devel@gnu.org
Subject: Patch for more useful C-x } and C-x { behavior
Date: Sat, 05 May 2012 04:25:22 +0200 [thread overview]
Message-ID: <4FA48F92.2080706@dogan.se> (raw)
[-- 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.
next reply other threads:[~2012-05-05 2:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-05 2:25 Deniz Dogan [this message]
2012-05-05 3:15 ` Patch for more useful C-x } and C-x { behavior 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FA48F92.2080706@dogan.se \
--to=deniz@dogan.se \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).