Topic

emacs

I was about to write a blog post about how indifferent I became towards different text editors, and how I don’t really care anymore whether I edit code with emacs, vim, Sublime or even Atom. And then this happened:

It’s called Spacemacs and it’s a beautiful hybrid between emacs and vim, or at least it looks like it. Will explore how it works in the course of the next couple of days, i.e., no work will be done and I will spend my days playing with the configuration of a text editor.

And I thought those days were over. Silly me.

update, Sep 9: I’m back onST3vim with my old config. I still think Spacemacs is a great idea, it’s just a bit too bloated for my taste.

I like auto-fill-mode and even have it customized for LaTeX-mode in my Emacs configuration. However, while working with other people via a distributed version control system, like I do with my friends, auto-fill-mode can be a real pain if not everyone uses it. Whenever the ones that do commit any code, others are annoyed because it’s difficult to see the changes in the diff file, since auto-fill-mode reformats paragraphs (hence producing ‘more’ changes).

The most straightforward solution is to put some local variables into the file, like (auto-fill-mode -1), but today at StackOverflow I saw a much neater solution: one can put a function that searches for a specific string inside a file and sets minor-modes accordingly. So now there’s a coauthors search function in my .emacs:

; auto-fill is enabled for TeX...
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
; ...unless I work with the gang
(defun my-auto-fill-disabling-hook ()
  "Check to see if we should disable autofill."
  (save-excursion
    (when (or (re-search-forward "truls" 1000 t)
              (re-search-forward "sjur" 1000 t)
              (re-search-forward "erik" 1000 t))
      (auto-fill-mode -1))))
(add-hook 'find-file-hooks 'my-auto-fill-disabling-hook)