7

(I’m using emacs23; on Debian 7; Xfce.)

I want to try Gilles’s recommended solution for taking quick notes with Emacs.

When trying to run emacsclient -a "" -e "(remember-other-frame)", I get the following error:

*ERROR*: Unknown terminal type

What is wrong?


(Not really sure about what I’m doing,) I tried to start a server from within Emacs: Ctrl+x and entering server-start. Then it says:

Warning (server): Unable to start the Emacs server.
There is an existing Emacs server, named "server".
To start the server in this Emacs process, stop the existing
server or call `M-x server-force-delete' to forcibly disconnect it.

When pressing Ctrl+x and entering server-force-delete, it says:

Connection file "/tmp/emacs1000/server" deleted

When I now run emacsclient -a "" -e "(remember-other-frame)" from a different terminal window (having emacs -nw still running in the first one), I get:

emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
("emacs")
Loading 00debian-vars...
Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50a2ps.el (source)...
Loading /etc/emacs/site-start.d/50a2ps.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Starting Emacs daemon.
Emacs daemon should have started, trying to connect again
*ERROR*: Unknown terminal type

[Edit] Requested information

Output of echo $TERM; echo $DISPLAY:

xterm
:0.0

Are you running this from a terminal emulator, if so which, if not where?

I’m not sure what a "terminal emulator" is, but the terminal thing I’m using identifies itself (in the "Info" menu) as: Xfce Terminal-Emulator (Terminal 0.4.8). It’s the default one that came with installing Debian 7 + Xfce.


What do you have in ~/.emacs and ~/.emacs.d?

  • ~/.emacs does not exist.
  • ~/.emacs.d contains only a sub folder auto-save-list (which contains an empty file whose name starts with .saves).
4
  • Does emacs on its own print the same error?
    – Mikel
    Commented Mar 15, 2014 at 22:11
  • @Mikel: I can start emacs (opens the GUI) and emacs -nw (opens in the terminal) without errors.
    – unor
    Commented Mar 15, 2014 at 22:34
  • #worksforme. “Unknown terminal type” looks like a bad value for TERM, which isn't a common problem unless you've deliberately done something odd. Please post the output of echo $TERM; echo $DISPLAY. Are you running this from a terminal emulator, if so which, if not where? What do you have in ~/.emacs and ~/.emacs.d? Commented Mar 16, 2014 at 0:29
  • @Gilles: I added the requested info at the end of my question.
    – unor
    Commented Mar 16, 2014 at 0:43

2 Answers 2

11

Explanation of the bug

remember-other-frame calls switch-to-buffer-other-frame which calls display-buffer with the variable pop-up-frames set to t. This results in a call to make-frame with the argument pop-up-frame-alist. The function make-frame creates a frame on the same display device as the current selected frame. (What Emacs calls a frame is what GUIs call a window, except that a frame can also be in a text terminal.) At this point, Emacs is still running in daemon mode, so there is no selected frame. Thus make-frame sees no GUI environment and thinks it should create a terminal frame, but there is no text terminal either, resulting in the confusing error message “Unknown terminal type”.

Simple but clumsy workaround

remember-other-frame is the right function to call from within an existing Emacs window, but is technically wrong from emacsclient. There, we should be using the -c option to make Emacs create a new frame, and the plain remember function.

emacsclient -a "" -c -e "(remember)"

However this is not very nice because remember creates a window which has to be dismissed with C-c C-c (which is also what saves the note), then the frame has to be dismissed with C-x 5 0. If you forget C-c C-c (which is all the more likely because the message to type C-x 5 0 overwrites the message to type C-c C-c in the echo area), the note isn't even saved.

A nicer workaround

Instruct make-frame explicitly to create the frame on the current X display.

emacsclient -a "" -e "
    (let ((pop-up-frame-alist \`((window-system . x)
                                 (display . \"$DISPLAY\")
                                 ,@pop-up-frame-alist)))
      (remember-other-frame))"

You can put this all in one line, just make sure not to change the punctuation.

emacsclient -a "" -e "(let ((pop-up-frame-alist \`((window-system . x) (display . \"$DISPLAY\") ,@pop-up-frame-alist))) (remember-other-frame))"
1
3

If you can call (make-frame) directly instead, you can tell it to always create an X frame, which will avoid this error, e.g.:

(select-frame
 (make-frame
  '((window-system . x))))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .