[comp.emacs] "Suspending a program running in an X window is silly"

thoth@shark.cis.ufl.edu (Gilligan) (06/30/90)

  Dudes,

  How about binding ^Z to something useful when running under
X-windows, like x-iconify?  You say you don't have the function
x-iconify?  Try this!
	/* ICCCM compliant, see p 24-26, sec 4.1.4 */
  It also includes x-deiconify, a function that is hard to invoke
while the window is iconified, but we hope to hack it into the
emacs-client and -server stuff.

*** x11fns.c.orig Tue Oct 10 04:04:50 1989
--- x11fns.c Thu Jun 28 19:31:12 1990
***************
*** 828,833 ****
--- 828,879 ----
        return (Qnil);
  }

+ DEFUN ("x-iconify", Fx_iconify, Sx_iconify, 0, 0, "",
+   "this iconifies the emacs window.")
+   ()
+ {
+       XClientMessageEvent     xev;
+
+       BLOCK_INPUT_DECLARE ();
+       check_xterm();
+
+       xev.type = ClientMessage;
+       xev.send_event = True;
+       xev.window = XXwindow;
+       xev.format = 32;
+       xev.data.l[0] = IconicState;
+
+       BLOCK_INPUT ();
+
+       xev.message_type = XInternAtom(XXdisplay,"WM_CHANGE_STATE",False);
+       XSendEvent(XXdisplay, DefaultRootWindow(XXdisplay), False,
+                  SubstructureRedirectMask|SubstructureNotifyMask, &xev);
+
+       UNBLOCK_INPUT ();
+
+       XFlush(XXdisplay);
+
+       return Qt;
+ }
+
+
+ DEFUN ("x-deiconify", Fx_deiconify, Sx_deiconify, 0, 0, "",
+   "this de-iconifies the emacs window.")
+   ()
+ {
+       BLOCK_INPUT_DECLARE ();
+       check_xterm();
+       BLOCK_INPUT ();
+
+       XMapWindow(XXdisplay,XXwindow);
+
+       UNBLOCK_INPUT ();
+
+       XFlush(XXdisplay);
+
+       return Qt;
+ }
+
  XRedrawDisplay ()
  {
        Fredraw_display ();
***************
*** 892,897 ****
--- 938,945 ----
    defsubr (&Sx_rebind_keys);
  #endif notdef
    defsubr (&Sx_debug);
+   defsubr (&Sx_iconify);
+   defsubr (&Sx_deiconify);
  }

  #endif /* HAVE_X_WINDOWS */
--
( My name's not really Gilligan, It's Robert Forsman, without an `e' )

kpc00@ccc.amdahl.com (Kimball P Collins) (06/30/90)

This reminds me.  Does anybody else think that the version of ^Z that
gets compiled on machines without job control (the inferior shell that
uses the original terminal) is better than the version that gets
compiled on machines with job control (the superior shell)?

What is the advantage of the superior shell other than that one's
.cshrc/$ENV file is not read and that non-exported items are
available?  One of the advantages of the inferior shell is that one
starts out in the working directory of the current buffer, rather than
the wd at the time that one called emacs.

And, tangentially, has anybody else noticed that M-x shell is useless
with ksh because of its raw-mode features?  Are there hints on this?

(P.S. I quickly tell the difference between an inferior shell and the
superior shell because I have my prompts change for each invocation of
a subshell.  This helps to remind me that I am inside emacs and is an
advantage of the inferior shell, along with knowing that I have a new,
unadulterated shell.)

--

Not representing Amdahl nor necessarily myself.

milgr@teapot.prime.COM (Marc Milgram) (07/02/90)

In article <96AW02Cm01gU01@JUTS.ccc.amdahl.com>, kpc00@ccc.amdahl.com
(Kimball P Collins) writes:
|>This reminds me.  Does anybody else think that the version of ^Z that
|>gets compiled on machines without job control (the inferior shell that
|>uses the original terminal) is better than the version that gets
|>compiled on machines with job control (the superior shell)?
|>
I do, except when it is an X window, it should iconify instead of suspending.

|>What is the advantage of the superior shell other than that one's
|>.cshrc/$ENV file is not read and that non-exported items are
|>available?  One of the advantages of the inferior shell is that one
|>starts out in the working directory of the current buffer, rather than
|>the wd at the time that one called emacs.
|>
My .cshrc file is read when I invoke a new csh (or tcsh), unless I
provide some flag
(which emacs does not).

Two advantages to a superior shell: ^Z does what most other programs do
on a BSD system (they suspend).  Secondly, on such a system, you can start
multiple jobs from one shell, and switch between them.

About 4 years ago, I worked on a VAX running BSD 4.[23], with not enough
memory,
and too many users.  When I logged in I would start up emacs (took about
a minute).
When I wanted to use some other screen oriented program (such as talk(1)
or rogue(6),
I would suspend emacs and enter the program.  When I was taking an AI
course, (before
I discovered how nicely Lisp runs from emacs) I flipped back and forth
between emacs
and Lisp.  Lisp also took forever to initially start.

|>And, tangentially, has anybody else noticed that M-x shell is useless
|>with ksh because of its raw-mode features?  Are there hints on this?
|>
I don't use ksh.  why not try bash, or fix ksh.

|>(P.S. I quickly tell the difference between an inferior shell and the
|>superior shell because I have my prompts change for each invocation of
|>a subshell.  This helps to remind me that I am inside emacs and is an
|>advantage of the inferior shell, along with knowing that I have a new,
|>unadulterated shell.)

I needed to do some hacking to do this.  After all, my .cshrc is read
every time I reenter a
csh.  I had some global which was set to the depth of the shell.

|>
|>--
|>
|>Not representing Amdahl nor necessarily myself.
                       
Marc Milgram           My opinions are my own
milgr@teapot.prime.com

malis@bbn.com (Andy Malis) (07/02/90)

thoth@shark.cis.ufl.edu (Gilligan) writes:
>  How about binding ^Z to something useful when running under
>X-windows, like x-iconify?  You say you don't have the function
>x-iconify?  Try this!
> ...  C source code deleted ...

There's an even easier way to get a de-iconify function for your
emacs (or any other) window under X.  Put in your .twmrc file:

"L7" = : all : f.iconify

using your favorite function key.  L7 is the appropriately
labeled function key for Sun-3 keyboards.  No code involved!


Andy Malis <malis@bbn.com>    UUCP: {harvard,rutgers,uunet}!bbn!malis

charles@hpcvca.CV.HP.COM (Charles Brown) (07/03/90)

> This reminds me.  Does anybody else think that the version of ^Z that
> gets compiled on machines without job control (the inferior shell that
> uses the original terminal) is better than the version that gets
> compiled on machines with job control (the superior shell)?

I prefered forking a new shell over returning to the original.

> What is the advantage of the superior shell other than that one's
> .cshrc/$ENV file is not read and that non-exported items are
> available?  One of the advantages of the inferior shell is that one
> starts out in the working directory of the current buffer, rather than
> the wd at the time that one called emacs.

One of the advantages of inferior shells is that I could more easily
stack emacses.  If I was planning extensive editing in a directory but
afraid I might screw things up I would type "emacs *" and immedeately
fork out with ^Z and use emacs on the files I knew I wanted to change.
If I got to a plateau, (that is a place where things were working
again, but not really the ultimate objective) I would fork out again
and start over.  In this way I had a file history created as I went.
If my edits were successful I could simply exit from my shells and
emaces and therefore dispose of the history.  Perhaps this is still
possible, but I am not really proficient with job control.

> (P.S. I quickly tell the difference between an inferior shell and the
> superior shell because I have my prompts change for each invocation of
> a subshell.  This helps to remind me that I am inside emacs and is an
> advantage of the inferior shell, along with knowing that I have a new,
> unadulterated shell.)

So do I.  When I sit down to someone elses session to help them out,
it makes me nervous not having that information.
--
	Charles Brown	charles@cv.hp.com or charles%hpcvca@hplabs.hp.com
			or hplabs!hpcvca!charles or "Hey you!"
	Not representing my employer.