Skip to content

Instantly share code, notes, and snippets.

(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:
(let* ((x 1) (y 2)) ...)
===
(setq x-old x)
(setq y-old y)
(setq x 1)
(setq y 2)
...
(setq x x-old)
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
...
(global-set-key (kbd "C-c u") 'unfill-paragraph)
(defun unfill-paragraph ()
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
@jorgenschaefer
jorgenschaefer / eldot.el
Created June 10, 2014 12:21
Trivial elisp code to create a basic dot file call graph
;; 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
(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)
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,
(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))))
$ 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
(defun circe-command-AKICK (args)
(circe-command-MSG "ChanServ"
(format "AKICK %s ADD %s" circe-chat-target args)))