From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.devel Subject: Patch for more useful C-x } and C-x { behavior Date: Sat, 05 May 2012 04:25:22 +0200 Message-ID: <4FA48F92.2080706@dogan.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060803020901070205050107" X-Trace: dough.gmane.org 1336184753 26557 80.91.229.3 (5 May 2012 02:25:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 5 May 2012 02:25:53 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 05 04:25:53 2012 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 1SQUgy-0001cs-NN for ged-emacs-devel@m.gmane.org; Sat, 05 May 2012 04:25:52 +0200 Original-Received: from localhost ([::1]:36264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQUgy-00061a-0P for ged-emacs-devel@m.gmane.org; Fri, 04 May 2012 22:25:52 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQUgv-00061K-35 for emacs-devel@gnu.org; Fri, 04 May 2012 22:25:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SQUgs-0005AY-5Z for emacs-devel@gnu.org; Fri, 04 May 2012 22:25:48 -0400 Original-Received: from mxf5.bahnhof.se ([213.80.101.29]:64894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQUgr-0005A2-QI for emacs-devel@gnu.org; Fri, 04 May 2012 22:25:46 -0400 Original-Received: from localhost (mxf5.local [127.0.0.1]) by mxf5-reinject (Postfix) with ESMTP id 3011ACF0F6 for ; Sat, 5 May 2012 04:25:44 +0200 (CEST) X-Virus-Scanned: by amavisd-new using ClamAV at bahnhof.se (MXF1) Original-Received: from mxf5.bahnhof.se ([127.0.0.1]) by localhost (mxf5.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 44PUIMAV-lVj for ; Sat, 5 May 2012 04:25:41 +0200 (CEST) Original-Received: from [176.10.168.241] (h-168-241.a336.priv.bahnhof.se [176.10.168.241]) by mxf5.bahnhof.se (Postfix) with ESMTP id 53BA5CF0F4 for ; Sat, 5 May 2012 04:25:41 +0200 (CEST) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.80.101.29 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:150263 Archived-At: This is a multi-part message in MIME format. --------------060803020901070205050107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit "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 --------------060803020901070205050107 Content-Type: text/plain; charset=windows-1252; name="window-patch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="window-patch.patch" === 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. --------------060803020901070205050107--