0

I am trying to launch Emacs through a keyboard shortcut on my Debian/xmonad system. Relevant lines from my xmonad.hs:

~$ cat .xmonad/xmonad.hs
import XMonad

...

main =
  xmonad =<< xmobar
  (defaultConfig {modMask = mod4Mask, terminal="gnome-terminal"}
   `additionalKeysP`
   [ ("M-e", spawn "emacs"),
     ...
   ])
...

~$ xmonad --recompile
~$

(and even restart, I'm just proving minimal sanity here)

When I use the keyboard shortcut, nothing happens and if I inspect my .xsession-errors I can see:

~$ tail -n1 .xsession-errors 
emacs: standard input is not a tty

If I just start Emacs from the terminal I go in "terminal mode".

Finally:

~$ echo $DISPLAY
:0.0

How can I further debug this?


Further version info:

$ apt-cache policy emacs
emacs:
  Installed: 46.1
  Candidate: 46.1
  Version table:
 *** 46.1 995
        995 http://ftp.se.debian.org/debian testing/main amd64 Packages
[...]
$ apt-cache policy emacs-nox
emacs-nox:
  Installed: (none)
  Candidate: 46.1
  Version table:
     46.1 995
        995 http://ftp.se.debian.org/debian testing/main amd64 Packages
[...]
$ emacs --version
GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
aronisstav
  • 129
  • 7
  • 5
    Has Emacs been compiled with GUI support? How did you install it? – phils May 04 '16 at 10:54
  • 3
    Is this an Emacs problem or an xmonad problem? If the latter, we might want to migrate you to the Linux and Unix sister site. – Dan May 04 '16 at 13:30
  • 3
    I'm voting to close this question as off-topic because it belongs on http://unix.stackexchange.com – jch May 04 '16 at 19:25
  • @phils This is Emacs version 46.1 from the Debian repositories. – aronisstav May 04 '16 at 22:10
  • @Dan I had posted the question on both unix and super user stackexchanges, got no comments in more than 10 days on either site except for the suggestion to try it out here (and couldn't be migrated cause it was already migrated once). – aronisstav May 04 '16 at 22:14
  • @jhc Sure, but you may want to consider flagging it for migration instead. In either case see my previous comment, too. – aronisstav May 04 '16 at 22:15
  • 1
    aronisstav: I've no idea what version 46.1 means (Emacs 25 is in pre-release right now), but if it's a debian package then I suspect you've only installed the emacs-nox (I think it's called) package. 'nox' being 'No X support'. – phils May 04 '16 at 22:18
  • @phils Good guess, but no, I haven't, as you can see in the version info I have added to my question. – aronisstav May 04 '16 at 22:23
  • 1
    Have you tried emacs -Q? If you've got a properly installed emacs, running the command emacs should start the GUI version. It looks like you do have the GUI version installed, so the fact that it is opening in 'terminal mode' suggests that maybe there's something in your config that's explicitly requesting the non-GUI version. Maybe :/ – Tyler May 05 '16 at 01:31
  • 1
    The Debian package emacs is a meta package, so we still don't actually know which emacs you have installed. You can lookup the variables system-configuration-options and system-configuration-features to see how your emacs was build. Just in case, try type emacs to see which emacs binary gets called. – YoungFrog May 05 '16 at 05:41
  • 1
    What if you try: ("M-e", spawn "emacs < /dev/tty") or whatever the appropriate way would be to write this in XMonad? – wvxvw May 05 '16 at 10:28
  • Many of these comments could also work as actual answers to "how I can debug this further", mind you! :) – aronisstav May 05 '16 at 11:14
  • @Tyler emacs -Q starts Emacs with a different colour scheme, but still no GUI. – aronisstav May 05 '16 at 11:15
  • @YoungFrog type emacs returns emacs is hashed (/usr/bin/emacs). The system-configuration-options, when viewed from the console version has a --with-x=no, but I think that's reasonable (it's the console version after all). – aronisstav May 05 '16 at 11:19
  • @wvxvw Running this from a gnome-terminal takes me to the console version. Running it from the gmrun topbar does nothing. – aronisstav May 05 '16 at 11:23
  • 1
    @aronisstav AFAIK It is a configuration option set when building Emacs, so you really seem to have a nox version of Emacs. Write a wrapper to start Emacs within a term emulator or install a GUI Emacs. – YoungFrog May 05 '16 at 11:36
  • 1
    Setting Emacs' input explicitly to /dev/tty was meant to get rid of the .xsession-errors message (though not necessarily to eliminate the problem altogether). Do you still get the "input is not a tty" error after you've done that, or is it a different error? Mind you that I don't know what is the correct way to set input for XMonad version of invoking a command, maybe you need to look up its docs to figure out why it's not doing that / what should be done to do that. – wvxvw May 05 '16 at 11:48
  • @YoungFrog Indeed! On another machine the console version reports --with-x=yes. Let's see what I can do further... – aronisstav May 05 '16 at 11:48

1 Answers1

2

Managed to find a solution with the help of some comments, so here's an answer:

@YoungFrog suggested I check the value of system-configuration-options (with C-h v) which revealed that the Emacs version I was running was configured with the --with-x=no option. This is a global setting, not related to the fact that I was reading the variable from the console.

This prompted me to try and reinstall the package, and I found out that @phils was right all along, as it turns out I had emacs24-nox (but not the metapackage emacs-nox) installed. Why was this one preferred over the plain emacs24 eludes me... Removing emacs24-nox automatically selected emacs24 and the problem was resolved.

aronisstav
  • 129
  • 7