Skip to content

Instantly share code, notes, and snippets.

@bowbow99
Created December 28, 2010 06:47
Show Gist options
  • Select an option

  • Save bowbow99/756971 to your computer and use it in GitHub Desktop.

Select an option

Save bowbow99/756971 to your computer and use it in GitHub Desktop.
#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*))
(cond ((commandp *this-command*)
(format t "~&Command: ~S~%" *this-command*)
(unwind-protect
(call-interactively *this-command*)
(setf *last-command* *this-command*
prefixes nil
keymap* keymap)
(clear-message)))
((keymapp *this-command*)
(format t "~&Prefix: ~S~&" *this-command*)
(message "~{~S~^ ~}" (push *last-command-char* prefixes)) ;逆じゃね?
(setf keymap* *this-command*))
(t
(format t "~&unboud key: ~C~%" *last-command-char*)
;(error "What? ~S" *this-command*)
)))))
@bowbow99
Copy link
Author

universal-argument あたりが上手く動かない。

universal-argument から呼ばれてる process-prefix-args で(C-u 1 2 3 とかを処理するのに (read-char *keyboard*) した後)set-next-prefix-args してるのだけど、これは call-interactively には効かないっぽい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment