Posts with tag "emacs"

Wireworld in Emacs

By Christopher Allan Webber on Fri 10 March 2017

It is a truth universally acknowledged, that a hacker under the pressure of a deadline must be in want of a distraction. So it has been with me; I've a TODO list a mountain high, and I've been especially cracking under the stress of trying to get things moving along with ActivityPub. I have a test suite to write, and it's turned out to be very hard, and this after several other deadlines in a row. I've also meant to blog about several things; say the talks I gave at FOSDEM or at ChicagoLUG. I've got a leak in my inbox that's been running for so long that the basement of my email has developed an undertow. So today, instead of getting what I knew I should be doing done, I instead went off and did something much more interesting, which is to say, I implemented Wireworld in emacs.

Wireworld in emacs screenshot

What is Wireworld? It's a cellular automaton, not unlike Conway's Game of Life. Except with Wireworld, the "cells" in play are a bit more constrained... you have a set of wires, and electrons run along them, multiply, and die out, but the paths stay the same. The rules are very simple to implement (Wikipedia says all there is to know). But you can build incredible things with it... even a fully working computer!

Anyway, like many hacks, this one appeared out of boredom/distraction. I had long wanted to play with Wireworld, and I was reminded of it by seeing this cool hack with a digital clock implemented in Conway's Game of Life. It reminded me just how much I wanted to try implementing that computer, or even much simpler circuitry, but I had never been able to get started, because I couldn't find a working implementation that was easy for me to package. (I started packaging Golly for Guix but got stuck for reasons I can't remember.) I started thinking about how much I liked typing out ASCII art in Emacs, and how cool would it be to just "draw out" circuits in a buffer? I started experimenting... and within two hours, I had a working implementation! Two more hours later, I had a major mode with syntax highlighting and a handy C-c C-c keybinding for "advancing" the buffer. Live hacking in Emacs is amazing!

More could be done. It would be nice to have a shortcut, say C-c C-s, that starts up a simulation in a new buffer and runs through the simulation automatically without clobbering your main buffer. (It could work the way M-x life does.) Anyway, the code is here should you want to play around.

Happy (circuit) hacking!

Minimalist bundled and distributed bugtracker w/ orgmode

By Christopher Allan Webber on Sun 11 October 2015

Thinking out loud here... this isn't a new idea but maybe here's a solid workflow...

"Distributed" as in the project's existing DVCS.

  • Check a orgmode file right into your project's git repo
  • Accept additions/adjustments to via patches on your mailing list
  • As soon as a bug is "accepted", it's committed to the project.
  • When a bug is finished, it's closed and archived.
  • Contributors are encouraged to submit closing tasks in the orgmode tree as part of their patch.
  • Bug commentary happens on-list, but if users have useful information to contribute to someone working on a bug, they can submit that as a patch.

I think this would be a reasonably complete but very emacs user oriented bugtracker solution, so maybe in addition:

  • A script can be provided which renders a static html copy for browsing open/closed bugs.
  • A "form" can be provided on that page to email the list about new discovered bugs, and formats the submission as an orgmode TODO subsection. This way maintainers can easily file the bug into the tracker file if they deem appropriate.

I think this would work. Lately I've been hacking on a project that's mostly just me so far, so I just have an orgmode file bundled with the repo, but I must say that it's rather nice to just hack an orgmode file and have your mini-bugtracker distributed with your project. I've done this a few times but as soon as the project grows to multiple contributors, I move everything over to some web based bugtracker UI. But why not distribute all bugs with the project itself? My main thinking is that there's a tool-oriented barrier to entry, but maybe the web page render can help with that.

I've been spending more time working on more oldschool projects that just take bugs submitted on mailing lists as a contribution project. They seem to do just fine. So I guess it entirely depends on the type of project, but this may work well for some.

And yes, there are a lot of obvious downsides to this too; paultag points out a few :)

emacslisten (an idea)

By Christopher Allan Webber on Fri 11 October 2013

An idea I've wanted to pursue for some time now but never really have had time to work on is some kind of voice-activated emacs interface. (I'm proposing the name emacslisten here partly as a tribute to the super amazing emacspeak, which is kind of the reverse of this accessibility project.) Unfortunately, several attempts of this have been tried, but as far as I know they all rely on Dragon Naturally Speaking. Given that this is nonfree, it's a non-starter for me (not to mention the fact that I neither want to use Windows nor Wine). What to do?

Here's a brief, and I mean really brief, sketch of how I think things maybe could work.

  • Write a python daemon using the gstreamer bindings for pythonsphinx and exposing a d-bus interface. (This tutorial worked for me by the way, though I did have to change gconfaudiosrc to pulsesrc... then it worked.) This will be where commands are actually "listened" from. It might, optionally, have an --interface mode with some kind of gtk dialog.
  • Write an emacs minor-mode to listen to those d-bus calls.
  • Probably, as for how it would work, it would be a bit more vi-style modal, but also contextually modal depending on what major-mode you're in in emacs (yes I know, confusing). So, you could jump in and out of write mode vs different kinds of command mode. Depending on what major mode you're in might affect the kind of commands you're restricted to; this might improve accuracy, since you could set pythonsphinx to a more limited subset of commands. (Presumably you could set up emacs to be able to speak to this process and switch out the command set also.)
  • Just like emacs does every keybinding bound to a lisp function, every vocal command is bound to a function.

Crazy? Probably. Crazy enough to work? Maybe.

I wish I had time to run this project. And admittedly, there's a common, unfortunate pattern amongst hackers that when they're having wrist problems, they're desparate to figure out some kind of voice activated editing software. But when their wrists are okay enough, they're too busy to actually care to invest that time in it.

I can't run this project myself, but I could help with it, if someone else would be willing to take the lead on it. Anyone interested?

EDIT: In case you're wondering, Tavis Rudd's "Using Python to Code By Voice" is definitely an inspiration. As far as I know he hasn't made a release of the software though (he did kindly offer to send me the source at one point, but I didn't want to get Dragon Naturally Speaking, so I never went through with it). It might be a great base though, and anyway, it's definitely a source of inspiration. I'd really love to see a public release of the code!

EDIT / UPDATE 2: I started working on this. Not much to see yet, but you can speak and words appear in the minibuffer. Get it here and help improve it!

Emacs appointment notifications via XMPP

By Christopher Allan Webber on Sun 21 November 2010

Since I've started using Emacs' appointment notifications with orgmode, I've wished that I could get notifications via XMPP. I think it's the most sensible system to use; I have it running on both my desktop, my phone, and my laptop, and the whole issue of "figuring out which device to send this notification to" has already been evaluated and solved by the XMPP community long long ago (back when everyone called XMPP Jabber, even ;)).

I initially thought I'd use a SleekXMPP bot connected to emacs via D-Bus, but then I decided that maybe I would eventually want to add more commands to this that integrated more closely with emacs, so maybe I should use emacs lisp directly. I had heard of Jabber.el but thought that it was mainly aimed at users who want a client, and that writing a bot in it would end up cluttering up my emacs with extra UI stuff I don't want. Then I was pointed at Steersman.el, and that seemed like a cleanly written bot, so I decided to give it a shot.

I was running a newer version of JabberEl than the copy of Steersman's code I looked at, so it took a little bit to figure out how to adjust for the multi-account code, but once I did that the implementation happened fairly quickly. Here's the relevant code:

;; Copyright (C) 2010  Christopher Allan Webber

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.

(require 'jabber)

(load-file "~/.emacs.d/emacs-jabberbot-login.el")

(defun botler->appt-message-me (min-to-app new-time appt-msg)
  "Message me about an upcoming appointment."
  (let ((message-body
         (format "Appointment %s: %s%s"
           (if (string-equal "0" min-to-app) "now"
             (format "in %s minute%s" min-to-app
                     (if (string-equal "1" min-to-app) "" "s")))
           new-time appt-msg)))
     (jabber-find-connection "")
     `(message ((to . "")
                (type . "normal"))
                (body () ,message-body)))))

; I don't care when people come online to my bot's roster.
(setq jabber-alert-presence-hooks nil)

(setq appt-display-format 'window)
(setq appt-disp-window-function 'botler->appt-message-me)
(setq appt-delete-window-function (lambda ()))

Adjust "" with your bot's JID and "" with who you want to send messages to. You can replace emacs-jabber-bot-login.el with whatevever you want to login with, but you probably want to setq jabber-account-list and then run (jabber-connect-all). Note that if you're connecting with a self-signed cert with Jabber.el you'll need to do:

(setq starttls-extra-arguments '("--insecure"))
(setq starttls-use-gnutls t)

I haven't yet figured how to whitelist my own self-signed cert yet, and passing in --insecure makes me feel like a monster, but it works for now. Maybe it's about time I finally got my ssl cert signed for

Anyway! It works, and I've been successfully getting appointment messages from my emacs session over IM for the last week, and it's pretty great. Next up, configuring things so that I can retrieve my agenda over IM when I request it and be able to IM myself new tasks and events.