Skip to content

Instantly share code, notes, and snippets.

View *scratch*.el
(defun evil-cd (dir)
(interactive "D")
(if (file-exists-p dir)
(message dir)
(message "error")))
(evil-ex-define-cmd "cd" 'evil-cd)
View *scratch*.el
(defmacro my-notmuch-search-creator (name &rest tags)
(let ((funname (intern (concat "my-notmuch-search-for-" (symbol-name name)))))
(defun ,funname ()
(notmuch-search-tag (my-notmuch-toggle-tags-changes
View *scratch*.el
(defun evil-filter (count)
(interactive "p")
(evil-ex (if current-prefix-arg
(format ".,+%d!" count)
(define-key evil-normal-state-map (kbd "!") #'evil-filter)
View *scratch*.el
(defun switch-in-keymap (key1 key2 keymap)
(let ((cmd1 (lookup-key key1 keymap))
(cmd2 (lookup-key key2 keymap)))
(define-key keymap key1 cmd2)
(define-key keymap key2 cmd1)))
(mapc (lambda (map) (switch-in-keymap "x" "y" map))
(list evil-motion-state-map
View evil-ace-jump-integration.el
;; AceJump integration is now included in evil, this gist is only preserved for historical reasons.
;; Please use the provided integration (it's far more advanced)
;; AceJump is a nice addition to evil's standard motions.
;; The following definitions are necessary to define evil motions for ace-jump-mode (version 2).
;; ace-jump is actually a series of commands which makes handling by evil
;; difficult (and with some other things as well), using this macro we let it
;; appear as one.
cofi / gist:3013327
Created Jun 28, 2012
Command using Helm to select spelling corrections
View gist:3013327
(defun cofi/helm-flyspell-correct ()
"Use helm for flyspell correction.
Adapted from `flyspell-correct-word-before-point'."
;; use the correct dictionary
(let ((cursor-location (point))
(word (flyspell-get-word))
(opoint (point)))
View cofi-func.el
(require 'cl))
(defun cofi/inc-at-pt (amount)
"Increment the number at point by `amount'"
(interactive "p*")
;; find binary literals
(when (looking-back "0[bB][01]*")
import sys
import types
class Tee(object):
Contextmanager for writing simulaniously to multiple files.
def __init__(self, *args, **kwargs):
args -- file names or open file-like objects
cofi / gist:1070347
Created Jul 7, 2011
revert all(!!) buffers after git pull
View gist:1070347
(require 'cl)
(defadvice magit-pull (after refresh-buffers-after-pull activate)
(loop for buffer in (buffer-list)
when (buffer-file-name buffer)
do (with-current-buffer buffer
(if (buffer-modified-p buffer)
;; ask for confirmation on modified buffers
(revert-buffer 'ignore-auto 'noconfirm)))))