escreen instead of elscreen for screen-like features in emacs

I’ve been using elscreen for screen-like features in emacs the last couple of years. However, I have a few complaints. Elscreen has issues when used with emacsclient -c: a new frame might not be created from the -c argument, which messes up my current screen in emacs, and the “Opening Server Files Always in a New Frame” tip on this did not resolve this issue perfectly with elscreen. Also, when used with emacs’ Desktop mode, I get an error when launching emacs with an Rnw file (Rweave, or Sweave) is in the file list; the launch actually does not load all files, and I have to exit and delete my desktop file (which I’ll lose the list of files).

I discovered escreen from this post a long time ago, and thought escreen was pretty lightweight and worked pretty well. However, I never switched to it because it didn’t have “tabs” for me to know which screen I was at. I didn’t realize the very same post had customizations that would show which screen you are at. I’ve copied his customizations, and added a few more of my own, which I’ll list here:

;; escreen is simpler than elscreen...but elscreen spawns new 0-9 set of screens for a new frame whereas escreen does not
;; it is better than elscreen because: elscreen has issues when using with emacsclient -c (does not always create new frame, messes up existing frame); in escreen, each screen has its own ring of recently visited files (good!)
(load "escreen")
(setq escreen-prefix-char "\C-z") ;;
(global-set-key escreen-prefix-char 'escreen-prefix)
;; add C-\ l to list screens with emphase for current one
(defun escreen-get-active-screen-numbers-with-emphasis ()
 "what the name says"
 (let ((escreens (escreen-get-active-screen-numbers))
 (emphased ""))

 (dolist (s escreens)
 (setq emphased
 (concat emphased (if (= escreen-current-screen-number s)
 (propertize (number-to-string s)
 ;;'face 'custom-variable-tag) " ")
 'face 'info-title-3)
 ;;'face 'font-lock-warning-face)
 ;;'face 'secondary-selection)
 (number-to-string s))
 " ")))
 (message "escreen: active screens: %s" emphased)))

(global-set-key (kbd "C-\\ l") 'escreen-get-active-screen-numbers-with-emphasis)

(defun escreen-goto-last-screen-dim ()

(defun escreen-goto-prev-screen-dim (&optional n)
 (interactive "p")
 (escreen-goto-prev-screen n)

(defun escreen-goto-next-screen-dim (&optional n)
 (interactive "p")
 (escreen-goto-next-screen n)

(define-key escreen-map escreen-prefix-char 'escreen-goto-last-screen-dim)

(defun escreen-create-screen-dim ()

(defun escreen-kill-screen-dim ()

(add-hook 'escreen-goto-screen-hook 'escreen-get-active-screen-numbers-with-emphasis)

(define-key escreen-map "c" 'escreen-create-screen-dim)
(define-key escreen-map "k" 'escreen-kill-screen-dim)

;; (global-set-key (kbd "C-]") 'escreen-goto-next-screen)
;; (keyboard-translate ?\C-[ ?\H-[)
;; (global-set-key (kbd "H-[") 'escreen-goto-prev-screen)
(global-set-key (kbd "C-]") 'escreen-goto-next-screen-dim)
(keyboard-translate ?\C-[ ?\H-[)
(global-set-key (kbd "H-[") 'escreen-goto-prev-screen-dim)

Whenever I create/kill/visit a screen, the minibuffer will always show the list of screens available, with emphasis on the current screen. I like escreen because it does not have the issues I listed before with elscreen. Also, in escreen, each screen has its own ring of recently visited files, so that if I move to a different screen and edit a buffer, move back to my original screen, kill the buffer, the recent buffer from the other screen will not be the default screen on this current screen.

I like escreen!

About Vinh Nguyen



  1. Hey, thanks for your config. Do you know how to make it show only buffers which belong to screen in C-x b, preferably with ido buffer switch support?

  2. Thanks for the pointer to escreen and the code for setting it up to show all active screens. I’ve used your setup almost verbatim, except I used advices instead of defining new functions and replacing the old one in keymap, such as:

    (defadvice escreen-goto-last-screen (after escreen-goto-last-screen-dim activate)

  3. I was also disappointed with el-screen. Main feature it was lacking for me was persistent save of sessions, so after I restart Emacs I can easily load back my window configurations.
    I haven’t found any substitute that will do so, so I wrote my el-screen –
    It’s written from scratch, uses GNU Screen key bindings (with difference that main prefix is C-z not C-a) and keeps configurations saved between sessions.
    It doesn’t provide it’s own recent-files ring, but it’s on todo list and shouldn’t be that hard to implement ;-)
    It also doesn’t provide any tab bar, but somehow I never found that useful. If needed I can easily check current screen name with “C-z i”.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>