Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nicferrier's full-sized avatar

Nic Ferrier nicferrier

View GitHub Profile
@nicferrier
nicferrier / lexical-sentinel.el
Created September 29, 2011 20:58
macro for doing lexically scoped sentinels
;;; -*- lexical-binding: t -*-
(defmacro with-process-shell-command (name buffer command &rest sentinel-forms)
`(let ((proc (start-process-shell-command ,name ,buffer ,command)))
(let ((sentinel-cb (lambda (process signal)
,@sentinel-forms)))
(set-process-sentinel proc sentinel-cb)
)))
@nicferrier
nicferrier / creole.el
Created October 24, 2011 22:51
most of the bits of a creole parser in emacslisp
;;; creole.el --- A parser for the Creole Wiki language
;;; Copyright (C) 2011 by Nic Ferrier
;;; Commentary:
;; This is a WikiCreole wiki parser. WikiCreole is something like the
;; Wiki language used by OddMuse, which is the EmacsWiki wiki
;; language.
@nicferrier
nicferrier / withprocesshellcommand.el
Created October 28, 2011 19:25
a macro for doing async shell commands a little easier
(defmacro with-process-shell-command (command buffer-or-filter &rest forms)
"Run COMMAND through /in the BUFFER-OR-FILTER using FORMS as the sentinel.
FORMS is a 'cond' like you'd use in a sentinel, for example:
(with-process-shell-command \"ls\" some-buffer
((equal signal \"finished\\n\")
;; Clean up?
(with-current-buffer (get-buffer \"* log *\")
(insert \"some text\\\n\")))
@nicferrier
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
(defun ispell-lookup (word)
(interactive "Mword: ")
(with-current-buffer (get-buffer-create "* ispell-lookup *")
(erase-buffer)
(insert word)
(goto-char (point-min))
(switch-to-buffer-other-window (current-buffer))
(ispell-word)))
(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.
@nicferrier
nicferrier / pinboard.el
Created November 3, 2011 06:16
pinboard doodling for emacslisp using url-retrieve
(defun pinboard-get ()
"A little function to retrieve pinboard.in into a buffer.
The buffer is *pinboard*. We don't even switch to it."
(interactive)
(url-retrieve
"https://api.pinboard.in/v1/posts/all/?format=json"
(lambda (status &rest args)
(save-excursion
(re-search-forward "^$" nil 't)
;;; wikiengine.el --- a WIKI engine -*- lexical-binding: t -*-
;; Copyright (C) 2011 Nic Ferrier
;; Author: Nic Ferrier - <nferrier@ferrier.me.uk>
;; Version: 0.1
;; Keywords: hypermedia
;; 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
(progn (setq load-path (quote ("/home/nferrier/.emacs.d/elpa/ahg-0.99" "/home/nferrier/.emacs.d/elpa/chess-1.96" "/home/nferrier/.emacs.d/elpa/creole-0.6.1"
"/home/nferrier/.emacs.d/elpa/elnode-0.9"))) (let ((target "/home/nferrier/wiki/README.creole") (header "<div id='top'></div>") (footer "<div id='footer'>
<form action='/wiki/' method='POST'>
<textarea name='wikitext'>
{{text}}
</textarea>
<input type='submit' name='send' value='send'/>
<input type='submit' name='preview' value='preview'/>
</form>
</div>")) (progn (require (quote creole)) (creole-wiki target :destination t :body-header header :body-footer footer))))
@nicferrier
nicferrier / gist:1368492
Created November 15, 2011 21:51
new vc agnostic veh
def get_config(repo, rev=None):
"""Get the config from the veh root.
We try and work out what version control system is being used from
the location of the veh config file.
We currently only support Mercurial and GIT.
The veh.conf MUST exist in the file system though we might read a
completly different version of course."""