Skip to content

Instantly share code, notes, and snippets.

@jiyoo
jiyoo / mutreb.el
Created March 17, 2014 22:47
Three MutReb tests
(setq aa (vector 10 11 12))
(defun foo (bb)
(setf (elt bb 0) (+ 90 9))
(setq bb 9999))
(foo aa)
(print aa) ; => [99 11 12]
(require 'cl-lib)
(defun m-random-choice (seq)
(elt seq (random (length seq))))
(defvar m-doors (list 1 2 3))
;; baseball scenario:
(cl-loop repeat 10000
for car-door = (m-random-choice m-doors)
for chosen-door = 1 ; door chosen by you
for hit-door = (m-random-choice m-doors) ; door hit by the baseball
@jiyoo
jiyoo / font-lock-example-4.el
Created September 23, 2013 19:58
word boundary font lock test
;;; Example 4
'(wxyz xy xy-xy end)
'(aabb ab ab-ab end)
(progn
(font-lock-add-keywords
nil
`(("\\bxy\\b"
(0 'success t))
@jiyoo
jiyoo / fix-quotes-instruction.el
Last active December 19, 2015 03:48
instruction for what to do with a code you copied from a blog comment
;; copy the following and
;; paste it in your emacs init file (the dotemacs file)
(defun fix-quotes (beg end)
"replaces pretty quotes to ugly quotes."
(interactive "r")
(save-excursion
(format-replace-strings '(("\x2019" . "'")
("\x201c" . "\"")
("\x201d" . "\"")