Skip to content

Instantly share code, notes, and snippets.

@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))))
@magnars
magnars / gist:3048595
Created July 4, 2012 17:57
cleanup-buffer.el
(defun cleanup-buffer-safe ()
"Perform a bunch of safe operations on the whitespace content of a buffer.
Does not indent buffer, because it is used for a before-save-hook, and that
might be bad."
(interactive)
(untabify-buffer)
(delete-trailing-whitespace)
(set-buffer-file-coding-system 'utf-8))
(defun cleanup-buffer ()
@magnars
magnars / gist:2868250
Created June 4, 2012 13:06
accumulate-forces
(defn accumulate-forces [o os]
(assoc o :force
(reduce vector/add (map (partial force-between o)
(filter #(not (identical? o %)) os)))))
@magnars
magnars / Controller.java
Created April 20, 2012 07:12
Keep session alive
@RequestMapping("/session/keepAlive.json")
public void sessionKeepalive(Model json) {
json.addAttribute("result", "ok");
}
@magnars
magnars / gist:2360578
Created April 11, 2012 17:05
ido-imenu as used in Emacs Rocks #10
(defun ido-imenu ()
"Update the imenu index and then use ido to select a symbol to navigate to.
Symbols matching the text at point are put first in the completion list."
(interactive)
(imenu--make-index-alist)
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
@magnars
magnars / gist:2350388
Created April 10, 2012 10:50
Push mark when using ido-imenu
;; Push mark when using ido-imenu
(defvar push-mark-before-goto-char nil)
(defadvice goto-char (before push-mark-first activate)
(when push-mark-before-goto-char
(push-mark)))
(defun ido-imenu-push-mark ()
(interactive)