Category Archives: favpkg

My favorite Emacs packages, usually with a small description where I found them, how to install them and how I use them

Evening and day wear for Emacs

During the day, I like a light theme, but in the evening I prefer a dark theme. Off course it is possible to change my theme twice a day, but that gets old quickly, and be honest, who wouldn’t want to spend an hour on elisp to save a couple of minutes of drudgery?

wpid-men-42691_320.jpg

Emacs knows when it gets dark, or for the early risers, when it gets light (see: Sunrise/Sunset – GNU Emacs Manual), so from that it is possible to infer when to switch themes.

As it happens, Joshua Griffith figured that out as well and put theme-changer on github:

Description: “Given a location and day/night color themes, this file provides a `change-theme` function that selects the appropriate theme based on whether it is day or night. It will continue to change themes at sunrise and sunset.”

I like to install my stuff through el-get, but there is no recipe yet, so I createda recipe and installed the package:

(:name theme-changer
       :website "https://github.com/hadronzoo/theme-changer"
       :description "Minor mode for editing WordPress files with Emacs."
       :type github
       :pkgname "hadronzoo/theme-changer"
)

Configuration

Setting up theme changer is very simple, it needs a location, so it knows when the switch themes, and two themes, one for the evening and one for the day.

First, configure your location:

(setq calendar-location-name "The Hague, Netherlands")
(setq calendar-latitude 52.0799)
(setq calendar-longitude 4.3111)

Next we require theme-changer and set the themes we want to use (make sure they are installed already).

(require 'theme-changer)
(change-theme 'solarized-light 'solarized-dark)

And now all that’s left is to wait until sundown…

After using it for a while

How does it actually work? So far not too bad. Themes automatically switch, but if my laptop is closed while Emacs is running switching does not work, and switcher gets confused. So far I play around with color-themes a bit too much, and switching is not too stable. The best solution is restarting Emacs, which takes only second or two, so that’s what I do.

Overal: nice package, will keep.

Shaving time with goto-chg

Through Irreal I found Arne Babenhauserheide’s Emacs configuration. His setup is glean-friendly, using Org-babel. Literate programming is great for config-files. It is probably the best way for people to actually comment their configurations.

shaving and saving time

goto-chg

Arne has lots of little things I want to try. The first one goto-chg is a must-have. From the package:

Goto the point of the most recent edit in the buffer.
When repeated, goto the second most recent edit, etc.
Negative argument, C-u -, for reverse direction.
Works by looking into buffer-undo-list to find points of edit.

I love such packages, they help, but don’t get in the way. If you open a file, you have to start somewhere, so why not at the last place you changed something? Brilliantly simple! It is not a big change, but it will shave a couple of seconds here and there when you revisit a file you edited before, and now you need to make another small change.

As Arne says: “And then you get used to it and it becomes absolutely indispensable.”

Install it (I used el-get) and configure it:

;;(package-require 'goto-chg) ;; you might need this
(global-set-key [(control .)] 'goto-last-change)
; M-. can conflict with etags tag search. But C-. can get overwritten
; by flyspell-auto-correct-word. And goto-last-change needs a really
; fast key.
(global-set-key [(meta .)] 'goto-last-change)
;;(global-set-key [(control ?,)] 'goto-last-change-reverse) ;;I don't use this

That’s it! Simple, but a great time-s(h)aver.