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
;; -*- Mode: Lisp; Syntax: Common-Lisp -*- | |
;;; Package Management | |
(in-package :cl-user) | |
(defpackage :hige | |
(:use :cl | |
:drakma | |
:cl-ppcre) | |
#+ABCL (:shadow :y-or-n-p) |
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
;;;; Emacs Lisp | |
(require 'cl) | |
(setf *opening-stream-buffers* | |
(make-hash-table)) | |
(defmacro with-default-values (binds &rest body) | |
`(progn | |
,@(mapcar |
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 read-line (buf) | |
(let ((start (point))) | |
(end-of-line) | |
(prog1 | |
(buffer-substring start (point)) | |
(forward-char)))) |
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 make-nesting-print-fn (up-pre down-pre &optional (*standard-output* *standard-output*)) | |
(let ((counter 0)) | |
(list | |
;;count-up | |
(lambda (obj) | |
(incf counter) | |
(dotimes (i counter) | |
(format t "~A" up-pre)) |
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 dotted-list-p (lst) | |
(when (consp lst) | |
(loop :for rest = (cdr lst) then (cdr rest) | |
:while (consp rest) | |
:finally (return (not (null rest)))))) | |
(defun walk-inner (sexp pre mid post) | |
(cond | |
((atom sexp) | |
(funcall mid sexp)) |
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
;;; loop | |
(defun split-str-1 (str sep) | |
(labels ((sep? (ch) | |
(typecase sep | |
(function | |
(funcall sep ch)) | |
(list (find ch sep)) | |
(sequence (find ch sep)) | |
(atom (eq sep ch)) | |
(T nil)))) |
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 kill-to-regexp-forward (regexp) | |
(interactive "sRegexp:") | |
(let ((start-point (point))) | |
(when (re-search-forward regexp nil t) | |
(re-search-backward regexp nil t) | |
(kill-region start-point (point))))) | |
(defun kill-to-regexp-backward (regexp) | |
(interactive "sRegexp:") |
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
;;; examples | |
(def-binary-raw u1 | |
;; reader | |
([type in] | |
(bit-and 255 (.read in))) | |
;; writer | |
([type value out] | |
(.write out))) | |
(def-binary-raw u2 |
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
(defmacro with-assoc-values (binds alist &body body) | |
(let ((al (gensym "alist"))) | |
(flet ((expand-bind (bind) | |
`(,(first bind) | |
(cdr (assoc ,(second bind) ,al))))) | |
`(let ((,al ,alist)) | |
(let ,(mapcar #'expand-bind binds) | |
,@body))))) | |
;; (with-assoc-values ((a :hoge) (b :fuga)) `((:hoge . (3 4)) (:fuga . 4)) |
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
(defmacro switch (val &body clauses) | |
(let ((syms (loop :repeat (length clauses) | |
:collect (gensym)))) | |
`(tagbody | |
(case ,val | |
,@(mapcar | |
#'(lambda (clause sym) | |
`(,(car clause) (go ,sym))) | |
clauses | |
syms)) |
OlderNewer