feat(emacs/lean-cmd): add WAIT command

This commit is contained in:
Soonho Kong 2014-09-08 16:01:58 -07:00
parent c88bfc0c02
commit 4f604544c4
2 changed files with 17 additions and 4 deletions

View file

@ -100,6 +100,9 @@ It has the effect of evaluating a command in the end of the current file"
"FINDG generates a sequence of declarations that may be used to “fill” a particular placeholder"
`(FINDG ,line-number ,column-number ,patterns))
(defun lean-cmd-wait ()
"Block server until all pending information has been computed."
`(WAIT))
;; Type
;; ====
@ -265,16 +268,19 @@ It has the effect of evaluating a command in the end of the current file"
"Convert valid command to string"
(format "VALID"))
(defun lean-cmd-findp-to-string (cmd)
"Convert valid command to string"
"Convert findp command to string"
(format "FINDP %d\n%s"
(lean-cmd-findp-get-line-number cmd)
(lean-cmd-findp-get-prefix cmd)))
(defun lean-cmd-findg-to-string (cmd)
"Convert valid command to string"
"Convert findg command to string"
(format "FINDG %d %d\n%s"
(lean-cmd-findg-get-line-number cmd)
(lean-cmd-findg-get-column-number cmd)
(lean-cmd-findg-get-patterns cmd)))
(defun lean-cmd-wait-to-string (cmd)
"Convert wait command to string"
(format "WAIT"))
(defun lean-cmd-to-string (cmd)
"Convert command to string"
@ -293,7 +299,8 @@ It has the effect of evaluating a command in the end of the current file"
('SHOW (lean-cmd-show-to-string cmd))
('VALID (lean-cmd-valid-to-string cmd))
('FINDP (lean-cmd-findp-to-string cmd))
('FINDG (lean-cmd-findg-to-string cmd))))
('FINDG (lean-cmd-findg-to-string cmd))
('WAIT (lean-cmd-wait-to-string cmd))))
;; -- Test
(cl-assert (string= (lean-cmd-to-string (lean-cmd-load "~/work/lean/basic.lean"))
@ -316,6 +323,8 @@ It has the effect of evaluating a command in the end of the current file"
(concat "FINDP 42" "\n" "iff_")))
(cl-assert (string= (lean-cmd-to-string (lean-cmd-findg 48 10 "+intro -and -elim"))
(concat "FINDG 48 10" "\n" "+intro -and -elim")))
(cl-assert (string= (lean-cmd-to-string (lean-cmd-wait))
(concat "WAIT")))
;; ----------------
(provide 'lean-cmd)

View file

@ -102,6 +102,8 @@
,(rx line-start (group "-- ENDFINDP") line-end))
(FINDG ,(rx line-start "-- BEGINFINDG" (* not-newline) line-end)
,(rx line-start (group "-- ENDFINDG") line-end))
(WAIT ,(rx line-start "-- BEGINWAIT" line-end)
,(rx line-start (group "-- ENDWAIT") line-end))
(ERROR ,(rx line-start "-- " (0+ not-newline) line-end)
,(rx line-start (group "-- ERROR" (0+ not-newline)) line-end)))
"Regular expression pattern for lean-server message syntax")
@ -258,6 +260,7 @@ If it's not the same with file-name (default: buffer-file-name), send VISIT cmd.
('VALID (lean-server-check-current-file))
('FINDP (lean-server-check-current-file))
('FINDG (lean-server-check-current-file))))
('WAIT (lean-server-check-current-file))))
(defun lean-server-after-send-cmd (cmd)
"Operations to perform after sending a command."
@ -276,6 +279,7 @@ If it's not the same with file-name (default: buffer-file-name), send VISIT cmd.
('VALID ())
('FINDP ())
('FINDG ())))
('WAIT ())))
(defun lean-server-send-cmd (cmd)
"Send cmd to lean-server"