Skip to content

Instantly share code, notes, and snippets.

View nicferrier's full-sized avatar

Nic Ferrier nicferrier

View GitHub Profile
nicferrier / gist:2277987
Created April 1, 2012 19:34
Clone a git repo if it does not exist, or pull into it if it does exist
# We do it this way so that we can abstract if from just git later on
if [ ! -d $LOCALREPO_VC_DIR ]
(defun motionless-mark ()
"Do commands until a command.
Remember point and then read a key to end a sequence of commands.
The sequence is read (until you enter the key that is being matched
as the end marker) and executed and then, when the end command is
matched, point is moved back to the remembered location and
the end command is executed.
This can be useful for things like slurp."
nicferrier / elnode-ijs.el
Last active June 8, 2018 00:05
A complete javascript shell with elnode. It's pretty simple obviously and there's a lot of return value hacking to do. It's quite interesting that this stuff is so easy though. I think it might be a useful addition to any elnode project to map in a handler that let you control the javascript from the elnode emacs instance.
;;; interactive javascript shell with elnode -*- lexical-binding: t -*-
(elnode-app elnode-ijs-dir comint uuid)
(defvar elnode-ijs/input nil
"Input for the js shell.
Each element is a cons of a uuid and the javascript to send.")
(defvar elnode-ijs/input-hash (make-hash-table :test 'equal)
nicferrier / cps-foreach-bg.el
Created February 15, 2013 20:08
sentinel based cps in emacs-lisp. bit wierd
(defun cps-foreach-bg (proc l cont &optional command-args)
"Call PROC with each element of L, in the background.
When there are no more elements of L call CONT with L.
Optionally use the COMMAND-ARGS as the command to run in the
operating system to do the queueing."
(let* ((process-args (or command-args '("sleep" "1")))
(qproc (apply
nicferrier / worker-elisp.el
Created October 28, 2011 20:48
Doing worker processing with EmacsLisp
(defmacro worker-elisp (output-stream &rest lisp)
"Evaluate the LISP in a child Emacs sending output to OUTPUT-STREAM.
The child Emacs has a 'load-path' exactly as the 'load-path' of
the parent Emacs at execution.
The OUTPUT-STREAM could be a buffer, a function or a process.
If the OUTPUT-STREAM is a process it may have a process property
nicferrier / nic-custom.el
Created July 22, 2012 10:21
My .emacs self installing portable config
:;exec emacs -batch -l "$0" -f nic-custom-self-install "$@"
;;; custom.el --- Nic's custom stuff for Emacs
;; Copyright (C) 2012 Nic Ferrier <>
;; Author: Nic Ferrier <>
;; Keywords: local
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
(defmacro elnode-worker-elisp (output-stream &rest body)
"Evaluate the BODY in a child Emacs connected to OUTPUT-STREAM.
The child Emacs has a 'load-path' exactly as the 'load-path' of
the parent Emacs at execution.
The created child Emacs process is returned. It's possible to
kill the child Emacs process or do other things to it directly.
This could be very dangerous however, you should know what you
are doing before attempting it.
<div id="tip"><span id="tipheart">♥</span><span id="tipword">gittip</span></div>
commit c91974d5afc8216e4cc87435eaff3bf950074092 (HEAD, refs/remotes/nictest/build-dist, refs/remotes/nicsoundcloud/build-dist, refs/heads/build-dist)
Author: Nic Ferrier <>
Date: Wed Jul 31 17:12:35 2013 +0100
add a dist target to the Makefile to build a tarball.
Modified .pkgignore
diff --git a/.pkgignore b/.pkgignore
index 139b42b..be41456 100644
--- a/.pkgignore
(defun tapas-creole->bootstrap (struct)
"Transform STRUCT, a creole structure, into something bootstrapable.
HTML DIV elements are hacked into the structure wherever we find
an HR element. The HR elements are retained."
(let ((tx
(loop for e in struct
(if (eq (car e) 'hr)
(list '(hr) '(plugin-html . "</div><div class=\"section\">"))