Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site rochester.UUCP
Path: utzoo!linus!decvax!harpo!seismo!rochester!koomen
From: koomen@rochester.UUCP (Hans Koomen)
Newsgroups: net.emacs
Subject: Re: Bug in Unipress Emacs
Message-ID: <2429@rochester.UUCP>
Date: Sat, 30-Jul-83 01:43:39 EDT
Article-I.D.: rocheste.2429
Posted: Sat Jul 30 01:43:39 1983
Date-Received: Mon, 1-Aug-83 04:57:17 EDT
Sender: koomen@rocheste.UUCP
Organization: U. of Rochester, CS Dept.
Lines: 96

From: Hans.Koomen
Yeah, I've often wondered about that wrap feature myself.
Here's my solution:

****************
(defun					; "HaKo 05-12-83"
    (window-width 80)	; should be built-in a la (window-height) !@#$%!

    (line-to-bottom-of-window	curpos prevpos nextpos
				lines2skip chars2skip physlines
	(setq chars2skip (window-width))
	(setq lines2skip (window-height))
	(setq curpos (dot))
	(line-to-top-of-window)
	(beginning-of-line)
	(setq nextpos (dot))
	(setq physlines  (+ 1 (/ (- curpos nextpos) chars2skip)))
	(setq lines2skip (- lines2skip physlines))
	(while (> lines2skip 0)
	       (previous-line)
	       (beginning-of-line)
	       (setq prevpos nextpos)
	       (setq nextpos (dot))
	       (setq physlines  (+ 1 (/ (- prevpos nextpos) chars2skip)))
	       (setq lines2skip (- lines2skip physlines)))
	(line-to-top-of-window)
	(goto-character curpos)
	(if (< lines2skip 0)
	    (scroll-one-line-up))))

****************

I use this function to force the last line in the shell buffer to stay
at the bottom of the window (simulating usual scrolling). Just in case
you wonder how: (process.ml)

****************
(defun
    (pr-newline
	(end-of-line)
	(if (eobp)
	    (newline)
	    (progn com
		   (beginning-of-line)
		   (if (looking-at shell-prompt) (region-around-match 0)
		       (looking-at lisp-prompt) (region-around-match 0))
		   (set-mark)
		   (end-of-line)
		   (forward-character)
		   (setq com (region-to-string))
		   (end-of-file)
		   (set-mark)
		   (insert-string com)
	    )
	)
	(line-to-bottom-of-window)	; "HaKo 05-12-83"
	(setq last-line (region-to-string))
	(region-to-process (active-process))
	(set-mark)
    )

    (shell
	(pop-to-buffer "shell")
	(setq needs-checkpointing 0)
	(if (< (process-status "shell") 0)
	    (start-filtered-process "csh -i" "shell" "more-shell-stuff"))
;	    (start-process "csh -i" "shell"))	; "HaKo 05-12-83"
	(local-bind-to-key "pr-newline" '^m')
	(local-bind-to-key "send-eot" '')
	(local-bind-to-key "send-int-signal" '')
	(local-bind-to-key "send-quit-signal" '^\')
	(local-bind-to-key "grab-last-line" "\e=")
;	(local-bind-to-key "stop-shell" "\e\^Z")
	(end-of-file)
	(novalue)
    )

    (more-shell-stuff				; "HaKo 05-12-83"
	(if (= (current-buffer-name) "shell")
	    (progn (end-of-file)
		   (insert-string (process-output))
		   (set-mark)
		   (line-to-bottom-of-window)
		   (sit-for 0))
	    (save-excursion 
		(temp-use-buffer "shell")
	    	(end-of-file)
	    	(insert-string (process-output))
	    	(set-mark)))))

****************


I know, it's a crock. Enjoy, anyway!

-- Hans  (Koomen@Rochester or ..!seismo!rochester!koomen)