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
(define (subsets s) | |
(if (null? s) | |
(list '()) | |
(let ((rest (subsets (cdr s)))) | |
(append rest (map (lambda (x) | |
(cons (car s) x)) | |
rest))))) |
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
(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) |
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
(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?)))) |
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
(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 |
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 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" |
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
;;; 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. |
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 '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.") |
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
;; 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 |
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 '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." |
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
;; inparen.el --- Highlight parentheses and the inside of them. | |
;;; Setup: | |
;; (require 'inparen) | |
;; (global-inparen-mode t) | |
;;; Code: | |
(require 'paren) |
NewerOlder