0
votes

The excellent answer to the question How do I define an Emacs List function to spawn a shell buffer with a particular command executed in the shell weirdly does not work in a Gnu "screen" session. In the context of a screen command, instead of the command I tell it to execute,

echo 'test1'\n

, Emacs is called recursively! The would-be shell buffer contains the familiar "emacs: Terminal type "dumb" is not powerful enough to run Emacs" message.

How can I make this work? Here's what I did:

On the command line:

~  srn@basil{1}% screen -s run-emacs2

Here is the shell script run-emacs2:

#!/bin/bash
EMACS=/usr/bin/emacs23-x
export NO_AT_BRIDGE=1  ## suppress annoying gtk>2 warning
exec "$EMACS" -nw --load init.el.test -f spawn-shell

NOTE: If on the command line I say:

~  srn@basil{1}% run-emacs2

...everything works fine. The problem appears to be some interaction with Gnu screen.

Here is init.el.test (almost verbatim from the answer linked above):

(defun spawn-shell ()
  "Invoke shell test"
  (pop-to-buffer (get-buffer-create (generate-new-buffer-name "gzo")))
  (shell (current-buffer))
  (process-send-string nil "echo 'test1'\n"))
1

1 Answers

1
votes

It is expected behavior. According to the screen manual, the -s option is where to look:

-s program

Set the default shell to be program. By default, screen uses the value of the environment variable $SHELL, or /bin/sh if it is not defined. This option is equivalent to the shell command (see Shell).

The screen program sets the $SHELL variable to program (as part of opening a new window), and it is inherited in the subprocess, which in turn runs whatever $SHELL happens to be. Since you do not want that, the fix would be to modify the emacs script to reset $SHELL back to /bin/sh before running a "shell".