www.bundesbrandschatzamt.de
Babblings about Systems Administration.

Emacs into the beyond

In the last 20 years I used a lot of programs but Emacs is still around. The one thing I regret: I should have started earlier diving into it. It’s 18 month since I started using git for my Emacs configuration. 180 commits - time for a resume.

Before I go into the details: A big “Thank You!” to the Emacs community. I learned a lot from other blog posts, youtube videos and code on github and last but not least twitter.

Even after a hard days work it’s still fun and pleasure learning more about Emacs and tweaking your configuration.

Beeing a systems administrator focused on automation Emacs is much more for me than just another text editor. It’s more like a complete environment.

TRAMP for example enables me to edit on remote files via ssh or with different privileges via sudo:

C-x C-f /sudo::/etc/fstab
C-x C-f /sudo::user@server

C-x C-f /sudo:ssh-host:file-on-ssh-host
C-x C-f /ssh:localhost#4000|ssh:10.2.2.4|ssh:10.5.5.5:/etc/nagiosconfigbuilder.yml

I can use the setup I am comfortable with and which I have highly customized for my needs. A good machinist builds his own tools. A good systems administrator should do the same - and definitely not stop at the editor.

orgmode alone has a lot of great features to make life easier:

Almost everybody uses git for version control. Magit makes live so much easier. Even though it’s possible to cherry-pick commits via command line I prefer the Emacs Magit way:

If you use git tags there is a good chance that you summarize the commits between each annotated tag. With a little bit of elisp Magit takes care of that for you.

You need to search for specific changes in your version control? git-timemachine is your answer.

Extending your Emacs is simple nowadays: M-x package-list-packages The learning curve hasn’t changed much. Getting used to new key-bindings takes still some time. I have my personal cheatcheet reachable via C-c F9 and guide-key supports my muscle memory and fading brain, too.

Trailing whitespaces or unbalanced parentheses? Let Emacs take care. Just don’t use it for file formats like YAML - there is a good chance you need your whitespaces. #! in the first line? Let Emacs safe the file as executable.

There isn’t much to tell you about helm: Install it!

As a systems administrator occasionally you have one of these days: You get some old config files or raw files and have to make new config files. That’s the moment of the keyboard macros! You split your screen into 2 windows. You start your keyboard macro. You do the first block while copying stuff from right to left frame. You end your macro. You run your macro maybe 500 times while drinking some coffee. Job done. There is even a macro counter. You can insert it within your macro. Every time you run your macro it increases by one.

Talking about copying strings: It’s called kill in Emacs jargon and you have a whole kill-ring. How many times do you have overwritten something in that clipboard with your average editor and the next second you wished you could reach the item you had before? With Emacs you can even include it in your save history.

Save save history can do much more for you: I have kill ring, search ring, regexp-search-ring, last-kbd-macro and kmacro-ring included.

If you write a lot a spell checker, a thesaurus and a reminder of weasel words are pretty helpful.

Sometimes it takes little to safe you a lot of time. For example dns-mode: It takes care of your serial number. If you edit your zone files via TRAMP this little function uses your existing ssh connection and runs rndc reload for you. No extra terminal, no extra ssh. No command to type. Just a key binding away.

There is some wisdom in the phrase that Emacs is an Operating System missing a good editor. Emacs is a virtual lisp machine. The editor is only a small part of it. Gnus, twittering-mode, Dired, ERC, eshell are only a view examples. Regarding the editor part: I am fine with it. It served well for me in the last 20 years and will probably do in the next 20 years, too. And I am quite sure: There will still be some unexplored land.