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 string-index-of (whole part &key ignore-case) | |
"Return position where PART starts in WHOLE." | |
(let ((i 0) | |
(part-len (length part)) | |
(start-with (if ignore-case #'string-equal #'string=))) | |
(loop | |
(cond ((funcall start-with whole part :end1 part-len) | |
(return-from string-index-of i)) | |
((<= (length whole) part-len) |
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
(defmacro flet* (defs &body body) | |
(if defs | |
`(flet (,(car defs)) | |
(flet* (,@(cdr defs)) ,@body)) | |
`(progn ,@body))) | |
=> flet* | |
(flet* ((foo (x) (1+ x)) | |
(foo (x) (foo (* x x)))) | |
(foo 3)) |
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* NAME (ARGS...) (declare (type TYPE VAR*)) ...) | |
;; VAR の型チェックしてダメだったらブブブーブブブブーーブブー | |
;; ※音が鳴るだけでエラーで止めたりはしてくれない | |
(require "vuvuzela") ; vuvuzela が別ライブラリ sound に依存してるのでそれも必要 | |
(defun parse-body (body) | |
(let (doc intr decls) | |
(labels ((parse-1 (body) | |
(let ((form (car body))) |
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
;;; *scratch* で http://www.cs.northwestern.edu/academics/courses/325/readings/lisp-unit.html | |
;;; にある example をやってみたの図 | |
(load "~/work/xyzzy.lisp-unit/site-lisp/lisp-unit.l") | |
t | |
(use-package :lisp-unit) | |
t | |
(setf (get 'define-test 'ed:lisp-indent-hook) 1) | |
1 |
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
;; - http://d.hatena.ne.jp/rubikitch/20110226/savekill | |
(defvar *kill-ring-file* "~/var/xyzzy-kill-ring.dat" | |
"*kill-ring* の内容を保存するファイル名") | |
;; *kill-ring* をファイルに保存/ファイルから読み込み | |
(defun dump-kill-ring () | |
(with-open-file (out *kill-ring-file* :direction :output | |
:if-exists :overwrite | |
:if-does-not-exist :create) |
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
;;; repeat kbd-macro with just #\e (without #\C-x) | |
(let ((repeating nil)) | |
(labels ((check-repeating-kbd-macro () | |
(unless (member *this-command* | |
'(execute-last-kbd-macro | |
repeat-kbd-macro-or-self-insert | |
universal-argument | |
digit-argument | |
negative-argument)) | |
(setf repeating nil) |
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 command-loop (keymap) | |
(let (*this-command* | |
*last-command* | |
*last-command-char* | |
(keymap* keymap) | |
prefixes) | |
(loop | |
(refresh-screen) | |
(setf *last-command-char* (read-char *keyboard*) | |
*this-command* (lookup-keymap keymap* *last-command-char*)) |
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
;; load するファイル | |
(format t "loading: fred.lisp~%") | |
(defun fred () :fred) |
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
;; xyzzy では structure の accessor で全く関係ない structure の slot に触れてしまう事に気づいた。 | |
(defstruct foo | |
bar baz) | |
=> #<structure-definition: foo> | |
(defstruct hoge | |
fuga piyo) | |
=> #<structure-definition: hoge> | |
(hoge-fuga (make-foo :bar 3 :baz 4)) |
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
;;; generator っぽいものだとスッキリしそうなケースを思いついたので書いて | |
;;; みたけど、あまりスッキリしなかった | |
(define-condition stop-iteration (condition) | |
() | |
(:report (lambda (c s) (format s "Stop Iteration")))) | |
=> t | |
(defun plist-iterator (plist) | |
"generato iterator from plist." |