逆引きxyzzy lisp(GUI) - circleratio/xyzzy GitHub Wiki
(defvar *prompt* "> ")
(defun eval-line ()
(interactive)
(if (save-excursion
(goto-bol)
(looking-at (concat "^ *" *prompt*)))
(let ((cmd (buffer-substring (match-end 0)
(progn
(goto-eol)
(point)))))
(insert (concat "\n"
(eval-cmd cmd)))))
(insert (concat "\n" *prompt*)))
(defun eval-cmd (cmd) ; 実際に使うときは書き換えること!
cmd)
(defun minibuf-prompt (prompt display-as-password)
(let ((ans ""))
(loop
(minibuffer-prompt (concat prompt
(if display-as-password
(substitute-string ans "." ".")
ans)))
(let ((c (read-char *keyboard*)))
(case c
((#\RET #\C-j) (return ans))
((#\C-h #\C-?) (if (> (length ans) 0)
(setq ans (subseq ans 0 (1- (length ans))))))
(#\C-g (quit))
(t (setq ans (format nil "~A~C" ans c))))))))
(minibuf-prompt "test:" t)
(setq foo-history '("abc" "def" "ghi"))
=> ("abc" "def" "ghi")
(defun foo ()
(interactive)
(list
(let ((*minibuffer-default-history* foo-history))
(prog1
(completing-read
"foo: "
'("foo" "bar" "baz")
:must-match nil
:case-fold t)
(setq foo-history *minibuffer-default-history*)))))
(setq *test-history* '("history1" "history2" "history3"))
=> ("history1" "history2" "history3")
(setf (get 'test-minibuf 'ed::minibuffer-history-variable) '*test-history*)
=> *test-history*
(defun test-minibuf ()
(interactive)
(completing-read "cmd: "
'("cmd1" "cmd2" cmd3 cmd4)
:case-fold t
:default "default"
:history 'test-minibuf
:must-match nil))
変数の定義に setq でなく define-history-variable を使うと、xyzzy の終了時にファイルに履歴を保存してくれるようになる。
(case (message-box "Are you ready?" nil
'(:yes-no-cancel :question :button1))
(:yes "yes")
(:no "no")
(:cancel "cancel")
(t "Not to be reached"))
=> "yes"
(yes-or-no-p "yes or no?")
=> t
(msgbox "buf: ~A" (selected-buffer))
=> :ok
(defun func ()
(popup-list
'("123" "abc" "xyz")
#'(lambda (x) (msgbox "\"~A\" selected" x))))
ツールチップ風の表示。
(popup-string "test!" (point) 1)
最後の引数(表示時間)は省略可。