Skip to content

Instantly share code, notes, and snippets.

;;; C-u <key> で現在のウィンドウを登録しておいて、<key> でそのウィンドウに
;;; 移動する。
;;; ※プレフィックスキーは無視されちゃう([C-x 1] と [C-c 1] はどっちも [1]
;;; 扱いになる)。
(let ((table (make-hash-table)))
(defun switch-to-registered-window (&optional arg)
(interactive "P")
(if arg
(progn
@bowbow99
bowbow99 / gist:610925
Created October 5, 2010 03:13
#xyzzy で structure を #S(...) で出力。スロット毎に改行+インデント。
#+xyzzy
(defun print-structure-sharp-s-aligned (obj stream n)
(assert (si:*structurep obj))
(let ((def (si:*structure-definition obj)))
(format stream "#S(~S" (si:*structure-definition-name def))
(let ((indent (1+ (si:*stream-column stream))))
(dotimes (i (si:*structure-definition-nslots def))
(unless (= i 0)
(terpri stream))
(format stream " ~VT~S ~S"
;;; ref. http://practical-scheme.net/gauche/man/gauche-refj_16.html#SEC18
(defmacro debug-print (form stream)
`(progn
(format t "~&#?=~S:~S:~S~%"
,(or *load-pathname*
(when (buffer-stream-p stream)
(buffer-name (buffer-stream-buffer stream)))
stream)
,(si:*stream-line-number stream)
@bowbow99
bowbow99 / gist:716148
Created November 26, 2010 01:13
継続とマクロでお手軽ブレークポイント - athosの日記 http://d.hatena.ne.jp/athos/20091226/p1 を #xyzzy + condition-restart で
(require "condition-restart")
(define-condition breakpoint (condition)
(name places)
(:report (lambda (bp stream)
(format stream "ぶれーく! ~S" (breakpoint-name bp)))))
(defmacro bp (name &rest places)
`(tagbody breakpoint
@bowbow99
bowbow99 / gist:717490
Created November 27, 2010 02:21
let* とスペシャル変数のあれ http://d.hatena.ne.jp/bowbow99/20101127/1290818576 #xyzzy
diff --git a/src/eval.cc b/src/eval.cc
old mode 100644
new mode 100755
index 6dec67b..9fdacb8
--- a/src/eval.cc
+++ b/src/eval.cc
@@ -289,7 +289,7 @@ special_bind::~special_bind ()
}
}
;;; generator っぽいものだとスッキリしそうなケースを思いついたので書いて
;;; みたけど、あまりスッキリしなかった
(define-condition stop-iteration (condition)
()
(:report (lambda (c s) (format s "Stop Iteration"))))
=> t
(defun plist-iterator (plist)
"generato iterator from plist."
@bowbow99
bowbow99 / gist:740588
Created December 14, 2010 15:39
xyzzy では structure の accessor で全く関係ない structure の slot に触れてしまうことに気づいた。
;; 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))
@bowbow99
bowbow99 / fred.lisp
Created December 21, 2010 13:30
undefined-function が投げられたらファイルを load してやり直す
;; load するファイル
(format t "loading: fred.lisp~%")
(defun fred () :fred)
@bowbow99
bowbow99 / gist:756971
Created December 28, 2010 06:47
#xyzzy のコマンドループっぽいもの(作りかけ
(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*))
@bowbow99
bowbow99 / gist:802650
Created January 30, 2011 07:28
`e' だけ(`C-x' なし)で kbd-macro を繰り返す #xyzzy
;;; 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)