Skip to content

Instantly share code, notes, and snippets.

@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")))))
;; 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
@magnars
magnars / gist:3178597
Created July 25, 2012 20:50
Saner magit quit
;; full screen magit-status
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
@magnars
magnars / gist:3155433
Created July 21, 2012 10:58
Closing *Completion* buffer easily
(defun insert-self-and-close-completion (N)
(interactive "p")
(self-insert-command N)
(ignore-errors
(bury-buffer "*ESS Completions*")))
(define-key ess-mode-map (kbd "SPC") 'insert-self-and-close-completion)
(define-key ess-mode-map (kbd "(") 'insert-self-and-close-completion)
@magnars
magnars / *github:gists*
Created July 18, 2012 08:46
Overlays not working in ecukes
5487177 04/30/13 09:37 public
5057886 02/28/13 17:15 public
4771940 02/12/13 19:12 public
4328055 12/18/12 14:42 public
+ 4e8ae71... 12/12/12 11:51 public
4141489 11/24/12 22:35 public Emacs bot til Kodemakers irc-kanal
+ 4116916 11/20/12 10:20 public Project specific settings in Emacs
eea74d7... 11/16/12 20:53 public
+ a305a6c... 11/15/12 09:28 public introduce-parameter
4060654 11/12/12 18:23 public Hippie Expand: use closest matches first
(defun kill-region-or-backward-word ()
(interactive)
(if (region-active-p)
(kill-region (region-beginning) (region-end))
(backward-kill-word 1)))
@magnars
magnars / gist:3129159
Created July 17, 2012 12:28
Inverse of C-k
(global-set-key (kbd "C-S-k") (lambda () (interactive)
(kill-region (save-excursion (beginning-of-line) (point))
(point))))