Hacker News new | ask | show | jobs
by kleiba 5644 days ago
Interesting timing: just two days ago, I spent a good part of my afternoon making "emacs -nw" running inside GNU screen to look more or less exactly the way my standard windowed Emacs looks. That included mostly fiddling with terminal settings and finding colors that are supported by the terminal and resemble my original choices (and some other tweaking here and there).

Now clickong on my Emacs icon on the desktop will open a new gnome-terminal that runs an Emacs inside screen -- it looks pretty much the same as it did before, but I can access and take over my current session remotely from home. As a matter of fact, the shortcut will actually first check if there's a detached screen session that runs emacs and ask me in a small dialog window if I want to re-attach to that session or start a new window.

Makes me happy.

Sorry if that post is of no interest at all to anyone else on HN but me...

2 comments

I use a similar setup with urxvt and stumpwm. In stumpwm I have

    ;; Launch emacs
    (defcommand emacs () ()
       (run-or-raise
        "urxvt -title emacs -e screen -U -dRR -S emacs -c ~/.screenrc.emacs"
      '(:title "emacs" :instance "urxvt" :class "URxvt")))
which will launch emacs (or raise it if it was already launched).

Some of the thing you might want to consider when doing "emacs -nw"

  - Make sure your TERM is exported appropriatly.
    Otherwise you may end up with less colors (M-x list-colors-display).
    Screen fiddles with TERM and emacs may end up supporting less colors.

  - Copy/Paste between regular X apps and the emacs will not work.
    You would need to use something like "xsel". See here [1]

  - Some of the keys may not work as expected. This will be 
    apparent especially when using orgmode. You may want to 
    remap them appropriately
And also I suggest you use Emacs + Wanderlust setup for email (and put it in a screen session as well).

[1] http://hugoheden.wordpress.com/2009/03/08/copypaste-with-ema...

Yes, these points are exactly the ones you have to pay attention to when running -nw. For instance, I run

    gnome-terminal -x /bin/bash -c /usr/bin/screen
instead of

    gnome-terminal -x /usr/bin/screen
directly, or else I get less than 256 colors (although more than 8).

Copy/Paste works fine for me in so far as that is one of the few things I use the mouse for. (I guess, in a lot of case you use the mouse anyway to select the text you'd like to copy.)

Remapping some keys is indeed necessary. In particular, GNU screen's standard escape key sequence is C-a, which in Emacs a lot of people probably prefer to be bound to (move-beginning-of-line). But also within Emacs some keys may need to be bound using input-decode-map.

As for your launcher, one thing I did differently is that my start script does not automatically re-attach to a detached screen session, but will show me a dialog window where I can select the one thing or the other. The reason for this is that I often keep a few Emacsen running in parallel for a long time, each of which is dedicated to a different aspect of my work. If I detach one session it is not always the case that I want to continue there the next time I open a new Emacs. Also, if more than one Emacs is detached I'd like to be able to say which one I want to re-attach to.

I looked at wanderlust a few years ago when I was looking for an IMAP-compatible email client for Emacs but in the end I wasn't convinced by it. Can't remember, though, what I didn't like about it, perhaps I should give it another chance.

Probably you are using x selection buffer for copy/paste. But if you want to pick up stuff from X "clipboard" buffer, you would need xsel or something like that.

Wanderlust is quite usable now. I use it everyday(I have my gmail and exchange server(imap) accounts managed in it). You should give it another try sometime.

That was interesting to me because today I also spent some time tweaking Emacs to make it work more like Textmate.
more like Textmate -> in what sense?