🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.emacs
Article #2137

Re: Re: Bogus transient windows in Unipress Emacs

#2137
From: Ken Manheimer
Date: Fri, 17 Oct 1986 00:54
122 lines
5904 bytes
>							    I, for one, got
> really tired of that stupid help buffer sucking up half the screen all the
> time.  Note, however, that the help buffer in Unipress 2.x is called "Help",
> and you can use it like any other buffer.  So if you want to look at the 
> help again, use your favorite "make buffer visible" function on it.
> -- 
>  Matt Landau      	 		BBN Laboratories, Inc.

I also am bugged by the way that pop-up windows operate in Gosmacs,
and went so far (when i had no alternatives) to run with
'pop-up-windows' 0, and use a refinement of split-window which
turns out to be much like the suite of functions bound to ^X-4 in
Gnu Emacs.  For instance, with pop-ups disabled (preventing them
from frequently disrupting my precious window-layout) the help window
*doesn't* show up when you do, say, an apropos (or completion
happens), so i could do a '^X-2-h', which produces the help window
in the second half of the current window (instead of superceding
one of my other windows).

Gnu Emacs' strategy of preserving a history of previously
superceded windows for easy recovery is the best answer i've
encountered, so that i don't hesitate to pop-up windows when using
it, knowing that i can recover displaced ones very easily.  One
further refinement i've developed is a 'preserve-excurse' function,
bound to ^X-' (with marginally mnemonic connotations as "quote-
environment"), that just does a recursive-edit within a
save-excursion so that i can go off, do arbitrary and incidental
things (sounds like fun, hmm?), and then pop back to the layout i
was working within.

In case anyone is interested, here are the functions i'm talking
about; first the mlisp refinement on split-current-window, called
'split-and', then the mlisp version of 'preserve-excurse', then the
elisp version of 'preserve-excurse'.  (In looking at split-and for
the first time in a while it strikes me i should have made the ^X-2
a prefix for a suite of functions, like Gnu-emacs ^X-4, but this
is good enough, i guess.)

Cheers!
Ken Manheimer.

(defun    
    ; this helper necessary for 'split-and'; it's true when the named buffer
    ; already exists.  This is necessary because use-old-buffer always will
    ; do completion, so plain (use-old-buffer "mai") can succeed with, eg, the 
    ; buffer "main", even when/though a buffer called "mai" doesn't exist.
    (buffer-exists q-buff
	(setq q-buff (arg 1 "Buffer: "))
	(save-window-excursion
	    (& (! (error-occurred (use-old-buffer q-buff)))
	       (= q-buff (current-buffer-name))))
	)
    (split-and suffix tobuf was-pop-ups
; This function is intended to provide an alternative to pop-up-windows.  It
; provides a refinement of the split-current-window functionality, and I
; suggest binding it to ^X2.
; I can't stand the way windows are mis-juggled with pop-up-windows engaged
; (in particular, the way help windows are left around and visit-files
; occlude an incidental buffer if more than two are on the screen), so I use 
; this function to put those behaviors at my discretion.  I find this scheme 
; *much* more convenient.
	(message
 "split-and: {`o'ld-`b'uffer, `s'ame; & `t'iny, `v'isit, `h'elp buffer, `!'}")
	(setq suffix (get-tty-character))
	(if (= suffix 111) 	; o
	    ; pop to an established buffer in the other half of current window:
	    (progn (setq tobuf (get-tty-buffer "(extant) Buffer: "))
		   (split-current-window)
		   (switch-to-buffer tobuf))
	    (= suffix 98)	; b
	    ; pop to an arbitrary buffer in the other half of current window:
	    (progn (setq tobuf (arg 1 "Buffer: "))
		   (split-current-window)
		   (switch-to-buffer tobuf))
	    (= suffix 115)	; s
	    ; split the current buffer in current window:
	    (split-current-window)
	    (= suffix 116)	; t
	    ; split the current buffer, tiny/large, in current window:
	    (progn  (split-current-window)
		    (previous-window)
		    (while (! (error-occurred (shrink-window))))
		    (enlarge-window))
	    (= suffix 118)	; v
	    ; Visit a file in other half of current window:
	    (progn (setq tobuf (arg 1 "File: "))
		   (split-current-window)
		   (if (buffer-exists tobuf)
		       (switch-to-buffer tobuf)
		       (visit-file tobuf)))
	    (= suffix 104)	; h
	    ; Expose the help window in other half of current window:
	    (progn (split-current-window)
		   (switch-to-buffer "Help"))
	    (= suffix 33)	; !
	    ; Execute cmd and expose results in other half of current window:
	    ; (Sorta silly finagling to prompt for command)
	    (progn (setq was-pop-ups pop-up-windows)
		   (setq pop-up-windows 1)
		   (pop-to-buffer "Command execution")
		   (setq needs-checkpointing 0)
		   (previous-window)
		   (setq pop-up-windows was-pop-ups)
		   (push-back-string "\^X!"))
	    (= suffix 112)	; p
	    ; Pop to shell in other half of current window
	    (progn (split-current-window)
		   (shell))
	    ; No such suffix:
	    (error-message "Aborted.")
	)
    ; Simple but useful:
    (preserve-excurse (save-window-excursion
			  (message "`^C' will resume pending window state")
			  (recursive-edit)))
)

Elisp code:
(defun preserve-excurse ()
  "Embark on a recursive edit within a save-window-excursion"
  (interactive)
  (save-window-excursion (recursive-edit)))
Technical Details
Message-ID: <433@nbs-amrf.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!nbs-amrf!manheime
References: <3948@amdahl.UUCP> <3473@mit-eddie.MIT.EDU> <1407@Diamond.BBN.COM>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!nbs-amrf!manheime
From: manheime@nbs-amrf.UUCP (Ken Manheimer)
Newsgroups: net.emacs
Subject: Re: Re: Bogus transient windows in Unipress Emacs
Message-ID: <433@nbs-amrf.UUCP>
Date: Thu, 16-Oct-86 20:54:06 EDT
Article-I.D.: nbs-amrf.433
Posted: Thu Oct 16 20:54:06 1986
Date-Received: Sat, 18-Oct-86 23:27:11 EDT
References: <3948@amdahl.UUCP> <3473@mit-eddie.MIT.EDU> <1407@Diamond.BBN.COM>
Organization: National Bureau of Standards
Lines: 122