This file contains 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 foo () | |
(interactive) ; To make it a command that can be bound to a key | |
(string-rectangle ; Call this function | |
(region-beginning) ; First arg: START | |
(region-end) ; Second arg: END | |
"ZZZ")) ; Third arg: STRING | |
;; More idiomatically: |
This file contains 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
(let* ((x 1) (y 2)) ...) | |
=== | |
(setq x-old x) | |
(setq y-old y) | |
(setq x 1) | |
(setq y 2) | |
... | |
(setq x x-old) |
This file contains 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
m = re.match(r'^(?:\s*([0-9]+)\s*x\s+)?(.*)$', line) | |
if m is None: | |
continue | |
quantity, typename = m.groups() | |
if quantity is None: | |
quantity = 1 | |
... |
This file contains 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
(global-set-key (kbd "C-c u") 'unfill-paragraph) | |
(defun unfill-paragraph () | |
(interactive) | |
(let ((fill-column (point-max))) | |
(fill-paragraph nil))) |
This file contains 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
;; Save to foo.dot, run dot -Tpng foo.dot -o foo.png, done | |
(defun eldot () | |
(interactive) | |
(let ((nodes (make-hash-table :test #'eq)) | |
(expr nil)) | |
(catch 'done | |
(save-excursion | |
(goto-char (point-min)) | |
(while t |
This file contains 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 lyk/close-buffer-on-process-exit () | |
(set-process-sentinel (get-buffer-process (current-buffer)) | |
(lambda (proc change) | |
(when (and (string-match "finished" change) | |
(process-buffer proc)) | |
(kill-buffer (process-buffer proc)))))) | |
(add-hook 'comint-exec-hook 'lyk/close-buffer-on-process-exit) |
This file contains 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
class UpdateOrCreateMixin(object): | |
"""Mixin-Class for models.Manager subclasses. | |
Provide the update_or_create method from Django 1.7 in earlier | |
Djangos. | |
""" | |
def update_or_create(self, defaults=None, **kwargs): | |
"""A convenience method for updating an object with the given kwargs, |
This file contains 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
(when (file-directory-p "~/.emacs.d/site-lisp") | |
(add-to-list 'load-path "~/.emacs.d/site-lisp") | |
(dolist (dirname (directory-files "~/.emacs.d/site-lisp" t "^[^.]")) | |
(when (file-directory-p dirname) | |
(add-to-list 'load-path dirname)))) |
This file contains 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
$ cat $PYTHONSTARTUP | |
try: | |
# this add completion to python interpreter | |
import readline | |
import rlcompleter | |
# see readline man page for this | |
readline.parse_and_bind("set show-all-if-ambiguous on") | |
readline.parse_and_bind("tab: complete") | |
except: | |
pass |
This file contains 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 circe-command-AKICK (args) | |
(circe-command-MSG "ChanServ" | |
(format "AKICK %s ADD %s" circe-chat-target args))) |
OlderNewer