Skip to content

Instantly share code, notes, and snippets.

(define (subsets s)
(if (null? s)
(list '())
(let ((rest (subsets (cdr s))))
(append rest (map (lambda (x)
(cons (car s) x))
rest)))))
(define (flatten lst)
(if (null? lst)
'()
(let ((a (car lst)) (d (cdr lst)))
(if (pair? a)
(append (flatten a) (flatten d))
(cons a (flatten d))))))
(define fringe flatten)
(define (same-parity first . rest)
(define (collect lst test)
(if (null? lst)
'()
(let ((a (car lst)) (d (cdr lst)))
(if (test a)
(cons a (collect d test))
(collect d test)))))
(cons first
(collect rest (if (even? first) even? odd?))))
(defface latex-hl-line
'((t (:background "DeepSkyBlue4")))
"Face for the lines start with \\documentclass[foo]{bar},
\\begin{document} or \\end{document}."
:group (if (featurep 'font-latex)
'font-latex-highlighting-faces
'font-lock-faces))
(font-lock-add-keywords
'latex-mode
(defun do-applescript+ (&rest scripts)
"Like `do-applescript', but execute concatenated SCRIPTS.
In case the execution fails, return an error."
(condition-case err
(do-applescript
(apply 'concat scripts))
(error err)))
(defun show-in-finder (&optional path behind)
"Display current file/directory in a Finder window"
;;; init-file-maker.el --- Help making your init files
;;; Setup:
;; (require 'init-file-maker)
;; (setq ifm:dir "/path/to/your-init-files-dir")
;;; Usage:
;; To make init file, type M-x ifm:make RET.
(require 'cl)
(require 'popup)
(defvar popup-color-string
(let ((x 9) (y 3))
(mapconcat 'identity
(loop with str = (make-string x ?\ ) repeat y collect str)
"\n"))
"*String displayed in tooltip.")
;; mac-dict.el --- Look up a word at point in the Dictionary.app and popup the result of it automatically.
;;; Requirements:
;; `dict.py' - <http://sakito.jp/mac/dictionary.html#python>
;; `popup.el' - <http://github.com/m2ym/auto-complete>
;;; Setup:
;; 1. Put the `dict.py' to somewhere you like. And add the execute
(require 'cl)
(defun region-string ()
"Return a string of marked region or nil."
(and mark-active
transient-mark-mode
(buffer-substring-no-properties (region-beginning) (region-end))))
(defun word/region-string ()
"Return a string of word at point or region."
;; inparen.el --- Highlight parentheses and the inside of them.
;;; Setup:
;; (require 'inparen)
;; (global-inparen-mode t)
;;; Code:
(require 'paren)