My start to Emacs/Spacemacs

In this post I’m going to share my experience with Spacemacs – a GNU emacs configuration – and how it became my main editor from the first start. I will try to mention all those little things that I found convenient but had to discover myself, as I could not find them in a comprehensive guide.

My personal editor history

I have always been a vim guy. I was taught vim during my Physics and Computer science studies, meaning: I had to learn it to pass the course, we even had tests. I’m glad we did though, it’s a great editor and once I got used to the keybindings (I still figure out some cool tricks from time to time) I never wanted to use anything else anymore – and no mouse of course.

I use that keybindings everywhere I can, in my i3 environment, in mutt, or when browsing with Palemoon and the Pentadactyl plugin.

When doing larger coding projects, some functionality has to be added to vim though (for my taste), to make the editor more convenient and to solve simple and repeating tasks quicker. I found vim to become quite slow when packed with too many plugins, especially with Python auto-completion / introspection it was no fun to use anymore.

So I switched to sublime text, an excellent editor in my opinion – providing vim mode, hackable with Python code and very much customizable with json style settings. I loved it and still would use it, if only there wasn’t this little sting all the time; Although free to use, Sublime text will remind you every X savings you do, that you can buy a license (which is not even very expensive, 70$ for a superb product). This gave me a little stitch, not because good software has a price, but because it reminded me that I’m using non-free software again. So I decided to give GNU Emacs another try.

I had installed Emacs on my system before to check out what’s so nifty about it, that you would use it in favor of vim. I worked through the tutorial (which I can recommend to everyone, since you will meet Emacs keybindings everywhere – the Bash is my favorite example). However, the permanent use of the Ctrl and Alt/Meta key felt so inconvenient for me as vim user, not even evil mode could help it, and I abandoned Emacs.

I learned about Spacemacs in a #dgplug session and gave that a try. I was skeptic at first, but it turned out that Spacemacs felt so intuitive and convenient from the first use, that I stopped using any other editor in an instant.

Spacemacs

Spacemacs is just a configuration for Emacs. That was important to me, I did not want to loose compatibility to other Emacs set-ups and enjoy the full Emacs experience. Also I would be lost if I couldn’t google for solutions to problems in classic Emacs forums.

However, the layer of abstraction that Spacemacs adds to Emacs is obvious. In Emacs, you can add features by adding a major mode and various minor modes to your buffer, and design a specific environment for all your specific tasks. That’s either copy and paste someone else’s config file to your own, or quite some time of fiddling with lisp.

Spacemacs does this by providing configuration layers, that will set up the major and minor modes and other things in the background for you already. So far I find this very convenient with nothing to miss for a nice workflow, no matter if I do Python coding, R scripting or writing my blogs or ToDos.

First things first

Installation was quite straight forward, following the steps on the Github page. I use Spacemacs with the helm (fully featured) distribution in evil mode (you will be asked for your preferences during first start-up).

I updated my configuration layers by editing the config file: space f e d for file -> emacs -> dotfile I commented in all of the configuration layers that were out-commented per default, like autocompletion better-defaults git markdown and org etc. and added some others for my daily work: python, django, latex, ess (which is the R layer).

Although I added some snippets to my config file, I did not change the default behavior or keybindings, so everything I write here refers to default settings.

Basic usage

Spacemacs commands mainly can be triggered using the Space key. A menu will pop up with keys and descriptions of options you have next. File operations, for example, can be accessed with f, so space f will lead you to another menu with options on file procedures. Another f press will let you open a file. Again it is useful to have at least a little Emacs background knowledge, so find file will not sound familiar to you and the space f f keybinding makes sense all of a sudden. This command opens a file on your disk. space f s will save your buffer to the file. It’s so intuitive, your fingers will almost move by themselves.

Similarly, space g will bring up a git (magit) menu (the best interface to git I have ever seen, by the way), given you have activated the git configuration layer in your dotfile.

With the projectile mode, space p shows options related to projects – e.g. every folder that contains a .git folder is considered a project. space p f will trigger a fuzzy search on files all over that project folder and sub-folders. I loved the ctrl+shift+p keybinding in Sublime text, that just did that and was happy not to have miss that feature. space m shows the options of your currently activate major mode. In Python mode for example, it will provide me with options of jumping to definitions, open a REPL, execute code, etc. Since the major mode may be used quite frequently, you can just type , to abbreviate the space m (it sounds ridiculous but it’s really nice to have).

In Emacs, you can assign keybindings to every function or macro of your choice. The keybindings change with the modes you activate, and of course they can be changed in your config files individually. To me, this seemed very chaotic and I found it difficult to remember all those key combinations. You can however call every function by name (given that you know the name). Spacemacs let’s you do the same thing, but by default lets you search for the desired function with a nifty fuzzy search. You can trigger that either with the original Emacs Alt x keybinding or by pressing space space. I do that very often for functions I don’t need to remember the key combinations, because I don’t use them too often. With the org2blog module, for example, I can login to my wordpress account to publish the post with only a few keystrokes from within Emacs. I simply type space space login to choose and execute the org2blog/wp-login function and space space publish to trigger org2blog/wp-post-buffer-and-publish.

In general, Emacs provides an excellent help, if you know how to pull it up. You might already guess it, you will find all help related options with space h. Here you can choose e.g. space to learn about the Spacemacs specific options and configuration layers. But what’s really cool is what you’ll find under space h d (for help -> describe). Here you can find help on any function f, mode m, package p and many more. Particularly helpful: space h d b let’s you fuzzy-type a function and shows you the keybindings to it. The other way round space h d k will let you type a keybinding to show you the documentation of the function it triggers.

Org mode

A comprehensive guide to org mode is by far beyond the scope of this blog post, but I wanted to mention this in particular, since it’s something non-emacs users hardly ever get to know.

Org mode is something I read of before, but never really could make sense of. Maybe that’s because it’s so versatile. It’s structured text very similar to markdown or rST; similarly you can export your .org files to a variety of formats (latex/pdf or beamer, html – plain or even with twitter bootstrap css and js, open office odt and many others). It also provides functionality to manage ToDo lists and agendas, schedule tasks and record progress. Writing tables and formatting any kind of text is super easy. What I find a very cool bonus: it is rendered by Github to perfectly beautiful sheets.

I went over to use it for my tasks at work but for my private appointments as well. The , to trigger the major mode commands comes very handy again.

You can create items with a simple asterisks. shift right/left will let you cycle through the todo sequence, so you can mark an item as TODO or DONE ect. You can nest those items with more asterisks, give them tags and define deadlines or schedule your tasks. To schedule you simply press , s, which will bring up a calendar to choose from. The interface is smart enough, however, to recognize most notations you type. To schedule the task for the next day, you could write +1, to put it on next Monday just type Monday (or even just mon) and hit enter. Type 1 sep if you want to schedule for September 1st. Same thing applies for deadlines , d.

You can have an arbitrary number of org files with tasks and ToDos of different domains. I have one for work and one for private stuff. With ctrl+c [ you can bring an org file to your agenda (actually I haven’t found a Spacemacs keybinding for that, yet). Your agenda can show you scheduled tasks and deadlines for the current week or provides other views and filters to not loose track. You can bring it up with , a a while in org mode (remember that , triggers major mode commands) or with space a o a (for apps -> org -> agenda) from any buffer and mode.

This blog is written in Org mode and transferred to WordPress.com with the org2blog module. All I have to add are some meta information. This can be done using the #+ tag. #+TITLE: <my title here> will add a title to my blog post.

elisp

Again, I cannot go into detail, describing lisp or emacs lisp (elisp) here. For those who don’t know lisp, it’s a quite old functional programming language, with a lot of parentheses. It’s quite powerful, although I still find it hard to read. @shakthimaan gave an excellent starting point for elisp coding in a dgplug session.

If you use Emacs, I dare say you won’t be able to avoid elisp completely, if you want to customize the editor a bit to your needs. Emacs itself is largely written in lisp and is fully hackable if you know that language. Using Spacemacs, you probably won’t get in touch with elisp that often or intensively. If you want to add a configuration layer in the dotfile, you basically add an item to an elisp list, but you’ll hardly notice. Still, I would recommend to everyone to dive into that language if you consider using Emacs or Spacemacs for you all-day work. Apart from the fact that it’s a fascinating and historically important language, it will make your life easier if you know what you’re doing. The basics (syntax, builtin datatypes and functions) are learned quite quickly; the real big deal is about learning the third party functions – I’m still too new to the language to be able to oversee the countless possibilities, but I will dive deeper into it some time.

Advertisements

My children and feelings

I wanted to write this down for many years now. It is about an amazing and overwhelming feeling, but with a frightening and sad taste. I still feel it now, after more than 4 years, like the way I felt it back then. It first appeared when I had a look at my new born oldest son for the very first time.

A child in time

I am incredibly lucky to have three healthy beautiful wonderful children, all of which gave me that feeling and still do.

They were born as perfect little beings. Flawless, without any scratches or scars, just complete and pure. Unnecessary to mention, I was happy and proud as can be, but one thing I knew from the start: From now on I would have to sit powerless and watch how time passes by my children and how scratches, scars breaches and whatsoever would be added to their perfect skins and bodies. Together with my children a fear was born that I know I will carry for the rest of my life; Sure, I will put anything into protecting my children from any harm as good as I can. I don’t have the illusion though, that I can protect them from all harm. This will become a constant struggle with my children and my fears, which they will not be able to understand until they have children themselves.

Furthermore I realized that it’s not only their bodies; They were born with a clean and pure mind and soul as well; both awaits a similar path. The tremendous task to protect three little bodies minds and souls from getting wounded, scarred or worse lies now upon me.

A word on time healing wounds

That’s what they say. However, I don’t think that time actually heals wounds, neither physical nor mental or emotional.

I imagine a soul as a beautiful landscape. Life with its ups and downs will add valleys and mountains to it, forming a unique personality. However, deep wounds will cut deep craters and gorges, or just burn things down. We can try to build bridges over crates and gorges and patch things. We can try to grow new things on the ashes and with time the tracks of wounds will become weaker. It will nevertheless not heal fully. You will see evidence of all these wounds if you took a cross-sectional view of a density distribution – a quake may tear open old wounds easily anytime.

Finally

This has been on my mind for quite some time now. When re-reading, it sounds pretty cheerless to me. But that’s not true; living means using the body, mind and soul. Life will inevitably leave its on them. This is what life is bears by default. I want my children to live, so that’s okay. They still are and always will be the most beautiful things I’ve ever seen and ever made myself, and they make me happier as anything else could do.

Community and Huntington’s Disease

So far, I’ve written about my experience with free and open software, coding and the like. However, in real life I am a physicist and researcher.

While I really enjoy being/becoming part of an incredible community of coders, hackers and activists, I realized that I already am part of a great community that I want to shed some light on here.

On Huntington’s Disease

I work in the George Huntington Institute (GHI) in Muenster, Germany. It is the first institute dedicated for research in Huntington’s Disease and clinical care for people suffering from Huntington’s Disease.

Now, what is Huntington’s Disease (or HD)? Scientists might say, HD is an autosomal dominant neurodegenerative disease that is caused by an overlengthy CAG repeat on the short arm of chromosome 4.

Here is what that means: The disease is inherited. A person with the gene mutation has a 50% chance to pass the disease to the children (if both parents are affected, the chance is 75%, if both chromosome arms are affected (homozygote) the chance is 100%). People with that specific gene mutation will get the disease. Depending on the CAG (the armino acids cytosine adenine and guanine) repeat length, they may start showing symptoms between an age of 30 and 50. Very long repeats even cause a juvenile disease type that shows symptoms in early ages, with a vast disease progress and early death.

While the complete pathways of the disease are not fully understood yet, it is assumed, that the gene mutation causes a production of a misfolded proteine (Huntingtin) with a toxic effect, that causes cell death especially on neurons, causing brain cell athrophy. Developing symptoms by the age of around 40 is the most common case. With constantly worsening symptoms, the disease ends in death after approximately 10 years after clinical onset.

Affected people describe the symptoms as a mixture of ALS, Parkinson’s Disease and Alzheimer’s Disease. The symptoms range from movement disorders (involuntary movements, chorea), cognitive decline and psychiatric disorders (apathy, depression).

To date, there is no cure, neither a therapy to slow down progress of the disease.

The community

Being a family disease with no cure, community is by far the most important thing for people affected from HD. Being affected does not necessarily mean being a gene carrier. Every part of of a family is affected, like every spouse or partner is, or close friends.
While there are a lot of clinical trials going on right now, time will show if the promising approaches will show an effect. Hope and community is all there is, so far.

As my life has changed significantly, even I as a researcher would call me an affected, and I feel like being part of the community. And it’s a strong one. Sophisticated networks have been built up in Europe and the USA, while other countries are following the example. Projects like We have a Face and HDdennomore (pronounced hidden no more) raise the awareness for the disease, to end the hush-up and shame that is common in affected families.

Projects like HD Buzz, a platform that “translates” scientific articles into human readible languate, help to connect researchers and families, I don’t know any field of research where the scientists are so much connected and dedicated to those people they try to help. This is the most awesome field I’ve worked in so far, and I won’t stop until there is a cure.

Another important factor that helped building this strong community is the CHDI foundation (Cure Huntington’s Disease Initiative), the largest funder of HD research. While other research fields are dominated by keeping results secret and save, showing elbows against other researchers and fighting for survival, CHDI somehow managed to establish a very prolific exchange between HD researchers worldwide.

Why do I write this article?

For myself, I am very grateful for being part in two such great communities. My science heart and my coder heart have home now and the perfect basis to grow smarter and to contribute back to the community.

However, while I feel happy of being able to express myself in a blog post, it is important that you know. If you read about Huntington’s Disease the first time now, or if you learned aspects you did not know before, this is great. It’s important that you know. Not to be known, not to be recognized can be fatal. Read more if you’re interested, spread the knowledge. Awareness may not only help affected, but will also contribute in raising funds to further improve and speed up the research. For many HD patients every day counts. I am certain that a Cure can be found, and it takes a strong community.

A libre OS

As described in my previous post, I migrated my system to a completely libre GNU/Linux distribution (seems I need to use the term libre in order to avoid the free/gratis confusion).

I admit that the pure migration process was pretty simple and almost unspectacular: I was running Manjaro Linux, an Arch-based distribution that comes with a nice set-up environment, but still has the freedom, simplicity and cutting edge packages, which I enjoyed very much. I decided to stay with an Arch derivative and followed these instructions to switch to Parabola Gnu/Linux. I expected some more magic, but basically I did the following:

  • removed all non-free packages
  • removed manjaro specific packages
  • installed libre alternatives where possible
  • installed your freedom

Removing the unwanted

While this sounds pretty straight forward there were some things I expected (like removal of certain software like TeamViewer, Skype etc) and some that were rather unexpected and made me swallow, like when I saw yaourt on the list of software-to-be-removed. Yaourt is a wrapper around the Arch packaging tool pacman. Whenever I could not find a package in the official repositories, that was my very first alternative, and I found what I was looking for in 99 of 100 searches.

However, it’s not crucial and I’ll be happy to invest more time in finding a solution in future, knowing that I will be more conscious about the software I install and use.
I was a bit puzzled about X not starting anymore, until I noticed that Plymouth is obviously non-free software and was hooked with my lightdm service; well I can absolutely forgo that one.

Embracing the alternative

My Thunderbird is now an Icedove, I totally can live with that ;) so far the libre alternative software does not at all change or affect the way I worked before. I was surprised to see that my kerned needed to be replaced. I nether thought about that, but apparently my linux kernel included binary blobs, I guess for hardware compatibility. The Free Software Foundation Latin America is developing libre-linux, a kernel free of any proprietary binaries, thanks for that!

More difficulties were caused by the software that was without alternative, like my proprietary wifi driver. Yes, I should have read just one more paragraph, so at least I would have been warned. Of course, no FOSS driver exists for my wifi card (since no specifications are made public), like for the vast majority of wifi cards, as far as I understood. So I ended up with buying an external usb wifi-dongle with a supported chipset (RTL8188 in my case) – I’ve come so far, I won’t be stopped by that :P

Keep the system clean

The funniest thing about the migration was indeed the your freedom package. The description given on the website tells you all you need to know about that:

This package conflicts with every nonfree package
known to date to ensure your system is free.

So this is my watchdog, conflicting with everything I didn’t know I didn’t want to have.

The system is up and running again, and I don’t feel much of a difference, yet. What I feel however, is to have gained deeper insight in how proprietary software and binary blobs are integrated in every layer of our system, unless we take the extra effort, time and knowledge to intentionally avoid it. I am no paranoiac and I don’t plan to become one in near future, but it is indeed alarming how many pieces of software are integrated per default, of which the operations that should be performed can not be verified – a very one-sided trust model.

free != gratis

Having a class on history of the hacker culture in the dgplug IRC channel has been highly interesting. Only within seconds after starting in 1955/56 with the TX-0 at MIT, my Wikipedia tabs popped up almost by themselves, going from TX-0 to Hacker to Hack Culture to Tech Model Railroad Club and Richard Stallman. By the end of the day I ended up installing FreeBSD and Plan9 on virtual machines on my laptop and began to explore those (what a weird thing, this Plan9, but interesting and consistent in concept)

Obviously, Richard Stallman had a great influence on hacker culture, the free software movement and actually on the working environment that I use right now and every day. After watching some talks and interviews, I realized that this guy really has the 100% freedom in mind (which ironically seems to be quite constraining), avoiding any proprietary software, but also boycotting a whole bunch of other services, tools, hardware and whatsoever if they violate against his philosophy.

Although I was a bit overwhelmed by the strict policy, I liked some of that thoughts initially. Like how he declares minified JavaScript to be proprietary software, because the code is not readable and you would need some reverse engineering to make sense of it. I also like his four essential freedoms (freedom 0, 1, 2 and 3) that finally helped me to understand that free software does not necessarily mean gratis software.

So I was interested in the OS and tools that are actually approved by Richard Stallman and found a good list here. I don’t remember how often I checked that box saying “install non-free packages” on my OS installations, without thinking twice even once. I will do now, and I think I might try out Parabola GNU/Linux and stay free, by staying propriety-free as good as possible. Judging from the post on stallman.org, not even he can manage to get the 100% he aims for; sometimes a trade-off is necessary until a better solution is found or created.

In the meantime I start searching and creating.

I open up

So I was browsing the web with my eyes more open to certain aspects. I never noticed that many Creative Commons logos before, though they have definitely been there. I searched the internet for free stuff a million times before. However, I realized that what I found (and actually was happy with) was shareware and adware most of the time. Now, for the first time I searched for FREE things. Not just software or media I can use for free, but things that are born free and live their free digital life out there in a free web.

I stumbled across the free music archive, where people share songs they produce and offer them for free download (again often with the CC involved), what a beautiful thing! Next I was searching a place for musicians to collaboratively create their music online and have their ideas continued by someone like-minded from across the continent. Looks like there are quite a few, though many of those projects are already dead or lack of funding. MyBlogBand looks promising, I will definitely try that out ;)

Meanwhile I will just start to share my own stuff on github; my writings, drawings, compositions and code, of course. I start with this little comic strip I’m working on.

first_draft.png

I know it’s not very good and it’s by far not done, yet. However, I realize that at this rate it will take me weeks to finalize. But maybe someone else likes the idea and has time and motivation to add whatever he thinks is missing, so fork it on github and here you go ;)

Going deeper

As written in my previous post, I’m attending the dgplug summertraining. It says they want to show the path of becoming an upstream contributor, which I think is pretty cool, but I must admit that all the time I was thinking about free and open software, only. Today’s homework, however, was to watch a documentary; The Internet’s own boy – the Aaron Swartz story.

This took me deeper. It’s not only about free software, it’s about free speech, free knowledge and free internet, issues that people have fought wars for for hundreds of years and still do. I’ve watched that movie and could not help but ask myself: Where have I been, what have I done and why didn’t I see all these things happen? The world wide web is about my age. We grew up together and we had a lot of fun. Well, turns out I was having more fun; although in permanent contact, I did not see the danger the internet was in and still is, as the threat to internet neutrality. I have the feeling of both, being affected directly and being able to change by contribution. This internet is still young and it’s not yet finished. More than ever I feel like I can help to make it better and protect it’s freedom.

As a physicist I also write publications that are published in scientific journals. Researchers like me heavily depend on publications to receive further grants to keep up the research projects. The majority of scientists will not make big money with research, it’s pure interest and the wish to contribute that keeps them going. From a scientific point of view absolutely reasonable to publish in a peer-reviewed journal, but it is also a necessity to survive. The impact factor of a journal represents the number of citations a journal gets, which in turn reflects the number of readers. For high impact factor journals, researchers even pay up to several 1000$ for publication; A ridiculous and perfidious system.

Luckily the numbers of Open Access journals are increasing, although I’m not sure if their impact factors do likewise. However, I’m glad, excited and curious where this summer training takes me. Maybe it is going to connect my worlds and wishes I have from science and coding.

Continue reading “Going deeper”