2013-01-22 Gists on Emacs Wiki

I just read a rant about Emacs Wiki and it’s alternative: The Wikemacs Experiment: 300 Days Later. Check out How Emacs Wiki Works for some context from my point of view. Anyway, the anonymous author says: “Maybe someone could work with Alex to add gist-style code snippets to Oddmuse, and make it so that code can be cited inline on Wiki pages, so that anyone visiting the page is automatically looking at the most up to date version of the code.”

Let’s take this random gist as an example. Click on the “view raw” button. Use <include text "..."> to transclude it:

(setq abg-elisp-external-dir
      (expand-file-name "external" abg-elisp-dir))

; ...

; Add external projects to load path
(dolist (project (directory-files abg-elisp-external-dir t "\\w+"))
  (when (file-directory-p project)
    (add-to-list 'load-path project)))

Actually, I added an Emacs Wiki feature using two lines of code that add support for fancy inclusion:

<include gist "https://gist.github.com/1236665">

It only works over there, however. See EmacsWiki:Gists.

Anyway, the same also works for Lisppaste:

<include text "http://paste.lisp.org/display/134703/raw">

Results in:

;; Set XTERM resources as so
;; metaSendsEscape: false
;; altSendsEscape: false
;; eightBitInput: true

;; Verify with cat > /dev/null command that pressing alt-a
;; alt-b and so on produces single >128bit char (will look
;; like a with a hat

;; once above is working in emacs do

;; Prevent pressing esc O from triggering binding
(define-key (get-input-decode-map) "\eO" nil)

;; tell emacs Meta is 8th bit
(cond ((fboundp 'set-input-meta-mode)
      (set-input-meta-mode t))
    (t (set-input-mode t nil t)))

I don’t think there’s a nice way to include the colored version, unfortunately.

Update: I added support and minimal Lisp highlighting for the following:

<include lisppaste "http://paste.lisp.org/display/134703">

It only works over there, of course.



Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.