Skip to content

Instantly share code, notes, and snippets.

(defvar adv-destination-room-overlay nil)
(make-variable-buffer-local 'adv-destination-room-overlay)
(defun adv-fontify-destination-room (s)
(set-text-properties
0 (length s)
`(face (:foreground ,(format "#%02x%02x%02x" 30 30 30)))
s)
s)
;; Keep emacs Custom-settings in separate file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)
;; Use lambda for anonymous functions
(font-lock-add-keywords
'js2-mode `(("\\(function\\) *("
(0 (progn (compose-region (match-beginning 1)
(match-end 1) "\u0192")
nil)))))
@magnars
magnars / kmbot.el
Created November 24, 2012 21:35
Emacs bot til Kodemakers irc-kanal
(require 's)
(require 'cl)
(require 'assoc)
(defvar kmbot--file ".kmbot-memory.el")
(defvar kmbot--definitions nil)
(defun kmbot--dump-list (list-symbol)
"Insert (setq LIST-SYMBOL LIST-VALUE) to current buffer."
(let ((value (symbol-value list-symbol)))
@magnars
magnars / *scratch3*.el
Created November 20, 2012 09:20
Project specific settings in Emacs
(add-hook
'find-file-hook
(lambda ()
(when (string-match-p "projects/my-project" (buffer-file-name))
(setq js2-additional-externs '("my" "additional" "externs")))))
@magnars
magnars / setup-hippie.el
Created November 12, 2012 17:23
Hippie Expand: use closest matches first
;; To use, replace these values in your hippie-expand-try-functions-list:
;;
;; try-expand-dabbrev => try-expand-dabbrev-closest-first
;; try-expand-line => try-expand-line-closest-first
;;
(defvar he-search-loc-backward (make-marker))
(defvar he-search-loc-forward (make-marker))
(defun try-expand-dabbrev-closest-first (old)
;; Elisp go-to-definition with M-. and back again with M-,
(autoload 'elisp-slime-nav-mode "elisp-slime-nav")
(add-hook 'emacs-lisp-mode-hook (lambda () (elisp-slime-nav-mode t)))
@magnars
magnars / buffer-defuns.el
Created October 12, 2012 10:27
create-scratch-buffer
(defun create-scratch-buffer nil
"create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
(interactive)
(let ((n 0)
bufname)
(while (progn
(setq bufname (concat "*scratch"
(if (= n 0) "" (int-to-string n))
"*"))
(setq n (1+ n))
@magnars
magnars / gist:3773499
Created September 24, 2012 00:02
Add spaces and proper formatting to linum-mode.
;; Add spaces and proper formatting to linum-mode. It uses more room than
;; necessary, but that's not a problem since it's only in use when going to
;; lines.
(setq linum-format (lambda (line)
(propertize
(format (concat " %"
(number-to-string
(length (number-to-string
(line-number-at-pos (point-max)))))
"d ")
@magnars
magnars / goto-line-with-feedback.el
Created August 8, 2012 06:42 — forked from joshwnj/goto-line-with-feedback.el
Emacs: Show line numbers temporarily, while prompting for the line number input
;; turn line numbers off by default
(global-linum-mode -1)
(defun goto-line-with-feedback (&optional line)
"Show line numbers temporarily, while prompting for the line number input"
(interactive "P")
(if line
(goto-line line)
(unwind-protect
(progn