all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: TheFlyingDutchman <zzbbaadd@aol.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Creating a bottom window?
Date: Fri, 23 Jul 2010 07:18:35 -0700 (PDT)	[thread overview]
Message-ID: <ba1f0e0e-4405-417c-bc3f-52a3f16ea8e2@v6g2000prd.googlegroups.com> (raw)
In-Reply-To: 64e7785b-1dc5-45b6-b90f-8a87fc76783b@q22g2000yqm.googlegroups.com

On Jul 22, 6:35 am, Elena <egarr...@gmail.com> 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.emacswiki.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
     ( (= 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)  )
      )
    ( (= 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 (/= (length windowList) 2)
     nil
     (if (= (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 "<f8>") 'MakeBottomWindow)




  parent reply	other threads:[~2010-07-23 14:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-22 13:35 Creating a bottom window? Elena
2010-07-22 20:15 ` Pascal J. Bourguignon
2010-07-23 14:18 ` TheFlyingDutchman [this message]
2010-07-23 14:25   ` TheFlyingDutchman
2010-07-23 15:20     ` TheFlyingDutchman
2010-07-23 16:39   ` Pascal J. Bourguignon

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba1f0e0e-4405-417c-bc3f-52a3f16ea8e2@v6g2000prd.googlegroups.com \
    --to=zzbbaadd@aol.com \
    --cc=help-gnu-emacs@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.