From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: New keybinding suggestion: C-x _ for `shrink-window' Date: Thu, 1 Nov 2007 09:54:22 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1193936096 14461 80.91.229.12 (1 Nov 2007 16:54:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Nov 2007 16:54:56 +0000 (UTC) Cc: bzg@altern.org, emacs-devel@gnu.org To: , "Stefan Monnier" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 01 17:54:57 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IndJo-0004JP-M0 for ged-emacs-devel@m.gmane.org; Thu, 01 Nov 2007 17:54:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IndJe-00013N-Re for ged-emacs-devel@m.gmane.org; Thu, 01 Nov 2007 12:54:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IndJc-00011E-DE for emacs-devel@gnu.org; Thu, 01 Nov 2007 12:54:44 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IndJZ-0000uw-CL for emacs-devel@gnu.org; Thu, 01 Nov 2007 12:54:43 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IndJZ-0000ul-8i for emacs-devel@gnu.org; Thu, 01 Nov 2007 12:54:41 -0400 Original-Received: from agminet01.oracle.com ([141.146.126.228]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IndJU-0002pF-P5; Thu, 01 Nov 2007 12:54:37 -0400 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id lA1GsSnv019928; Thu, 1 Nov 2007 11:54:29 -0500 Original-Received: from acsmt351.oracle.com (acsmt351.oracle.com [141.146.40.151]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id lA197jlG017452; Thu, 1 Nov 2007 10:54:26 -0600 Original-Received: from dhcp-4op11-4op12-west-130-35-178-158.us.oracle.com by acsmt350.oracle.com with ESMTP id 3337012881193936053; Thu, 01 Nov 2007 09:54:13 -0700 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82300 Archived-At: > Actually, I'd prefer to deprecate those bindings (along with > C-x ^) and replace them with a binding that allows the user to do: > M-x window-resize RET > (which we'd of course bind to some key) and then > ^ ^ ^ } } } } } { { { { } } ... > or left left left up up up up up up up > > I think that is worth trying. To make it convenient we need > a key binding for window-resize. How about C-x _? FWIW - This is trivial to do with Do Re Mi. Function `doremi' lets you increment or decrement anything repeatedly, using the arrow keys or a mouse wheel (or both). It is made for this kind of thing. In this case, we define two commands, `window-resize' and `window-resize-horizontally', that use `doremi' to increment the height and width, respectively. Left and right arrows are used for horizontal; up and down arrows are used for vertical. Each command calls the other whenever the arrow-key type changes (horizontal vs vertical). Only one of the commands needs to be bound to a key - e.g. bind `window-resize' to `C-x _'. Try it. You can get `doremi' here: http://www.emacswiki.org/cgi-bin/wiki/doremi.el. Some doc is here: http://www.emacswiki.org/cgi-bin/wiki/DoReMi. You can end either command by hitting any key besides an arrow or the mouse wheel (e.g. `C-g'). These definitions are trivial, even if they might not appear trivial to someone unfamiliar with `doremi' - they are typical. The first arg to `doremi' is an incrementation (growth) function. The second arg is the initial value. The third arg is the increment to pass to the growth function. The growth function returns the new value, so that it can be echoed to the user at each arrow key press. (defun window-resize (&optional increment window) "Change height WINDOW incrementally. INCREMENT is the size increment. WINDOW is selected. WINDOW defaults to the selected window." (interactive "p") (select-window (or window (selected-window))) (doremi (lambda (incr) (shrink-window incr) (window-height)) (window-height) (- increment) t) (when (member (car unread-command-events) '(left right M-left M-right)) (window-resize-horizontally increment window))) (defun window-resize-horizontally (&optional increment window) "Change width of WINDOW incrementally. INCREMENT is the size increment. WINDOW is selected. WINDOW defaults to the selected window." (interactive "p") (select-window (or window (selected-window))) (let ((doremi-up-key 'left) (doremi-boost-up-key 'M-left) (doremi-down-key 'right) (doremi-boost-down-key 'M-right)) (doremi (lambda (incr) (shrink-window-horizontally incr) (window-width)) (window-width) nil t)) (when (member (car unread-command-events) (list doremi-up-key doremi-down-key doremi-boost-up-key doremi-boost-down-key)) (window-resize increment window)))