[net.emacs] Executing a function when restarting Emacs.

chris@umcp-cs (08/11/84)

This is easy to do.  Restarting Emacs occurs only after pausing (or
running subshells with return-to-monitor).  Simply write something
like this:

(defun
    (my-pause-emacs
	(do-something-fancy)
	(pause-emacs)
	(do-something-else-fancy))
)

When you ``fg'' the Emacs, it will do whatever it says right after the
pause.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland

schnitzl@hplabsb.UUCP (Ray Schnitzler) (08/11/84)

Actually, both the pausing and the restarting is easy.

I, too, have #264 on 4.1BSD here.  

Here's an example of a way to do what you want.


(defun (newpause
	   (message "Do this stuff before pausing")
	   (sit-for 10)
	   (pause-emacs)
	   (sit-for 10)
	   (message "Do this stuff after returning")
	   (sit-for 10)
	   (novalue)
       )
)

Give it a shot.

-- 

	So remember to
	'Hang by your work,
	 and write if you get thumbs.'

				Ray Schnitzler, HP Labs
				uucp: ...!hplabs!schnitzl
				arpa: schnitzl.hplabs@rand-relay

marantz@null.DEC (Josh HL01-1/S07 DTN 225-4835) (08/13/84)

I use VMS and VMS Emacs now has standard variables "return-to-emacs-hook",
and "leave-emacs-hook" that can be setq'd to the functions of your choice,
but the way it used to be done was to write a new function that you bound
to ^X^Z or ^C or whatever as follows:

    (defun (hooked-pause-emacs
	(if (error-occurred (execute-mlisp-line leave-emacs-hook))
	    (progn
		(message error-message)
		(sit-for 20)))
	(pause-emacs)
	(execute-mlisp-line return-to-emacs-hook)))

The last line will be executed when the emacs is restarted.  This may
not work exactly on unix like it does on VMS, but the idea should be
similar.

phil@rice.ARPA (08/13/84)

From:  William LeFebvre <phil@rice.ARPA>

> The pausing part is easy: simply write the Mlisp code and bind it to the
> normal exiting or pausing keys. The restarting is a bit more difficult: when
> you restart a paused emacs, all it does is redraw the screen and put the
> cursor in the last used position. We would like to be able to execute a
> function every time emacs is restarted. My feeling is that there should be a
> variable (say "restart-function") that you could set to a string value, and
> that every time Emacs is restarted, it would do an (execute-string
> restart-function).

Presumably, the function that does the pausing calls the builtin function
"pause-emacs".  This function pauses the emacs and returns when the emacs is
restarted (or CONTinued).  This means that the function that does stuff
prior to pausing can also do stuff after the emacs is resumed.  It would
look something like this:

(defun
    (better-pause-emacs
	;;;  do preliminary stuff here
	(pause-emacs)
	;;;  do cleanup stuff here
    )
)

So you see, there is no need for the "restart-function" stuff.

                                William LeFebvre
				Department of Computer Science
				Rice University
                                <phil@Rice.arpa>

softech@othervax.UUCP (08/16/84)

[]
	We are using a 4.1 BSD port on a 780 with 264 Emacs. Most users have
the vanilla sea-shell (csh) as default and use VT100/131 terminals. We need
to do things of miscellaneous nature just before pausing (or exiting) and also
just upon starting (or restarting) Emacs. The pausing part is easy: simply
write the Mlisp code and bind it to the normal exiting or pausing keys. The
restarting is a bit more difficult: when you restart a paused emacs, all it
does is redraw the screen and put the cursor in the last used position. We 
would like to be able to execute a function every time emacs is restarted. My
feeling is that there should be a variable (say "restart-function") that you
could set to a string value, and that every time Emacs is restarted, it would
do an (execute-string restart-function). This would allow more flexibility in
doing things like re-configuring keyboards, etc. Anybody out there with any
kind of suggestions/solutions is welcome to mail or post.

Richard Blouin,
SofTech Inc.

...!philabs!othervax!softech