Emacs

What I need from IntelliJ and what I deeply miss when I’m not using Emacs

Updates will be written on my new site: draketo.de/software/intellij-emacs

At work I’m using IntelliJ for Java development, but I’m not happy with the interface. It forces me out of my concentration and regularly breaks my flow by having stuff jump around and stealing focus.

But I cannot switch to something that works better for me, because there are features of IntelliJ that I require to work efficiently.

IRC-chat via Tor with Emacs on Gentoo

As example: Connecting to #youbroketheinternet.

emerge privoxy torsocks net-vpn/tor
# rc-config start privoxy tor
# rc-update add privoxy default
# rc-update add tor default
mkdir -p ~/.local/EMACS_TOR_HOME/.emacs.d
echo "(require 'socks)" >> ~/.local/EMACS_TOR_HOME/.emacs.d/init.el
HOME=~/.local/EMACS_TOR_HOME torify emacs --title "Emacs-torified"
# M-x customize-variable RET socks-server RET
#   host: localhost
#   port: 9050
#   type: Socks v5
#   (C-x C-s to save and set)
# M-x erc-select
#   server loupsycedyglgamf.onion
#   port 67
# the welcome channel is good to go.

Muttertag und Vatertag für Emacs Org-Agenda, Deutsch und Spanisch

Um den Deutschen und Spanischen Muttertag in der Org-Agenda angezeigt zu bekommen, nutzt einfach

M-x customize-variable calendar-holidays

Und fügt die folgenden Zeilen ein:

(holiday-fixed 3 19 "Dia del Padre")
(holiday-float 5 0 2 "Muttertag")
(holiday-float 5 0 1 "Dia de la Madre")
(holiday-easter-etc 39 "Vatertag")

Dann nur noch C-x C-s zum Speichern, und die Org-Agenda zeigt euch die richtigen Mutter- und Vatertage für Deutschland und Spanien an.

Dia de la Madre, Vatertag

Surface Area of regions on an ellipsoid Earth

PDF

PDF (to print)

Org (source)

Data (netCDF4)

Calculating the area of arbitrary regions on the Earth approximated as an ellipsoid. I needed this for conversion between the output of different models.

It’s calculated in Emacs Lisp, which showed me that for somewhat complex mathematical tasks Lisp syntax isn’t only unproblematic, but actually helps avoiding mistakes. And full unicode support is great for implementing algorithms with ω, λ and φ.

eartharea_1x1.png

Staying sane with Emacs (when facing drudge work)

I have to sift through 6 really boring config files. To stay sane, I call in Emacs for support.

My task looks like this:

img
(click for full size)

Conveniently convert CamelCase to words_with_underscores using a small emacs hack

I currently cope with refactoring in an upstream project to which I maintain some changes which upstream does not merge. One nasty part is that the project converted from CamelCase for function names to words_with_underscores. And that created lots of merge errors.

Today I finally decided to speed up my work.

The first thing I needed was a function to convert a string in CamelCase to words_with_underscores.

Unicode-Characters for TODO-States in Emacs Orgmode

By default Emacs Orgmode uses uppercase words for todo keywords. But having tens of entries marked with TODO and DONE in my file looked horribly cluttered to me. So I searched for alternatives. After a few months of experimentation, I decided on the following scheme.

Using Macros to avoid tedious tasks (screencast)

Because I am lazy,1 and that makes me fast.

Screencast

(download (ogg theora video))

Using Macros to avoid tedious tasks


  1. I have lots of stuff to do, so I cannot afford not being lazy ☺ 

keep auto-complete from competing with org-mode structure-templates

For a long time it bothered me that auto-complete made it necessary for me to abort completion before being able to use org-mode templates.

I typed <s and auto-complete showed stuff like <string, forcing me to hit C-g before I could use TAB to complete the template with org-mode.

I fixed this for me by adding all the org-mode structure templates as stop-words:

;; avoid competing with org-mode templates.
(add-hook 'org-mode-hook
          (lambda ()
            (make-local-variable 'ac-stop-words)
            (loop for template in org-structure-template-alist do
                  (add-to-list 'ac-stop-words 
                               (concat "<" (car template))))))

Org-mode with Parallel Babel

Update 2017: a block with sem -j ... seems to block in recent versions of Emacs until all subtasks are done. It would be great if someone could figure out why (though it likely is the right thing to do). To circumvent that, you can daemonize the job in sem, but that might have unwanted side-effects: sem "[job] &"

Babel in Org

Emacs Org-mode provides the wonderful babel-capability: Including code-blocks in any language directly in org-mode documents in plain text.

In default usage, running such code freezes my emacs until the code is finished, though.

Up to a few weeks ago, I solved this with a custom function, which spawns a new emacs as script runner for the specific code:

; Execute babel source blocks asynchronously by just opening a new emacs.
(defun bab/org-babel-execute-src-block-new-emacs ()
  "Execute the current source block in a separate emacs,
so we do not block the current emacs."
  (interactive)
  (let ((line (line-number-at-pos))
        (file (buffer-file-name)))
    (async-shell-command (concat 
                          "TERM=vt200 emacs -nw --find-file " 
                          file 
                          " --eval '(goto-line "
                          (number-to-string line) 
                          ")' --eval "
     "'(let ((org-confirm-babel-evaluate nil))(org-babel-execute-src-block t))' "
                          "--eval '(kill-emacs 0)'"))))

and its companion for exporting to beamer-latex presentation pdf:

; Export as pdf asynchronously by just opening a new emacs.
(defun bab/org-beamer-export-new-emacs ()
  "Export the current file in a separate emacs,
so we do not block the current emacs."
  (interactive)
  (let ((line (line-number-at-pos))
        (file (buffer-file-name)))
    (async-shell-command (concat 
                          "TERM=vt200 emacs -nw --find-file " 
                          file 
                          " --eval '(goto-line " 
                          (number-to-string line) 
                          ")' --eval "
     "'(let ((org-confirm-babel-evaluate nil))(org-beamer-export-to-pdf))' "
                          "--eval '(kill-emacs 0)'"))))

But for shell-scripts there’s a much simpler alternative:

Tutorial: Writing scientific papers for ACP using emacs org-mode

Update 2023: I no longer work at the University. Nowadays I would use this setup as starting point, but with more focus on using org for reproducibility (I have German instructions for that) when the first version is ready for submission, export it as LaTeX, and work directly on that, because you’ll need detailed changes in LaTeX.

PDF-version (for printing)

orgmode-version (for editing)

Emacs Org mode is an excellent tool for reproducible research,1 but research is only relevant if people learn about it.2 To reach people with scientific work, you need to publish your results in a Journal, so I show here how to publish in ACP with Emacs Org mode.3

Write multiple images on a single page in org-mode.

How to add show multiple images on one page in the latex-export of emacs org-mode. I had this problem. This is my current solution.

Unicode char \u8:χ not set up for use with LaTeX: Solution (made easy with Emacs)

For years I regularly stumbled over LaTeX-Errors in the form of Unicode char \u8:χ not set up for use with LaTeX. I always took the chickens path and replaced the unicode characters with the tex-escapes in the file. That was easy, but it made my files needlessly unreadable. Today I decided to FIX the problem once and for all. And it worked. Easily.

Firstoff: The problem I’m facing is that my keyboard layout makes it effortless for me to input characters like ℂ Σ and χ. But LaTeX cannot cope with them out-of-the-box.

Reproduzierbare Veröffentlichungen

Für verlässliche Wissenschaft sind reproduzierbare Veröffentlichungen essenziell - aber oft sind sie nicht gegeben12. Dieser 5-Minuten-Vortrag motiviert, wieso Reproduzierbarkeit so wichtig ist, und zeigt eine Lösung zum wirklich reproduzierbaren Veröffentlichen - die er auch selbst nutzt. Ich habe ihn in einem Seminar zum wissenschaftlichen Präsentieren gehalten.

Einen praktischen Leitfaden für entsprechende Veröffentlichungen, den ich auch selbst genutzt habe, liefert das Tutorial: Writing scientific papers for ACP using emacs org-mode.

Reproduzierbare Veröffentlichungen

PDF-version (for printing)

Release (to download)

orgmode-version (for editing)

repository (for forking)

Falscher Anreiz

  • Die Versuchung
    • „Haben Sie einmal ein Paper mit per Skript erstellten Grafiken veröffentlicht?“
    • „Haben Sie Skripte und Daten veröffentlicht?“
    • „Warum erfinden Sie die Daten nicht? Das wäre weniger Arbeit…“

    „Niemals! Das verbietet die wissenschaftliche Integrität!“

  • Doch es passiert - leider
    • Einstieg: „passte ich den Untersuchungsentwurf an“.
    • Dietrich Stapel: „Es war grau und es war üblich“.
    • Sturz: „erfindet die Daten“.
    • „Forscher gratulieren“.
    • „Drei [seiner] Doktoranden sind Ungereimtheiten […] aufgefallen“.

    [Quarks & Co., 2013-06-04]


  1. Gerade haben Biologen gezeigt3, dass die Verfügbarkeit der Rohdaten von alten Veröffentlichungen jedes Jahr um 17% fällt. Das heißt, schon nach 4 Jahren gibt es für die Hälfte der Veröffentlichungen keine Daten mehr. Die hier gezeigte Methode macht es sehr einfach sicherzustellen, dass alle für die Veröffentlichung notwendigen Daten mitveröffentlicht werden - und erzeugt automatisch eine Archivdatei dafür. 

  2. Leider ist die durch die politisch gesetzten Rahmenbedingungen erzwungene Konkurrenzsituation für reproduzierbare Veröffentlichungen hinderlich, denn wer seine Daten und Skripte veröffentlicht - eigentlich alle Programme, die er oder sie nutzte - verspielt die Möglichkeit, sich ein Monopol auf die Daten aufzubauen, das die nächsten Veröffentlichungen sichern könnte. Sobald die Daten draußen sind, können andere damit arbeiten - und nur die schnellsten können veröffentlichen (ja, das System ist dumm…). Zusätzlich stehen sauberer Veröffentlichung oft „IP“-Regeln entgegen - also der Wunsch der Uni, ihre Ergebnisse zu monopolisieren. Zum Glück gibt es mit Open Access inzwischen eine Bewegung gegen solche schädlichen Regelungen - aber der Kampf wird wohl noch lange andauern. Immerhin stehen hier Misstrauen, Gier und leider berechtigte Sorgen um die eigene Zukunft gegen wissenschaftliche Integrität. 

  3. The Availability of Research Data Declines Rapidly with Article Age - Zeitungsartikel dazu: The Vast Majority of Raw Data From Old Scientific Studies May Now Be Missing

Publish a single file with emacs org-mode

I often write small articles on some experience I make, and since I want to move towards using static pages more often, I tried using emacs org-mode publishing for that. Strangely the simple usecase of publishing a single file seems quite a bit more complex than needed, so I document the steps here.

This is my first use of org-publish, so I likely do not use it perfectly. But as it stands, it works. You can find the org-publish version of this article at draketo.de/proj/orgmode-single-file.

How to show the abstract before the table of contents in org-mode

I use Emacs Org-Mode for writing all kinds of articles. The standard format for org-mode is to show the table of contents before all other content, but that requires people to scroll down to see whether the article is interesting for them. Therefore I want the abstract to be shown before the table of contents.

Use the source, Luke! — Emacs org-mode beamer export with images in figure

I just needed to tweak my Emacs org-mode to beamer-latex export to embed images into a figure environment (not wrapfigure!). After lots of googling and documentation reading I decided to bite the bullet and just read the source. Which proved to be much easier than I had expected.

This tutorial requires at least org-mode 8.0 (before that you had to use hacks to get figure without a caption). It is only tested for org-mode 8.0.2: The code you see when you read the source might look different in other versions.

Babcore: Emacs Customizations everyone should have

Update (2017-05): babcore is at 0.2, but I cannot currently update the marmalade package. See lisplets/babcore.el

1 Intro

PDF-version (for printing)

Package (to install)

orgmode-version (for editing)

repository (for forking)

project page (for fun ☺)

Emacs Lisp (to use)

I have been tweaking my emacs configuration for years, now, and I added quite some cruft. But while searching for the right way to work, I also found some gems which I direly miss in pristine emacs.

This file is about those gems.

Babcore is strongly related to Prelude. Actually it is just like prelude, but with the stuff I consider essential. And staying close to pristine Emacs, so you can still work at a coworkers desk.

But before we start, there is one crucial piece of advice which everyone who uses Emacs should know:

C-g: abort

Hold control and hit g.

That gets you out of almost any situation. If anything goes wrong, just hit C-g repeatedly till the problem is gone - or you cooled off far enough to realize that a no-op is the best way to react.

To repeat: If anything goes wrong, just hit C-g.

wisp: Whitespace to Lisp

New version: draketo.de/software/wisp

» I love the syntax of Python, but crave the simplicity and power of Lisp.«

display "Hello World!" ↦ (display "Hello World!")
define : factorial n     (define (factorial n)            
    if : zero? n       ↦     (if (zero? n)                
       . 1                      1                      
       * n : factorial {n - 1}  (* n (factorial {n - 1}))))

Wisp basics

»ArneBab's alternate sexp syntax is best I've seen; pythonesque, hides parens but keeps power« — Christopher Webber in twitter, in identi.ca and in his blog: Wisp: Lisp, minus the parentheses
♡ wow ♡
»Wisp allows people to see code how Lispers perceive it. Its structure becomes apparent.« — Ricardo Wurmus in IRC, paraphrasing the wisp statement from his talk at FOSDEM 2019 about Guix for reproducible science in HPC.
☺ Yay! ☺
with (open-file "with.w" "r") as port
     format #t "~a\n" : read port
Familiar with-statement in 25 lines.

 ↓ skip updates ↓

Update (2020-09-15): Wisp 1.0.3 provides a wisp binary to start a wisp repl or run wisp files, builds with Guile 3, and moved to sourcehut for libre hosting: hg.sr.ht/~arnebab/wisp.
After installation, just run wisp to enter a wisp-shell (REPL).
This release also ships wisp-mode 0.2.6 (fewer autoloads), ob-wisp 0.1 (initial support for org-babel), and additional examples. New auxiliary projects include wispserve for experiments with streaming and download-mesh via Guile and wisp in conf:
conf new -l wisp PROJNAME creates an autotools project with wisp while conf new -l wisp-enter PROJAME creates a project with natural script writing and guile doctests set up. Both also install a script to run your project with minimal start time: I see 25ms to 130ms for hello world (36ms on average). The name of the script is the name of your project.
For more info about Wisp 1.0.3, see the NEWS file.
To test wisp v1.0.3, install Guile 2.0.11 or later and bootstrap wisp:

wget https://www.draketo.de/files/wisp-1.0.3.tar_.gz;
tar xf wisp-1.0.3.tar_.gz ; cd wisp-1.0.3/;
./configure; make check;
examples/newbase60.w 123

If it prints 23 (123 in NewBase60), your wisp is fully operational.
If you have additional questions, see the Frequently asked Questions (FAQ) and chat in #guile at freenode.
That’s it - have fun with wisp syntax!

Update (2019-07-16): wisp-mode 0.2.5 now provides proper indentation support in Emacs: Tab increases indentation and cycles back to zero. Shift-tab decreases indentation via previously defined indentation levels. Return preserves the indentation level (hit tab twice to go to zero indentation).
Update (2019-06-16): In c programming the uncommon way, specifically c-indent, tantalum is experimenting with combining wisp and sph-sc, which compiles scheme-like s-expressions to c. The result is a program written like this:
pre-include "stdio.h"

define (main argc argv) : int int char**
  declare i int
  printf "the number of arguments is %d\n" argc
  for : (set i 0) (< i argc) (set+ i 1)
    printf "arg %d is %s\n" (+ i 1) (array-get argv i)
  return 0 ;; code-snippet under GPLv3+
To me that looks so close to C that it took me a moment to realize that it isn’t just using a parser which allows omitting some special syntax of C, but actually an implementation of a C-generator in Scheme (similar in spirit to cython, which generates C from Python), which results in code that looks like a more regular version of C without superfluous parens. Wisp really completes the round-trip from C over Scheme to something that looks like C but has all the regularity of Scheme, because all things considered, the code example is regular wisp-code. And it is awesome to see tantalum take up the tool I created and use it to experiment with ways to program that I never even imagined! ♡
TLDR: tantalum uses wisp for code that looks like C and compiles to C but has the regularity of Scheme!
Update (2019-06-02): The repository at https://www.draketo.de/proj/wisp/ is stale at the moment, because the staticsite extension I use to update it was broken by API changes and I currently don’t have the time to fix it. Therefore until I get it fixed, the canonical repository for wisp is https://bitbucket.org/ArneBab/wisp/. I’m sorry for that. I would prefer to self-host it again, but the time to read up what i have to adjust blocks that right now (typically the actual fix only needs a few lines). A pull-request which fixes the staticsite extension for modern Mercurial would be much appreciated!
Update (2019-02-08): wisp v1.0 released as announced at FOSDEM. Wisp the language is complete:
display "Hello World!"
↦ (display "Hello World!")

And it achieves its goal:
“Wisp allows people to see code how Lispers perceive it. Its structure becomes apparent.” — Ricardo Wurmus at FOSDEM
Tooling, documentation, and porting of wisp are still work in progress, but before I go on, I want thank the people from the readable lisp project. Without our initial shared path, and without their encouragement, wisp would not be here today. Thank you! You’re awesome!
With this release it is time to put wisp to use. To start your own project, see the tutorial Starting a wisp project and the wisp tutorial. For more info, see the NEWS file. To test wisp v1.0, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-1.0.tar.gz;
tar xf wisp-1.0.tar.gz ; cd wisp-1.0/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
If you have additional questions, see the Frequently asked Questions (FAQ) and chat in #guile at freenode.
That’s it - have fun with wisp syntax!
Update (2019-01-27): wisp v0.9.9.1 released which includes the emacs support files missed in v0.9.9, but excludes unnecessary files which increased the release size from 500k to 9 MiB (it's now back at about 500k). To start your own wisp-project, see the tutorial Starting a wisp project and the wisp tutorial. For more info, see the NEWS file. To test wisp v0.9.9.1, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.9.1.tar.gz;
tar xf wisp-0.9.9.1.tar.gz ; cd wisp-0.9.9.1/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2019-01-22): wisp v0.9.9 released with support for literal arrays in Guile (needed for doctests), example start times below 100ms, ob-wisp.el for emacs org-mode babel and work on examples: network, securepassword, and downloadmesh. To start your own wisp-project, see the tutorial Starting a wisp project and the wisp tutorial. For more info, see the NEWS file. To test wisp v0.9.9, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.9.tar.gz;
tar xf wisp-0.9.9.tar.gz ; cd wisp-0.9.9/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2018-06-26): There is now a wisp tutorial for beginning programmers: “In this tutorial you will learn to write programs with wisp. It requires no prior knowledge of programming.”Learn to program with Wisp, published in With Guise and Guile
Update (2017-11-10): wisp v0.9.8 released with installation fixes (thanks to benq!). To start your own wisp-project, see the tutorial Starting a wisp project. For more info, see the NEWS file. To test wisp v0.9.8, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.8.tar.gz;
tar xf wisp-0.9.8.tar.gz ; cd wisp-0.9.8/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2017-10-17): wisp v0.9.7 released with bugfixes. To start your own wisp-project, see the tutorial Starting a wisp project. For more info, see the NEWS file. To test wisp v0.9.7, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.7.tar.gz;
tar xf wisp-0.9.7.tar.gz ; cd wisp-0.9.7/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2017-10-08): wisp v0.9.6 released with compatibility for tests on OSX and old autotools, installation to guile/site/(guile version)/language/wisp for cleaner installation, debugging and warning when using not yet defined lower indentation levels, and with wisp-scheme.scm moved to language/wisp.scm. This allows creating a wisp project by simply copying language/. A short tutorial for creating a wisp project is available at Starting a wisp project as part of With Guise and Guile. For more info, see the NEWS file. To test wisp v0.9.6, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.6.tar.gz;
tar xf wisp-0.9.6.tar.gz ; cd wisp-0.9.6/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2017-08-19): Thanks to tantalum, wisp is now available as package for Arch Linux: from the Arch User Repository (AUR) as guile-wisp-hg! Instructions for installing the package are provided on the AUR page in the Arch Linux wiki. Thank you, tantalum!
Update (2017-08-20): wisp v0.9.2 released with many additional examples including the proof-of-concept for a minimum ceremony dialog-based game duel.w and the datatype benchmarks in benchmark.w. For more info, see the NEWS file. To test it, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.2.tar.gz;
tar xf wisp-0.9.2.tar.gz ; cd wisp-0.9.2/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2017-03-18): I removed the link to Gozala’s wisp, because it was put in maintenance mode. Quite the opposite of Guile which is taking up speed and just released Guile version 2.2.0, fully compatible with wisp (though wisp helped to find and fix one compiler bug, which is something I’m really happy about ☺).
Update (2017-02-05): Allan C. Webber presented my talk Natural script writing with Guile in the Guile devroom at FOSDEM. The talk was awesome — and recorded! Enjoy Natural script writing with Guile by "pretend Arne" ☺

presentation (pdf, 16 slides) and its source (org).
Have fun with wisp syntax!
Update (2016-07-12): wisp v0.9.1 released with a fix for multiline strings and many additional examples. For more info, see the NEWS file. To test it, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.1.tar.gz;
tar xf wisp-0.9.1.tar.gz ; cd wisp-0.9.1/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2016-01-30): I presented Wisp in the Guile devroom at FOSDEM. The reception was unexpectedly positive — given some of the backlash the readable project got I expected an exceptionally sceptical audience, but people rather asked about ways to put Wisp to good use, for example in templates, whether it works in the REPL (yes, it does) and whether it could help people start into Scheme. The atmosphere in the Guile devroom was very constructive and friendly during all talks, and I’m happy I could meet the Hackers there in person. I’m definitely taking good memories with me. Sadly the video did not make it, but the schedule-page includes the presentation (pdf, 10 slides) and its source (org).
Have fun with wisp syntax!
Update (2016-01-04): Wisp is available in GNU Guix! Thanks to the package from Christopher Webber you can try Wisp easily on top of any distribution:
guix package -i guile guile-wisp
guile --language=wisp
This already gives you Wisp at the REPL (take care to follow all instructions for installing Guix on top of another distro, especially the locales).
Have fun with wisp syntax!
Update (2015-10-01): wisp v0.9.0 released which no longer depends on Python for bootstrapping releases (but ./configure still asks for it — a fix for another day). And thanks to Christopher Webber there is now a patch to install wisp within GNU Guix. For more info, see the NEWS file. To test it, install Guile 2.0.11 or later and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.9.0.tar.gz;
tar xf wisp-0.9.0.tar.gz ; cd wisp-0.9.0/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2015-09-12): wisp v0.8.6 released with fixed macros in interpreted code, chunking by top-level forms, : . parsed as nothing, ending chunks with a trailing period, updated example evolve and added examples newbase60, cli, cholesky decomposition, closure and hoist in loop. For more info, see the NEWS file.To test it, install Guile 2.0.x or 2.2.x and Python 3 and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.8.6.tar.gz;
tar xf wisp-0.8.6.tar.gz ; cd wisp-0.8.6/;
./configure; make check;
examples/newbase60.w 123
If it prints 23 (123 in NewBase60), your wisp is fully operational.
That’s it - have fun with wisp syntax! And a happy time together for the ones who merge their paths today ☺
Update (2015-04-10): wisp v0.8.3 released with line information in backtraces. For more info, see the NEWS file.To test it, install Guile 2.0.x or 2.2.x and Python 3 and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.8.3.tar.gz;
tar xf wisp-0.8.3.tar.gz ; cd wisp-0.8.3/;
./configure; make check;
guile -L . --language=wisp tests/factorial.w; echo
If it prints 120120 (two times 120, the factorial of 5), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2015-03-18): wisp v0.8.2 released with reader bugfixes, new examples and an updated draft for SRFI 119 (wisp). For more info, see the NEWS file.To test it, install Guile 2.0.x or 2.2.x and Python 3 and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.8.2.tar.gz;
tar xf wisp-0.8.2.tar.gz ; cd wisp-0.8.2/;
./configure; make check;
guile -L . --language=wisp tests/factorial.w; echo
If it prints 120120 (two times 120, the factorial of 5), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2015-02-03): The wisp SRFI just got into draft state: SRFI-119 — on its way to an official Scheme Request For Implementation!
Update (2014-11-19): wisp v0.8.1 released with reader bugfixes. To test it, install Guile 2.0.x and Python 3 and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.8.1.tar.gz;
tar xf wisp-0.8.1.tar.gz ; cd wisp-0.8.1/;
./configure; make check;
guile -L . --language=wisp tests/factorial.w; echo
If it prints 120120 (two times 120, the factorial of 5), your wisp is fully operational.
That’s it - have fun with wisp syntax!
Update (2014-11-06): wisp v0.8.0 released! The new parser now passes the testsuite and wisp files can be executed directly. For more details, see the NEWS file. To test it, install Guile 2.0.x and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.8.0.tar.gz;
tar xf wisp-0.8.0.tar.gz ; cd wisp-0.8.0/;
./configure; make check;
guile -L . --language=wisp tests/factorial.w;
echo
If it prints 120120 (two times 120, the factorial of 5), your wisp is fully operational.
That’s it - have fun with wisp syntax!
On a personal note: It’s mindboggling that I could get this far! This is actually a fully bootstrapped indentation sensitive programming language with all the power of Scheme underneath, and it’s a one-person when-my-wife-and-children-sleep sideproject. The extensibility of Guile is awesome!
Update (2014-10-17): wisp v0.6.6 has a new implementation of the parser which now uses the scheme read function. `wisp-scheme.w` parses directly to a scheme syntax-tree instead of a scheme file to be more suitable to an SRFI. For more details, see the NEWS file. To test it, install Guile 2.0.x and bootstrap wisp:
wget https://bitbucket.org/ArneBab/wisp/downloads/wisp-0.6.6.tar.gz;
tar xf wisp-0.6.6.tar.gz; cd wisp-0.6.6;
./configure; make;
guile -L . --language=wisp
That’s it - have fun with wisp syntax at the REPL!
Caveat: It does not support the ' prefix yet (syntax point 4).
Update (2014-01-04): Resolved the name-clash together with Steve Purcell und Kris Jenkins: the javascript wisp-mode was renamed to wispjs-mode and wisp.el is called wisp-mode 0.1.5 again. It provides syntax highlighting for Emacs and minimal indentation support via tab. You can install it with `M-x package-install wisp-mode`
Update (2014-01-03): wisp-mode.el was renamed to wisp 0.1.4 to avoid a name clash with wisp-mode for the javascript-based wisp.
Update (2013-09-13): Wisp now has a REPL! Thanks go to GNU Guile and especially Mark Weaver, who guided me through the process (along with nalaginrut who answered my first clueless questions…).
To test the REPL, get the current code snapshot, unpack it, run ./bootstrap.sh, start guile with $ guile -L . (requires guile 2.x) and enter ,language wisp.
Example usage:
display "Hello World!\n"
then hit enter thrice.
Voilà, you have wisp at the REPL!
Caveeat: the wisp-parser is still experimental and contains known bugs. Use it for testing, but please do not rely on it for important stuff, yet.
Update (2013-09-10): wisp-guile.w can now parse itself! Bootstrapping: The magical feeling of seeing a language (dialect) grow up to live by itself: python3 wisp.py wisp-guile.w > 1 && guile 1 wisp-guile.w > 2 && guile 2 wisp-guile.w > 3 && diff 2 3. Starting today, wisp is implemented in wisp.
Update (2013-08-08): Wisp 0.3.1 released (Changelog).

Going from a simple Makefile to Autotools

Table of Contents

Links

Intro

I recently started looking into Autotools, to make it easier to run my code on multiple platforms.

Naturally you can use cmake or scons or waf or ninja or tup, all of which are interesting in there own respect. But none of them has seen the amount of testing which went into autotools, and none of them have the amount of tweaks needed to support about every system under the sun. And I recently found pyconfigure which allows using autotools with python and offers detection of library features.

Warning 2016: Contains some cargo-cult-programming — my current setup is cleaner thanks to using AC_CONFIG_LINKS in configure.ac.

Namespaces in Emacs Lisp - ohne den Interpreter zu ändern

» Adding namespace support to emacs lisp in a macro with just 15 lines of code - it’s things like this which make lisp feel like the mother of all languages.«1

(defmacro namespace (prefix &rest sexps)
  (let* ((naive-dfs-map
          (lambda (fun tree)
            (mapcar (lambda (n) (if (listp n) (funcall naive-dfs-map fun n)
                                  (funcall fun n))) tree)))
         (to-rewrite (loop for sexp in sexps
                           when (member (car sexp)
                                        '(defvar defmacro defun))
                           collect (cadr sexp)))
         (fixed-sexps (funcall naive-dfs-map
                               (lambda (n) (if (member n to-rewrite)
                                               (intern
                                                (format "%s-%s" prefix n)) n))
                               sexps)))
    `(progn ,@fixed-sexps)))
(provide 'namespace)
(require 'namespace)
(namespace foo
           (defun bar ()
             "bar")
           (defun foo (s)
               "foo"))
(foo-foo (foo-bar))

Disclaimer: This code is not perfect. It will likely fail in unpredictable ways, and the number of not supported corner-cases is probably huge - and unknown. But (and that’s the relevant result) you can do this right. Rainer Joswig gives pointers for that on Stackoverflow: “What you actually need is a so-called code-walker”. Also he shows examples where the code breaks.

(Der Hauptteil dieses Codes stammt von vpit3833 und konr und ich darf ihn verwenden. Er funktioniert dank einer Korrektur von Stefan. Er ist nicht perfekt, aber da er mir v.a. dazu dienen soll, meine eigenen Codeschnipsel besser zu organisieren, sollte ich das verschmerzen können)

Der Code mag schwer lesbar sein, hat aber riesige Implikationen: Du als einfacher Endnutzer des Lisp-Interpreters kannst Namespace-Support hinzufügen, ohne dass die Hauptentwickler dafür irgendetwas machen müssen.


  1. Der Code stammt größtenteils aus einer Diskussion auf Stackoverflow

Insert a scaled screenshot in emacs org-mode

@marjoleink asked on identi.ca1, if it is possible to use emacs org-mode for showing scaled screenshots inline while writing. Since I thought I’d enjoy some hacking, I decided to take the challenge.

It does not do auto-scaling of embedded images, as far as I know, but the use case of screenshots can be done with a simple function (add this to your ~/.emacs or ~/.emacs.d/init.el):


  1. Matthew Gregg: @marjoleink "way of life" thing again, but if you can invest some time, org-mode is a really powerful note keeping environment. → Marjolein Katsma: @mcg I'm sure it is - but seriously: can you embed a diagram2 or screenshot, scale it, and link it to itself? 

  2. For diagrams, you can just insert a link to the image file without description, then org-mode can show it inline. To get an even nicer user-experience (plain text diagrams or ascii-art), you can use inline code via org-babel using graphviz (dot) or ditaa - the latter is used for the diagrams in my complete Mercurial branching strategy

Sending email to many people with Emacs Wanderlust

I recently needed to send an email to many people1.

Putting all of them into the BCC field did not work (mail rejected by provider) and when I split it into 2 emails, many did not see my mail because it was flagged as potential spam (they were not in the To-Field)2.

I did not want to put them all into the To-Field, because that would have spread their email-addresses around, which many would not want3.

So I needed a different solution. Which I found in the extensibility of emacs and wanderlust4. It now carries the name wl-draft-send-to-multiple-receivers-from-buffer.

You simply write the email as usual via wl-draft, then put all email addresses you want write to into a buffer and call M-x wl-draft-send-to-multiple-receivers-from-buffer. It asks you about the buffer with email addresses, then shows you all addresses and asks for confirmation.

Then it sends one email after the other, with a randomized wait of 0-10 seconds between messages to avoid flagging as spam.

If you want to use it, just add the following to your .emacs:

(defun wl-draft-clean-mail-address (address)
  (replace-regexp-in-string "," "" address))
(defun wl-draft-send-to-multiple-receivers (addresses) (loop for address in addresses do (progn (wl-user-agent-insert-header "To" (wl-draft-clean-mail-address address)) (let ((wl-interactive-send nil)) (wl-draft-send)) (sleep-for (random 10)))))
(defun wl-draft-send-to-multiple-receivers-from-buffer (&optional addresses-buffer-name) "Send a mail to multiple recipients - one recipient at a time" (interactive "BBuffer with one address per line") (let ((addresses nil)) (with-current-buffer addresses-buffer-name (setq addresses (split-string (buffer-string) "\n"))) (if (y-or-n-p (concat "Send this mail to " (mapconcat 'identity addresses ", "))) (wl-draft-send-to-multiple-receivers addresses))))

Happy Hacking!


  1. The email was about the birth of my second child, and I wanted to inform all people I care about (of whom I have the email address), which amounted to 220 recipients. 

  2. Naturally this technique could be used for real spamming, but to be frank: People who send spam won’t need it. They will already have much more sophisticated methods. This little trick just reduces the inconvenience brought upon us by the measures which are necessary due to spam. Otherwise I could just send a mail with 1000 receivers in the BCC field - which is how it should be. 

  3. It only needs one careless friend, and your connections to others get tracked in facebook and the likes. For more information on Facebook, see Stallman about Facebook

  4. Sure, there are also template mails and all such, but learning to use these would consume just as much time as extending emacs - and would be much less flexible: Should I need other ways to transform my mails, I’ll be able to just reuse my code. 

Easily converting ris-citations to bibtex with emacs and bibutils

The problem

Nature only gives me ris-formatted citations, but I use bibtex.

Also ris is far from human readable.

The background

ris can be reformatted to bibtext, but doing that manually disturbs my workflow when getting references while taking note about a paper in emacs.

I tend to search online for references, often just using google scholar, so when I find a ris reference, the first data I get for the ris-citation is a link.

The solution

Emacs

Cross platform, Free Software, almost all features you can think of, graphical and in the shell: Learn once, use for everything.

» Get Emacs «

Emacs is a self-documenting, extensible editor, a development environment and a platform for lisp-programs - for example programs to make programming easier, but also for todo-lists on steroids, reading email, posting to identi.ca, and a host of other stuff (learn lisp).

It is one of the origins of GNU and free software (Emacs History).

In Markdown-mode it looks like this:

Emacs mit Markdown mode

Recipes for presentations with beamer latex using emacs org-mode

I wrote some recipes for creating the kinds of slides I need with emacs org-mode export to beamer latex.

Update: Read ox-beamer to see how to adapt this to work with the new export engine in org-mode 0.8.

PDF recipes The recipes as PDF (21 slides, 247 KiB)

org-mode file The org-mode sources (12.2 KiB)

Below is an html export of the org-mode file. Naturally it does not look as impressive as the real slides, but it captures all the sources, so I think it has some value.

Note: To be able to use the simple block-creation commands, you need to add #+startup: beamer to the header of your file or explicitely activate org-beamer with M-x org-beamer-mode.

«I love your presentation»:

PS: I hereby allow use of these slides under any of the licenses used by worg and/or the emacs wiki.

Minimal example for literate programming with noweb in emacs org-mode

If you want to use the literate programming features in emacs org-mode, you can try this minimal example to get started: Activate org-babel-tangle, then put this into the file noweb-test.org:

Minimal example for noweb in org-mode

* Assign 

First we assign abc:

#+begin_src python :noweb-ref assign_abc
abc = "abc"
#+end_src

* Use

Then we use it in a function:

#+begin_src python :noweb tangle :tangle noweb-test.py
def x():
  <<assign_abc>>
  return abc

print(x())
#+end_src

noweb-test.org

Custom link completion for org-mode in 25 lines (emacs)

Update (2013-01-23): The new org-mode removed (org-make-link), so I replaced it with (concat) and uploaded a new example-file: org-custom-link-completion.el.
Happy Hacking!

1 Intro

I recently set up custom completion for two of my custom link types in Emacs org-mode. When I wrote on identi.ca about that, Greg Tucker-Kellog said that he’d like to see that. So I decided, I’d publish my code.

El Kanban Org: parse org-mode todo-states to use org-tables as Kanban tables

Kanban for emacs org-mode.

Update (2020): Kanban moved to sourcehut: https://hg.sr.ht/~arnebab/kanban.el

Update (2013-04-13): Kanban.el now lives in its own repository: on bitbucket and on a statically served http-repo (to be independent from unfree software).

Update (2013-04-10): Thanks to Han Duply, kanban links now work for entries from other files. And I uploaded kanban.el on marmalade.

Some time ago I learned about kanban, and the obvious next step was: “I want to have a kanban board from org-mode”. I searched for it, but did not find any. Not wanting to give up on the idea, I implemented my own :)

The result are two functions: kanban-todo and kanban-zero.

“Screenshot” :)

TODODOINGDONE
Refactor in such a way that the
let Presentation manage dumb sprites
return all actions on every command:
Make the UiState adhere the list of
Turn the model into a pure state

Paper zu Org-Mode für „reproducible research“

Ich bin gerade auf das Paper hier gestoßen:

A Multi-Language Computing Environment for Literate Programming and Reproducible Research” (PDF)

Es beschreibt schön, was mit emacs org-mode möglich ist. Dazu gehören so spannende Punkte wie im Dokument mitgelieferter Quellcode, dessen Ergebnisse automatisch eingebunden werden, so dass die Dokumente aktuell bleiben können.

Inhalt abgleichen
Willkommen im Weltenwald!
((λ()'Dr.ArneBab))



Beliebte Inhalte

Draketo neu: Beiträge

Ein Würfel System

sn.1w6.org news