Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joseph Wells) Newsgroups: comp.emacs Subject: Re: vi triumphs over emacs! ("bug" in emacs) Message-ID: Date: 17 Sep 90 01:10:04 GMT References: <9009111909.AA00518@next-8.gac.edu> <45656@cornell.UUCP> Sender: news@bu.edu.bu.edu Organization: Boston University Computer Science Department Lines: 71 In-reply-to: murthy@algron.cs.cornell.edu's message of 11 Sep 90 20:08:37 GMT >>>>> "Scott" == scott@NIC.GAC.EDU Scott> What happens is that I log into the system with a suitably large vt100 Scott> window, something like 80x72, and then eventually get into emacs to Scott> use gnus. Fine. But, since almost without fail I forget to do my Scott> stty rows call first, I end up with only a small window out of this Scott> huge one. Scott> So, what I attempt it ctrl-z out of emacs, stty rows 72, fg back in. Scott> This doesn't fix it. What I end up having to do is find the pid for Scott> emacs, and do: Scott> (sleep 5 ; kill -WINCH ) & Scott> fg Scott> after the stty, to get emacs to recognize the window size change. The following piece of GNU Emacs Lisp should handle your problem: (setq emacs-pid (save-excursion (set-buffer (get-buffer-create " *Emacs PID*")) (erase-buffer) (call-process "/bin/sh" nil t nil "-c" "ps -l$$") (goto-char (point-min)) (let (case-fold-search) (re-search-forward "[ \t]+PID") (let ((col (current-column))) (forward-line 1) (move-to-column col)) (read (current-buffer))))) (setq suspend-resume-hook (function (lambda () (call-process "kill" nil nil nil "-lWINCH" (format "%s" emacs-pid))))) Scott> Meanwhile, when doing various stuff at the command line, I tend to use Scott> vi (quicker, well, sort of). In vi, I can ctrl-z out of the editting Scott> session, stty rows 72, and fg back in, without a problem. vi detects Scott> the resize, and applies it. Wonderful, none of this sleep/kill Scott> hoopla. GNU Emacs unfortunately only interrogates the system for the screen size when it receives a SIGWINCH and on startup. >>>>> "Chet" == murthy@algron.cs.cornell.edu (Chet Murthy) Chet> As I understood it, the _CORRECT_ protocol is for the Chet> terminal-emulator to signal the process group leader for the Chet> slave-side of the pseudo-terminal with WINCH, to let it know that the Chet> window size has changed. That is what SIGWINCH was invented for. That's exactly what's happening. His shell is the process group leader of the terminal's current process group. Chet> So the problem seems to me to be with NeXT's terminal emulator, not Chet> Emacs. Nope. Chet> But you're right - this is an easy problem to handle. Of course, if Chet> there were a way to get the process-id of Emacs easily (within Emacs), Chet> and do a UNIX kill(2), you could just do the kill from within Emacs. Chet> But apparently that has been left out. About 2 seconds' hacking. There is a way to get Emacs's pid without starting another process, if CLASH_DETECTION was specified when Emacs was built. Then you can lock a file and look at the contents of the lock file to get the pid. (Gross, huh?) -- Joe Wells