From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TheFlyingDutchman Newsgroups: gmane.emacs.help Subject: Re: Creating a bottom window? Date: Fri, 23 Jul 2010 07:18:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <64e7785b-1dc5-45b6-b90f-8a87fc76783b@q22g2000yqm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291849669 3475 80.91.229.12 (8 Dec 2010 23:07:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 23:07:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 00:07:45 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQT6v-0002GM-7M for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 00:07:45 +0100 Original-Received: from localhost ([127.0.0.1]:49954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQT6u-00018G-E2 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 18:07:44 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!v6g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 134 Original-NNTP-Posting-Host: 75.36.147.51 Original-X-Trace: posting.google.com 1279894716 2291 127.0.0.1 (23 Jul 2010 14:18:36 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 23 Jul 2010 14:18:36 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v6g2000prd.googlegroups.com; posting-host=75.36.147.51; posting-account=9bWHAAoAAAAxSFC_2O_ssTETNW9NhMbW User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; AskTbBT5/5.8.0.12304),gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:179975 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76187 Archived-At: On Jul 22, 6:35=A0am, Elena wrote: > Hello, > > how do you create a window as wide as its frame and positioned at the > bottom, no matter how many windows are there at the moment? I mean, a > window positioned like the `shrink-fit.el' in this picture:http://www.ema= cswiki.org/emacs/DrewsEmacsWindowCallouts > > I've checked the ELisp reference about windows, but it seems you can > just split existing windows. > I also don't see any other way to create a new window besides splitting windows. This code doesn't satisfy "no matter how many windows are there" - it only handles 1 or 2 windows, and also assumes equal sized windows, so may not be of any value. It does allow the number of bottom window lines and bottom window buffer to be spacified. ; window lines seems to include the mode line (setq bottom_window_lines 8) (setq bottom_window_buffer "*scratch*") (defun MakeBottomWindow () (interactive) (let ( (num_windows (length (window-list nil 0 nil))) ) (cond ( (=3D num_windows 1) (split-window-vertically (- (window-height) bottom_window_lines)) (when (get-buffer bottom_window_buffer) (set-window-buffer (next-window) bottom_window_buffer) ) ) ( (=3D num_windows 2) (if (FrameHasTwoHorizontalWindows) (BottomWithTwoHorizontalWindows) (BottomWithTwoVerticalWindows) ) ) ( (> num_windows 2) (message "MakeBottomWindow can't handle more than two windows") (beep) ) ) ) ) (defun BottomWithTwoHorizontalWindows () (get-buffer-create " work") (delete-other-windows) (switch-to-buffer " work") (split-window-vertically (- (window-height) bottom_window_lines)) (split-window-horizontally) (set-window-buffer nil leftWindowBuffer) (other-window 1) (set-window-buffer nil rightWindowBuffer) (other-window 1) (when bottom_window_buffer (set-window-buffer nil bottom_window_buffer) (other-window 1) ) (when rightWindowActive (other-window 1) ) (kill-buffer " work") ) (defun BottomWithTwoVerticalWindows () (unless topWindowActive (other-window 1) ) (shrink-window (round (/ bottom_window_lines 2))) (other-window 1) (split-window-vertically (- (window-height)1 bottom_window_lines)) (when bottom_window_buffer (set-window-buffer (next-window) bottom_window_buffer) ) (if topWindowActive (other-window -1) ) ) (defun FrameHasTwoHorizontalWindows () "are there two side by side windows - from window-split-horizontally" (interactive) (setq currentWindow (next-window) ) (setq windowList (window-list nil 0 nil)) (setq window1Coords (window-edges (car windowList))) (setq window2Coords (window-edges (car (cdr windowList)))) (if (/=3D (length windowList) 2) nil (if (=3D (car window1Coords) (car window2Coords)) (progn (if (< (nth 1 window1Coords) (nth 1 window2Coords) ) (progn (setq topWindow (car windowList) ) (setq bottomWindow (nth 1 windowList) ) ) (setq bottomWindow (car windowList) ) (setq topWindow (nth 1 windowList) ) ) (if (eq (next-window) topWindow) (setq topWindowActive nil) (setq topWindowActive t) ) nil ) (if (< (car window1Coords) (car window2Coords) ) (progn (setq leftWindow (car windowList) ) (setq rightWindow (car (cdr windowList) ) ) ) (setq leftWindow (car (cdr windowList) ) ) (setq rightWindow (car windowList) ) ) (setq leftWindowBuffer (window-buffer leftWindow) ) (setq rightWindowBuffer (window-buffer rightWindow) ) (if (eq (next-window) leftWindow) (setq rightWindowActive t) (setq rightWindowActive nil) ) t ) ) ) (global-set-key (kbd "") 'MakeBottomWindow)