page feed



8 October, 2015

Using a shell in Emacs

Emacs Pumpkin

Emacs rocks.

It’s true, it does.

Recently, though, I’ve been trying to streamline my use of the shell in Emacs. Here’s my Halloween Emacs tips.

Added support for multiple shells

The first, glaring problem with shells in Emacs is that you can only have one.

I added a function that creates a shell based on the remote host of a buffer. It also names the shell after that host, so if I’m working on /example.com:/some/file, I’ll get a shell called *shell:example.com* (instead of just *shell*). This allows you to have multiple shells open simultaneously, one per host. [Credit: EmacsWiki]

(defun my/shell (&optional buffer)
   (let* ((tramp-path (when (tramp-tramp-file-p default-directory)
                        (tramp-dissect-file-name default-directory)))
          (host (tramp-file-name-real-host tramp-path))
          (user (if (tramp-file-name-user tramp-path)
                  (format "%s@" (tramp-file-name-user tramp-path)) ""))
          (new-buffer-name (format "*shell:%s%s*" user host)))
     (shell (if host new-buffer-name buffer))))

Added F9 shell toggle

Then I added the F9 global key binding to toggle between the current buffer and the related shell for the current buffer’s host, creating that shell as necessary.

(defun my/shell-toggle (&optional buffer)
  (if (string-match "^\\*shell[\\*:]" (buffer-name) )
      (my/shell buffer)))
(global-set-key [f9] 'my/shell-toggle)

Handle shell termination

There are several ways you could handle terminating the shell. You could, just for shell buffers, turn off the prompt that asks you if you’re sure you want to kill a buffer with an active subprocess running in it, and then use C-x k. But this would kill bash rudely, and bash would not save your command history. You could tell bash to save command history after every command. But this leaves executed commands between different shells all intermixed in the history file and shells would no longer have their own individual session history. That doesn’t appeal to me.

So I opted for another method: detect when the shell terminates and close the emacs buffer. This way, you can hit Ctrl-D (same as you would in a terminal window), bash saves its history, and everyone’s happy.

(add-hook 'comint-exec-hook
          (lambda ()
            (set-process-sentinel (get-buffer-process (current-buffer))
(defun my/shell-process-sentinel (process state)
  ;; show shell status and kill the buffer automatically
  (message "shell: %s" state)
  (if (or
       (string-match "exited abnormally with code.*" state)
       (string-match "finished" state))
      (kill-buffer (current-buffer))))



20 March, 2015

New cloud facilities

We are now running ownCloud at cloud.waxworlds.org. If want a user account created, please get in touch.

(FYI: ownCloud allows you to upload and sync files and documents between devices and then share them publicly or privately between other owncloud users or anyone who you gave a link to.)


16 March, 2015

Oak moving location

Oak is due to move home on 18th March and it's IP address will change again. There may be a 24hr delay as DNS catches up. As usual, please report any problems.

Update: Oak has moved. There may be a 24hr delay with DNS as caches expire. [2015-03-19]


27 February, 2015

Mail server listed in spam RBL

Due to mail.waxworlds.org (a.k.a. oak.waxworlds.org) being temporarily assigned a dynamic IP address, it has been listed in the SORBS DUHL spam RBL.

This is being persued with SORBS. I will post updates as they become available.

Update: SORBS will not unblacklsit oak while it has a dynamic IP address. It will move to a static address on 17th March. Appologies for any inconvenience in the meantime. [2015-03-09]

Update: This issue should be resolved after the forthcoming move. Appologies for any inconveniences. [2015-03-16]


21 December, 2014

Service disruption to oak

Oak's IP address has changed again, following the recent unexpected outage. All services should be up and running again now though. Please report any problems.


27 April, 2014

Service disruption to oak

Our internet provider for oak.waxworlds.org is experiencing a fault and oak is down. For updates, see their fault status page. I will update this post when the issue is resolved.

Update: The problem has now been resolved. [2014-04-27]


25 April, 2014

Service disruption to oak

We should be changing the service provider for oak.waxworlds.org some time today. oaks static IP address will change again. There may be a temporary disruption to services as this occurs. Most noticeably, email and jabber are handled by oak.

Update: oak is now down until this evening. [2014-04-25]

Update: DNS has been reconfigured with the new IP address, but may take a few hours to catch up. [2014-04-25]

Update: Everything is working again (barring DNS catching up). [2014-04-25]


6 April, 2014

Service disruption to oak

Our service provider is changing the static IP address of oak.waxworlds.org in the next few days. There may be a temporary disruption to services as this occurs. Most noticeably, email and jabber are handled by oak. I'll update as there is more information.

Update: oak is down and will remain so until this evening. [2014-04-08]

Update: oak is back up with its new IP address (although there will be a delay as DNS catches up). [2014-04-09]


1 July, 2013

Server software updates

Over the next few weeks the software running on all the servers will be upgraded to Debian 7. This should be uneventful, insofar as users are concerned, but please let me know if you find something that isn't working as expected.

Update: ash has been upgraded. [2013-07-23]

Update: oak has been upgraded. [2013-08-22]

Update: The issue with authenticating to send emails from outside of the network has been fixed. [2013-08-27]


1 December, 2012

New root certificate

As planned, the waxworlds.org root certificate was changed today, to avoid it expiring. All service certificates have also been replaced for ones signed by the new root certificate. The new root certificate will expire in 2100, so I shouldn't need to replace it again any time soon.