Thread View: gnu.epoch.misc
2 messages
2 total messages
Started by Gerd Hoeren
Thu, 20 May 1993 17:45
Re: shrink or enlarge X window
Author: 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
--------------------------------------
Re: shrink or enlarge X window
Author: Jim.Rees
Date: Mon, 24 May 1993 22:07
Date: Mon, 24 May 1993 22:07
11 lines
1027 bytes
1027 bytes
In article <9305201532.AA00319@ente.ims.com>, gerdh@ims.COM (Gerd Hoeren) writes:
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.
I like it! I recommend adding
(interactive)
after the doc string. Then you can bind it to a key or alt-x it.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads