From e7f62280011bd1a6f902c9bbda7d0492308b4950 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Thu, 4 Sep 2014 15:43:31 -0700 Subject: [PATCH] feat(emacs): use lean-server-send-cmd-async --- src/emacs/lean-info.el | 7 +++++-- src/emacs/lean-option.el | 14 +++++++------- src/emacs/lean-type.el | 10 +++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/emacs/lean-info.el b/src/emacs/lean-info.el index f2c740faf..f65a807ac 100644 --- a/src/emacs/lean-info.el +++ b/src/emacs/lean-info.el @@ -553,8 +553,11 @@ Take out \"BEGININFO\" and \"ENDINFO\" and Use \"ACK\" as a delim." (let ((file-name (buffer-file-name)) (line-number (line-number-at-pos))) (lean-server-check-current-file file-name) - (lean-server-send-cmd (lean-cmd-info line-number) - cont))) + (lean-server-send-cmd-async (lean-cmd-info line-number) + (lambda (info-record) + (if (lean-info-record-nay info-record) + (lean-get-info-record-at-point cont) + (funcall cont info-record)))))) (defun lean-get-full-name-at-point-cont (info-record) "Continuation of lean-get-full-name-at-point" diff --git a/src/emacs/lean-option.el b/src/emacs/lean-option.el index a6e585b6d..fdad3c82d 100644 --- a/src/emacs/lean-option.el +++ b/src/emacs/lean-option.el @@ -28,7 +28,7 @@ nil t "" nil (car key-list))) (option (cdr (assoc option-name option-record-alist))) (option-value (lean-option-read option))) - (lean-server-send-cmd (lean-cmd-set option-name option-value) 'message))) + (lean-server-send-cmd-async (lean-cmd-set option-name option-value) 'message))) (defun lean-set-option () "Set Lean option." @@ -49,7 +49,7 @@ (stringp tmp-str) (string= tmp-str str)) val - (error "%s is not an int value" str)))) + (error "%s is not an int value" str)))) (defun lean-option-read-uint (prompt) (interactive) @@ -134,7 +134,7 @@ (defun lean-options-parse-string (str) "Parse lines of option string into an entry of alist of lean-option-records -(NAME . OPTION-RECORD)." +'(NAME . OPTION-RECORD)'." (let ((str-list (split-string str "\n")) str-str-list option-list) @@ -151,8 +151,8 @@ (defun lean-get-options (cont) "Get Lean option." (interactive) - (lean-server-send-cmd (lean-cmd-options) - (lambda (option-record-alist) - (when cont - (funcall cont option-record-alist))))) + (lean-server-send-cmd-async (lean-cmd-options) + (lambda (option-record-alist) + (when cont + (funcall cont option-record-alist))))) (provide 'lean-option) diff --git a/src/emacs/lean-type.el b/src/emacs/lean-type.el index 424f4063e..f93f09d89 100644 --- a/src/emacs/lean-type.el +++ b/src/emacs/lean-type.el @@ -60,15 +60,15 @@ (defun lean-eval-cmd (lean-cmd) "Evaluate lean command." (interactive "sLean CMD: ") - (lean-server-send-cmd (lean-cmd-eval lean-cmd) - 'message)) + (lean-server-send-cmd-async (lean-cmd-eval lean-cmd) + 'message)) ;; Clear Cache (defun lean-clear-cache () "Send CLEAR_CACHE command to lean-server" (interactive) (call-process (lean-get-executable "linja") nil 0 nil "clear-cache") - (lean-server-send-cmd (lean-cmd-clear-cache))) + (lean-server-send-cmd-async (lean-cmd-clear-cache))) ;; ======================================================= ;; Change Handling @@ -138,14 +138,14 @@ pairs, compute changed-lines, inserted-lines, and removed-lines." (defun lean-after-change-handle-inserted (inserted-lines changed-lines) (lean-flush-changed-lines) (cl-loop for n in inserted-lines - do (lean-server-send-cmd (lean-cmd-insert n (lean-grab-line n)))) + do (lean-server-send-cmd-async (lean-cmd-insert n (lean-grab-line n)))) (setq lean-changed-lines changed-lines) (lean-flush-changed-lines)) (defun lean-after-change-handle-removed (removed-lines changed-lines) (lean-flush-changed-lines) (cl-loop for n in removed-lines - do (lean-server-send-cmd (lean-cmd-remove n))) + do (lean-server-send-cmd-async (lean-cmd-remove n))) (setq lean-changed-lines changed-lines) (lean-flush-changed-lines))