· by [Joakim Verona] · Read in about 7 min · (1480 words) ·

Zen-mode overview

zen-mode is Emacs is a concentration aid for Emacs.

Zen-mode provides different zen-states, which manage different aspects of Emacs and your environment.

I use F11 as a pefix key for zen-mode. My prefered bindings can be installed with m-x zen-keys.

F11 means full-screen in many applications, and one zen-aspect is fullscreen.

With zen-mode you bind a set of zen aspects to a zen state.

Here’s the default keybindings:

l zen-less m zen-more zen-set-state p zen-pommodoro

So, normaly you load zen-mode, and nothing happens. Then, when you are ready to achieve zen, you press m. Repeat until desired state is reached. When you want to descend back into the world l.

zen aspects

Zen states are created using Emacs themes, so you can bind any customizable variable value to a zen state. Zen mode adds a couple of customizable features.


Enter fullscreen. Applications that are not Emacs are not Zen. (Although you can cheat and embedded other applications in Emacs. See the Emacs Xwidget branch)


Wordly urls that you can’t visit in a Zen state. I use Polipo as a http proxy, and zen-mode creates rules for it using this feature.


A sound of your choosing that helps you achieve Zen. I use a binaural beat mixed with the sound of the Shinkhansen train.

standard Emacs features that Zen can set

Various Emacs decorators that are not Zen: ‘(scroll-bar-mode nil) ‘(menu-bar-mode nil) ‘(tool-bar-mode nil) ‘(mode-line-format nil))

You can use whatever customizable variable you want.

zen themes

zen-mode has a couple of default zen themes. They are ordinary Emacs custom themes.

The Zen themes are stackable, so when in zen state 3, themes zen-1 zen-2 and zen-3 are applied.

default zen themes

  • zen 0

    zen-mode is disabled

  • zen 1

    ’(zen-fullscreen-mode t))

  • zen 2

    ’(scroll-bar-mode nil) ‘(zen-fullscreen-mode t) ‘(zen-encumbered-urls (quote ( «#brief timewastes» «www.penny-arcade.com» «www.dilbert.com» «www.xkcd.com» «www.userfriendly.org» «#news waste» «slashdot.org» «dn.se» «#social timewastes» «https://www.facebook.com»))) ‘(menu-bar-mode nil) ‘(tool-bar-mode nil) ‘(mode-line-format nil))

  • zen 3

    ’(mode-line-format nil))


TODO Currently Zen mode cant see the difference between a maximized

frame and a fullscreen frame. This is because of a limitation in Emacs, which will be fixed future-ish. The end result is that currently Zen will probably not do what you expect if you enter zen while in a maximized frame.

doesnt remember previous window size and position always

CANCELLED There are some problems in the Compiz WM, (and maybe other WM:s)

regarding fullscreen: When selecting another workspace temporarily and going back, Emacs does not cover the wm panels as it should. This can be resolved with alt-tab a bit, but its annoying. In Metacity it works well. Maybe Zen could learn to work around these WM:s

(cancelled because it doesn’t happen lately)

TODO features annoyingly wind up in the user theme

customize troubleshoot sometimes variables I want in the theme winds up in the customizations.

also custom-enabled-themes gets out of sync: ‘(custom-enabled-themes (quote (zen-2 tsdh-dark))) so, when emacs is restarted, zen-2 is set, but zen thinks the level is 0.

the user-theme has higher precedence than other themes which is counterintuitive.

TODO theme load path confusion

;;;###autoload (add-to-list ‘custom-theme-load-path load-file-name)

custom-theme-load-path: (»home/joakim.emacs.d/jave/git/zen-mode/» «home/joakim.emacs.d/elpa/color-theme-solarized-20121209.1204/» custom-theme-directory t)

;;;###autoload (add-to-list ‘custom-theme-load-path load-file-name t)

new features

TODO play trance inducing track with EMMS

I have my (emms-play-file «/home/joakim/build_myprojs/sbagen/examples/jave/ts-brain-delta-nopink.sbg»)

DONE more states that accumulate

stackable themes CLOSED: [2012-06-27 ons 18:57]

DONE zen-more and zen-less

DONE Levels of Zen-ness. Quickly enter zen with different

predetermined settings. (c-u NUMBER m-x zen-mode), NUMBER is the Zen state. The features for each state is configurable

DONE utilize custom-themes

The custom theme code in Emacs 24 is nicely demonstrated by color-themes. Re-use this facility and scrap Zen:s limited in-built feature.

themable: scroll-bar-mode menu-bar-mode tool-bar-mode

needs work: frame-mode

«Allow more than one theme at a time» enable-theme custom-theme-load-path customize-create-theme `:set SETFUNCTION’ custom-theme-visit-theme

although one could have any number of zen-states, I want a couple of usable defaults.

  • zen-master

    3 Zen-master mode, like writeroom mode. it turns all distractions off, including modeline. (setq mode-line-format nil) (setq-default mode-line-format nil)

  • zen-deep

    2 no menubor toolbar or scrollbar. fullscreen

  • zen-light

    1 maximized

  • zen-wordly

    0 all zen-ness is disabled.

DONE encumbered URLs

polipoli is a webproxy which has a forbiddenurls feature, which is a file with regexps of forbidden urls. zen can handle this with customize. The config file will be generated and the file reloaded.

each url shall have a zen state. This could possibly be managed as a theme variable.

a problem is that the configuration and reload requires root privileges on Fedora(and thus probably many other distributions also)

/etc/polipo/forbidden pgrep polipo|xargs kill -SIGUSR1 service polipo reload

curl -m 15 -d ‘init-forbidden=Read%20forbidden%20file’ http://localhost:8123/polipo/status?

TODO let emacs run polipo

its more convenient if emacs controls the polipo proxy. why?

  • its a personal proxy anyway
  • there is less hassle with permissions of configuration files
  • polipo needs to be restarted occasionally
    • when nic changes
    • if restart is used rather than curl when the forbidden file changes, you dont need curl

m-x zen-polipo-start should also ask restart if there already is a running instance.

TODO support https encumbering

polipo can also encumber https urls but that requires a new file + a polipo patch entering the polipo repo soonish maybe.

TODO encumbered buffers

you can’t visit particular buffers, like maybe the Gnus buffers.

TODO advice some modes like ERC so as not to

interrupt while in Zen, also dont Gnus while in Zen. You are supposed to concentrate :)

TODO procrastination inhibitor. Enter a Zen state and dont leave until

youv’e actually produced someting useful. For instance, 15 minutes must pass and some useful buffer must grow by a number of bytes before you can begin wasting time again.

TODO implicit zen state shifting

lessening neurological procrastenating reward.

Its easier to describe with an example. You want to Gnus rather than do whatever more fruitful endeavor you are doing. Gnus is inhibited in your current zen state. However, you don’t need to change zen state manually to go to a zen state where Gnus is allowed. It is done automatically. You do, however, have to suffer a synthetic 30 second delay before arriwing in the Gnus buffer. Zen state is changed automatically after that. If you quit before the delay expires you stay in your current zen state.

TODO anti procrastenation timer

  • DONE emacs quick challenge timer against procrastination

    i had the idea to do this myself but it was already done. http://www.emacswiki.org/emacs/work-timer.el depends on todochiku which sends popup msgs with growl, which seemed to work immediately.

    (require ‘work-timer) (require ‘todochiku) (work-timer-start)

  • DONE zen timer/pommodoro timer

    The pommodoro method is very simple. You use an egtimer, and during the egtimers 25 minute run, you do whatever you are supposed to do. When the eggtimer rings, you can procrastinate for a while.

    I have used this method successfully with Emacs and org-mode for some time. (there is org-pommodoro.el, but it didnt exist when I started, but there was a simple Emacs timer example floating around.)

    I usually also enter Zen at the same time manually, but this should be done automaticaly. Also I might not necessarily log all pommodoros in org, altough neat, there is sometimes no immediately obvious org node to log time in, which increases the threshold for pommodoro.

TODO control erc state

busy in higher states etc

TODO integrate with the Neurosky Mindset

there is an initial attempt with (zen-neurosky)

TODO set background colours

so, in high zen, background is red for instance.

DONE ELPA package

ELPA packaging would make it easier to install the custom themes. A marmalade package was made.

DONE kill neural reward for aimless surfing

try using polipo as web proxy. it has a feature to disallow urls. w3m can then use direct connection. chrome or firefox won’t.

/etc/polipo/forbidden port 8123

theres an interface at http://localhost:8123/polipo/status?

forbiddenfile can be a directory that is scanned for files with rules.

zen-mode could handle enabling/disabling of distractions, thus also the forbidden file.

Added: [2011-03-03 tor 09:44]

TODO zen dimensions

I had a small prototype called now.el. It turned out that it was basically the same as zen, but slightly different. now I want to merge them somehow.

Zen was to begin with just a stackable set of emacs themes.

Now was some commands that you want to run depending on what you are doing. So, now-at-away-wifi, sets up your laptop for being away and using wifi.

Zen Dimensions, then, is the unification of these ideas:

  • Zen: how concentrated you are supposed to be
  • At: where you are, and how that affects your work

At is tentatively supposed to be a set of eieio classes that you can join to form different behaviour. so, m-x zen-at-work, sets up your laptop to use a 4G connection, and vpn to your private net for instance. This you must set up yourself, using some macros, and eieio inheritance.

tentative dimensions:

  • zen: level of allowed distractions
  • at: where you are
  • pommodoro: