Skip to content

Instantly share code, notes, and snippets.

View legumbre's full-sized avatar

Leonardo Etcheverry legumbre

  • GlamST / Ulta
  • Montevideo, Uruguay
View GitHub Profile
-- make all unbound vars of the form rNN resolve to level.rings[NN]
mt={}
mt.__index=function (t, k)
local r, rindex = string.find(k, "r%d", 0)
rindex = rindex and tonumber(string.sub(k, rindex))
if rindex then
return level.rings[rindex]
else
return nil
@legumbre
legumbre / scratch.el
Created March 11, 2012 03:44
compile advice
;; Just an idea for Boscop. When (eq display-buffer-reuse-frames t)
;; display-buffer will raise the frame showing the compilation
;; buffer. This advice raises the original frame so focus is not in
;; the compilation buffer frame.
(defadvice compile (around avoid-compile-switching-frames activate)
(let ((cf (selected-frame)))
ad-do-it
(raise-frame cf)))
;; Just an idea for Boscop. When (eq display-buffer-reuse-frames t)
;; display-buffer will raise the frame showing the compilation
;; buffer. This advice raises the original frame so focus is not in
;; the compilation buffer frame.
(defadvice compile (around avoid-compile-switching-frames activate)
(let ((cf (selected-frame)))
ad-do-it
(raise-frame cf)))
(defadvice narrow-to-region (around clone-when-narrowing-already-visible-buffer activate)
"Clone an indirect buffer when attempting to narrow the
contents of buffer visible in more than one window."
(save-excursion
(when (> (length (get-buffer-window-list (current-buffer) nil nil)) 1)
(let ((cloned-buffer (clone-indirect-buffer nil t) ))
(switch-to-buffer cloned-buffer t)))
ad-do-it))
@legumbre
legumbre / json-pretty-print.el
Created February 21, 2012 18:09
pretty print json
;; pretty print a json region using python
;;
;; M-| python -m json.tool
@legumbre
legumbre / gist:1848651
Created February 16, 2012 23:12
github friendly commit messages in magit
;; github-friendly commit messages as per:
;; https://github.com/blog/926-shiny-new-commit-styles
(add-hook 'magit-log-edit-mode-hook
(lambda ()
;; highlight too-long commit summary
(set (make-local-variable 'whitespace-line-column) 50)
(set (make-local-variable 'whitespace-style) '(face lines-tail))
(whitespace-mode 1)
;; autofill longer explanatory text
(setq fill-column 72)
@legumbre
legumbre / gist:1847750
Created February 16, 2012 20:51
conkeror in_module mechanism removal
commit 37da0aed0b33973893ac909fc707d84ce7c3f170
Author: John Foerch <[email protected]>
Date: Sun Jan 29 21:27:19 2012 -0500
remove in_module mechanism
The procedure in_module was a central concept to the "new module system"
of 2010-03-19 that was to have made modules possible within the framework
of Conkeror's 'load' and 'require' mechanism. However, there was a fatal
flaw in the design, and it really doesn't work after all. The flaw was
(defun erc-highlight-nicknames ()
"Searches for nicknames and highlights them. Uses the first
twelve digits of the MD5 message digest of the nickname as
color (#rrrrggggbbbb)."
(with-syntax-table erc-button-syntax-table
(let (bounds word color new-nick-face)
(goto-char (point-min))
(while (re-search-forward "\\w+" nil t)
(setq bounds (bounds-of-thing-at-point 'word))
(setq word (buffer-substring-no-properties
(defun rrnic-diff (cmd1 cmd2)
(interactive
(list
(read-shell-command "Shell command (1): " nil nil)
(read-shell-command "Shell command (2): " nil nil)))
(let ((b1 (get-buffer-create "*1*")) (b2 (get-buffer-create "*2*")))
(shell-command cmd1 b1)
(shell-command cmd2 b2)
(ediff-buffers b1 b2)))
(defun rrnic-diff (cmd1 cmd2)
(interactive
(list
(read-shell-command "Shell command (1): " nil nil)
(read-shell-command "Shell command (2): " nil nil)))
(let ((b1 (get-buffer-create "*1*")) (b2 (get-buffer-create "*2*")))
(shell-command cmd1 b1)
(shell-command cmd2 b2)
(ediff-buffers b1 b2)))