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
<?php | |
// Define the 'class' class | |
$class = Obj() | |
->fn('new', function ($class) { | |
$newClass = Obj($class->methods) | |
->fn('new', function($class) { | |
$obj = Obj($class->imethods); | |
$args = func_get_args(); | |
array_shift($args); |
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
(eval-when-compile | |
(require 'cl)) | |
(defmacro* scope (&rest args) | |
"Partial implementation of scope the statement from D2. | |
A series of :key val arguments are accepted after which there is | |
a body of forms. The body is executed within an unwind-protect, | |
with the :exit form being unconditionally executed, and :success | |
and :failure conditionalised. A :failure-return argument will be | |
evaluated and its value returned in place of any condition raised. |
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 eval-expression-to-kill-ring () | |
"Evaluate an expression interactively and place its result in the kill ring" | |
(interactive) | |
(kill-new (call-interactively 'eval-expression))) |
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
(defvar user/html-entity-to-unicode-alist | |
'(("Aacute" . "Á") ("aacute" . "á") ("Acirc" . "Â") ("acirc" . "â") ("acute" . "´") ("AElig" . "Æ") ("aelig" . "æ") ("Agrave" . "À") ("agrave" . "à") ("alefsym" . "ℵ") ("Alpha" . "Α") ("alpha" . "α") ("amp" . "&") ("and" . "∧") ("ang" . "∠") ("apos" . "'") ("aring" . "å") ("Aring" . "Å") ("asymp" . "≈") ("atilde" . "ã") ("Atilde" . "Ã") ("auml" . "ä") ("Auml" . "Ä") ("bdquo" . "„") ("Beta" . "Β") ("beta" . "β") ("brvbar" . "¦") ("bull" . "•") ("cap" . "∩") ("ccedil" . "ç") ("Ccedil" . "Ç") ("cedil" . "¸") ("cent" . "¢") ("Chi" . "Χ") ("chi" . "χ") ("circ" . "ˆ") ("clubs" . "♣") ("cong" . "≅") ("copy" . "©") ("crarr" . "↵") ("cup" . "∪") ("curren" . "¤") ("Dagger" . "‡") ("dagger" . "†") ("darr" . "↓") ("dArr" . "⇓") ("deg" . "°") ("Delta" . "Δ") ("delta" . "δ") ("diams" . "♦") ("divide" . "÷") ("eacute" . "é") ("Eacute" . "É") ("ecirc" . "ê") ("Ecirc" . "Ê") ("egrave" . "è") ("Egrave" . "È") ("empty" . "∅") ("emsp" . " ") ("ensp" . " ") ("Epsilon" . "Ε") ("epsilon" |
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 hide-by-regexp (regexp &optional buffer start finish) | |
"First stab at hiding from START (default: (point-min)) to the end of the first match of REGEXP in BUFFER." | |
(save-excursion | |
(with-current-buffer (or buffer (current-buffer)) | |
(unless start (setq start (point-min))) | |
(goto-char start) | |
(when (search-forward-regexp regexp finish t) | |
(add-text-properties start (point) '(invisible 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* kvplist-merge (&rest plists) | |
"Merge the 2nd and subsequent plists into the first, clobbering values set by lists to the left." | |
(let ((result (car plists)) | |
(plists (cdr plists))) | |
(loop for plist in plists do | |
(loop for (key val) on plist by 'cddr do | |
(setq result (plist-put result key val)))) | |
result)) |
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 package-dirs (package-name) | |
"Ignore version numbers in ELPA package directories" | |
(let ((regex (concat "^" package-name "-.*"))) | |
(mapcar (lambda (x) (concat package-user-dir "/" x)) | |
(remove-if-not (lambda (x) (string-match regex x)) | |
(directory-files package-user-dir))))) |
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
(defvar scratch-buffer-locals '(lexical-binding t) | |
"A plist of variables and bindings to apply in a new scratch buffer") | |
(defvar scratch-buffer-mode-locals '(cperl-mode (cperl-indent-level 4)) | |
"A plist of modes and the buffer locals to set in a new scratch buffer according to mode") | |
(defun create-scratch-buffer (&optional mode) | |
"Create a new scratch buffer to work in. (could be *scratch* - *scratchX*)" | |
(interactive "aMode: ") | |
(let ((n 0) |
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 ((regex | |
(rx | |
(or bol bos (not (any "["))) | |
(group | |
(>= 2 (and (any "A-Z")(one-or-more (any "a-z")))))))) | |
(list | |
(replace-regexp-in-string regex "\\1" "[OneWordOrMore]") | |
(replace-regexp-in-string regex "\\1" "Onewordormore") | |
(replace-regexp-in-string regex "\\1" "OneWordormore") | |
(replace-regexp-in-string regex "\\1" "OneWordOrMore"))) |
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 ((regex | |
(rx | |
(or bol bos) | |
(? (not (any "["))) | |
(group | |
(>= 2 (and (any "A-Z")(one-or-more (any "a-z"))))))) | |
case-fold-search) | |
(list | |
(replace-regexp-in-string regex "{\\1}" "[OneWordOrMore]") | |
(replace-regexp-in-string regex "{\\1}" "Onewordormore") |
OlderNewer