Article View: gnu.epoch.misc
Article #775Re: shrink or enlarge X window
From: Gerd Hoeren
Date: Thu, 20 May 1993 17:45
Date: Thu, 20 May 1993 17:45
107 lines
4592 bytes
4592 bytes
In article <JAEHO.93May19153426@poas.engin.umich.edu>, jaeho@engin.umich.edu (Jaeho Lee) writes:
|> Is there any implementation of mouse-based shrink-window and
|> enlarge-window in epoch? It would be great if I can point the
|> mode-line (the mode-line spliting two windows) and drag it to enlarge
|> or shrink the window.
If you decide to use Epoch with multiple X windows (instead of
splitting a single window), here is a function that adjusts the size
of the X window to the current buffer.
This is useful for taking up less screen space when working with small
files. It also makes the window larger for files with very long
lines. There are four variables that let you set the min and max sizes.
You can assign shrink-to-fit to a function key and/or connect it to
the DIRED display hook.
;;
;; Reduce the window to fit small buffers. The following global variables
;; can be set to control how the (shrink-to-fit) function behaves.
;;
(defvar shrink-max-lines 50
"*Maximum number of lines that (shrink-to-fit) puts in a window.")
(defvar shrink-min-lines 3
"*Minimum number of lines that (shrink-to-fit) puts in a window.")
(defvar shrink-max-columns 150
"*Maximum number of columns that (shrink-to-fit) puts in a window.")
(defvar shrink-min-columns 40
"*Minimum number of columns that (shrink-to-fit) puts in a window.")
(defun shrink-to-fit ()
"Shrink the current window to fit around the current buffer. Variables
SHRINK-MAX-LINES, SHRINK-MIN-LINES, SHRINK-MAX-COLUMNS and SHRINK-MIN-COLUMNS
set bounds on the largest and smallest resulting window."
(let ((max-width shrink-min-columns) ; Longest line in the file
(num-lines 0) ; Number of lines in file
(off-screen)) ; Number of lines to scroll down
(save-excursion
;; Calculate the number of lines and the longest line
(goto-char (point-min))
(while (search-forward "\n" (point-max) t)
(backward-char 1)
(setq max-width (max (1+ (current-column)) max-width))
(forward-char 1)
(setq num-lines (1+ num-lines)))
;; Change the screen size to fit around the text. Note that the height
;; of the window is the size of the file plus one for the mode line
;; plus one for the local mini-buffer (if present).
(setq num-lines (1+ (max
(min num-lines shrink-max-lines)
shrink-min-lines)))
(setq max-width (min max-width shrink-max-columns))
(change-screen-size
max-width
(if epoch::nonlocal-minibuffer num-lines (1+ num-lines))
(current-screen))
;; See if we have white space beyond the last line of the file.
(goto-char (window-start))
(setq off-screen (forward-line (1- num-lines))))
(if (not (eq 0 off-screen))
;; Put the last line of the file on the bottom of the window.
(scroll-down off-screen))))
-----
You can assign shrink-to-fit to a function key with something like:
(define-function-key "KP_Add" ;; Shrink window around buffer
'(lambda () (interactive)
(shrink-to-fit)))
-----
The following connects shrink-to-fit to the DIRED display hook so that
all DIRED windows automatically are fit to the size of their buffers.
(dired-version's value is "5.257 from
ftp.cs.buffalo.edu:pub/Emacs/diredall.tar.Z)
;; The following shrinks all DIRED windows around the size of the text.
(setq dired-after-readin-hook
(append dired-after-readin-hook '(shrink-to-fit)))
If you start Epoch in DIRED, put the following in your startup file to
shrink the initial DIRED display:
(shrink-to-fit) ;; Shrink our current (Home) dired window
-----
Happy Epoching!
--------------------------------------
Gerd Hoeren
Integrated Measurement Systems, Inc.
Beaverton, Oregon (USA)
Voice: (503) 626-7117
Fax: (503) 644-6969
Email: gerdh@ims.com
--------------------------------------
Technical Details
Message-ID:
<9305201532.AA00319@ente.ims.com>Path:
arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!uknet!pipex!bnr.co.uk!bnrgate!nott!torn!howland.reston.ans.net!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!ims.COM!gerdhShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,dc40612c50e22e2d,start X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1993-05-20 11:07:50 PST Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!uknet!pipex!bnr.co.uk!bnrgate!nott!torn!howland.reston.ans.net!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!ims.COM!gerdh From: gerdh@ims.COM (Gerd Hoeren) Newsgroups: gnu.epoch.misc Subject: Re: shrink or enlarge X window Date: 20 May 1993 13:45:59 -0400 Organization: GNUs Not Usenet Lines: 108 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <9305201532.AA00319@ente.ims.com>