This file contains hidden or 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 lexbind-insert-lexbind-enablement (&optional verbose) | |
| "Attempt to set `lexical-binding' to t in the current buffer's | |
| prop-line." | |
| (macrolet ((with-prop-line (&rest body) | |
| `(save-excursion | |
| (save-restriction | |
| (goto-char 1) | |
| (forward-line 1) | |
| (narrow-to-region 1 (point)) | |
| (goto-char (point-min)) |
This file contains hidden or 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 source-env-get (script &rest vars) | |
| "Source script in shell, then look for vars in the resulting subshell environment" | |
| (loop for line in (split-string (shell-command-to-string (concat "source " script " && set")) "[\n]" t) | |
| with result | |
| if (string-match "^\\([[:alpha:]]+\\)=\\(.*\\)$" line) | |
| do (let ((var (match-string 1 line)) | |
| (val (match-string 2 line))) | |
| (when (or (not vars) (member var vars)) | |
| (push (cons var val) result))) | |
| finally return result)) |
This file contains hidden or 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
| (cl-defun template-expand (string data &key | |
| recur | |
| (notation "${\\([^}]+\\)}") | |
| (default (lambda (x) (error "No expansion found for '%s'" x)))) | |
| "Expand variables from the alist `DATA' into the string `STRING'. | |
| The `RECUR' parameter triggers expansion of variables found in | |
| the substituted text. |
This file contains hidden or 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
| (setq org-capture-templates | |
| (("a" "Appointment" entry | |
| (file+headline | |
| (concat org-directory "/taskdiary.org") | |
| "Calendar") | |
| "* APPT %^{Description} %^g\n%?\nAdded: %U") | |
| ("n" "Notes" entry | |
| (file+datetree | |
| (concat org-directory "/taskdiary.org")) | |
| "* %^{Description} %^g %?\nAdded: %U") |
This file contains hidden or 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
| #!/usr/bin/env perl | |
| # ABSTRACT: proof of concept for sending subs to a child process for evaluation | |
| use strict; | |
| use warnings; | |
| use v5.10; | |
| use Data::Dumper; | |
| use Socket; | |
| use Time::HiRes qw(sleep); |
This file contains hidden or 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
| (require 'bookmark) | |
| (defvar my-doc-view-bookmark-push-p nil | |
| "Whether to push automatic doc-view bookmarks, or clobber them.") | |
| (defun my-doc-view-open-handler () | |
| (bookmark-jump (buffer-name))) | |
| (defun my-doc-view-save-handler () | |
| (if (eq major-mode 'doc-view-mode) |
This file contains hidden or 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
| ;;; The macro: | |
| (defmacro add-hook-one-time (hook function) | |
| "Add FUNCTION to HOOK. Remove it after its first execution." | |
| (let ((wrapper-function (make-symbol "wrapper-function-symbol"))) | |
| `(progn | |
| (defun ,wrapper-function () | |
| "Wrapper function that will be executed only once, and then removed from the hook." | |
| (funcall ,function) | |
| (remove-hook ,hook ',wrapper-function)) | |
| (add-hook ,hook ',wrapper-function)))) |
This file contains hidden or 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
| (setq month-names '("January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December")) | |
| (setq month-names-to-numbers (loop for name in month-names for number from 1 collect (cons name number))) | |
| (defun month-name-to-number (name) | |
| (or (cdr (assoc name month-names-to-numbers)) | |
| (error "Month not recognized: '%s'" name))) | |
| (defun month-name-to-number-nice (name) | |
| (let ((number (month-name-to-number name))) |
This file contains hidden or 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 ((data '((a 1 2 3)(c 5 6 7))) | |
| (insert '(b x y z))) | |
| (loop for prev on data | |
| for next on (cdr data) | |
| if (and next (eq (caar next) 'c)) | |
| do (let ((newcons (cons insert next))) | |
| (setcdr prev newcons))) | |
| data) |
This file contains hidden or 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") |