This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun evil-cd (dir) | |
(interactive "D") | |
(if (file-exists-p dir) | |
(message dir) | |
(message "error"))) | |
(evil-ex-define-cmd "cd" 'evil-cd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro my-notmuch-search-creator (name &rest tags) | |
(let ((funname (intern (concat "my-notmuch-search-for-" (symbol-name name))))) | |
`(progn | |
(defun ,funname () | |
(interactive) | |
(notmuch-search-tag (my-notmuch-toggle-tags-changes | |
(notmuch-search-get-tags) | |
tags))) | |
',funname))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun evil-filter (count) | |
(interactive "p") | |
(evil-ex (if current-prefix-arg | |
(format ".,+%d!" count) | |
".!"))) | |
(define-key evil-normal-state-map (kbd "!") #'evil-filter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 | |
evil-normal-state-map | |
evil-emacs-state-map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun cofi/helm-flyspell-correct () | |
"Use helm for flyspell correction. | |
Adapted from `flyspell-correct-word-before-point'." | |
(interactive) | |
;; use the correct dictionary | |
(flyspell-accept-buffer-local-defs) | |
(let ((cursor-location (point)) | |
(word (flyspell-get-word)) | |
(opoint (point))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eval-when-compile | |
(require 'cl)) | |
(defun cofi/inc-at-pt (amount) | |
"Increment the number at point by `amount'" | |
(interactive "p*") | |
(save-match-data | |
(or | |
;; find binary literals | |
(when (looking-back "0[bB][01]*") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) | |
(revert-buffer 'ignore-auto 'noconfirm))))) |