update packages
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
|
||||
;; Author: Artem Malyshev <proofit404@gmail.com>
|
||||
;; URL: https://github.com/proofit404/anaconda-mode
|
||||
;; Package-Version: 20200129.1718
|
||||
;; Package-Commit: 10299bd9ff38c4f0da1d892905d02ef828e7fdce
|
||||
;; Package-Version: 20200912.239
|
||||
;; Package-Commit: 39b1cf88c8c459901630d248d6135d8644075648
|
||||
;; Version: 0.1.13
|
||||
;; Package-Requires: ((emacs "25.1") (pythonic "0.1.0") (dash "2.6.0") (s "1.9") (f "0.16.2"))
|
||||
|
||||
@@ -73,7 +73,10 @@
|
||||
|
||||
(defcustom anaconda-mode-tunnel-setup-sleep 2
|
||||
"Time in seconds `anaconda-mode' waits after tunnel creation before first RPC call."
|
||||
:group 'anaconda-mode
|
||||
:type 'integer)
|
||||
|
||||
(defcustom anaconda-mode-sync-request-timeout 2
|
||||
"Time in seconds `anaconda-mode' waits for a synchronous response."
|
||||
:type 'integer)
|
||||
|
||||
;;; Compatibility
|
||||
@@ -379,12 +382,27 @@ be bound."
|
||||
(equal (process-get anaconda-mode-process 'remote-port)
|
||||
(pythonic-remote-port)))))))
|
||||
|
||||
(defun anaconda-mode-get-server-process-cwd ()
|
||||
"Get the working directory for starting the anaconda server process.
|
||||
|
||||
The current working directory ends up being on sys.path, which may
|
||||
result in conflicts with stdlib modules.
|
||||
|
||||
When running python from the local machine, we start the server
|
||||
process from `anaconda-mode-installation-directory'.
|
||||
This function creates that directory if it doesn't exist yet."
|
||||
(when (pythonic-local-p)
|
||||
(unless (file-directory-p anaconda-mode-installation-directory)
|
||||
(make-directory anaconda-mode-installation-directory t))
|
||||
anaconda-mode-installation-directory))
|
||||
|
||||
(defun anaconda-mode-bootstrap (&optional callback)
|
||||
"Run `anaconda-mode' server.
|
||||
CALLBACK function will be called when `anaconda-mode-port' will
|
||||
be bound."
|
||||
(setq anaconda-mode-process
|
||||
(pythonic-start-process :process anaconda-mode-process-name
|
||||
:cwd (anaconda-mode-get-server-process-cwd)
|
||||
:buffer (get-buffer-create anaconda-mode-process-buffer)
|
||||
:query-on-exit nil
|
||||
:filter (lambda (process output)
|
||||
@@ -473,7 +491,10 @@ called when `anaconda-mode-port' will be bound."
|
||||
anaconda-mode-ssh-process-buffer
|
||||
"ssh" "-nNT"
|
||||
"-L" (format "%s:localhost:%s" (anaconda-mode-port) (anaconda-mode-port))
|
||||
(format "%s@%s" (pythonic-remote-user) (pythonic-remote-host))
|
||||
(if (pythonic-remote-user)
|
||||
(format "%s@%s" (pythonic-remote-user) (pythonic-remote-host))
|
||||
;; Asssume remote host is an ssh alias
|
||||
(pythonic-remote-host))
|
||||
"-p" (number-to-string (or (pythonic-remote-port) 22)))))
|
||||
;; prevent race condition between tunnel setup and first use
|
||||
(sleep-for anaconda-mode-tunnel-setup-sleep)
|
||||
@@ -486,10 +507,25 @@ called when `anaconda-mode-port' will be bound."
|
||||
|
||||
(defun anaconda-mode-call (command callback)
|
||||
"Make remote procedure call for COMMAND.
|
||||
Apply CALLBACK to it result."
|
||||
Apply CALLBACK to the result asynchronously."
|
||||
(anaconda-mode-start
|
||||
(lambda () (anaconda-mode-jsonrpc command callback))))
|
||||
|
||||
(defun anaconda-mode-call-sync (command callback)
|
||||
"Make remote procedure call for COMMAND.
|
||||
Apply CALLBACK to the result synchronously."
|
||||
(let ((start-time (current-time))
|
||||
(result 'pending))
|
||||
(anaconda-mode-call
|
||||
command
|
||||
(lambda (r) (setq result r)))
|
||||
(while (eq result 'pending)
|
||||
(accept-process-output nil 0.01)
|
||||
(when (> (cadr (time-subtract (current-time) start-time))
|
||||
anaconda-mode-sync-request-timeout)
|
||||
(error "%s request timed out" command)))
|
||||
(funcall callback result)))
|
||||
|
||||
(defun anaconda-mode-jsonrpc (command callback)
|
||||
"Perform JSONRPC call for COMMAND.
|
||||
Apply CALLBACK to the call result when retrieve it. Remote
|
||||
@@ -740,6 +776,42 @@ number position, column number position and file path."
|
||||
|
||||
;;; Xref.
|
||||
|
||||
(defun anaconda-mode-xref-backend ()
|
||||
"Integrate `anaconda-mode' with xref."
|
||||
'anaconda)
|
||||
|
||||
(cl-defmethod xref-backend-definitions ((_backend (eql anaconda)) _identifier)
|
||||
"Find definitions for thing at point."
|
||||
(anaconda-mode-call-sync
|
||||
"goto_definitions"
|
||||
(lambda (result)
|
||||
(if result
|
||||
(if (stringp result)
|
||||
(progn
|
||||
(message result)
|
||||
nil)
|
||||
(anaconda-mode-make-xrefs result))))))
|
||||
|
||||
(cl-defmethod xref-backend-references ((_backend (eql anaconda)) _identifier)
|
||||
"Find references for thing at point."
|
||||
(anaconda-mode-call-sync
|
||||
"usages"
|
||||
(lambda (result)
|
||||
(if result
|
||||
(if (stringp result)
|
||||
(progn
|
||||
(message result)
|
||||
nil)
|
||||
(anaconda-mode-make-xrefs result))))))
|
||||
|
||||
(cl-defmethod xref-backend-apropos ((_backend (eql anaconda)) _pattern)
|
||||
"Not implemented."
|
||||
nil)
|
||||
|
||||
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql anaconda)))
|
||||
"Not implemented."
|
||||
nil)
|
||||
|
||||
(defun anaconda-mode-show-xrefs (result display-action error-message)
|
||||
"Show xref from RESULT using DISPLAY-ACTION.
|
||||
Show ERROR-MESSAGE if result is empty."
|
||||
@@ -826,7 +898,10 @@ Show ERROR-MESSAGE if result is empty."
|
||||
\\{anaconda-mode-map}"
|
||||
:lighter anaconda-mode-lighter
|
||||
:keymap anaconda-mode-map
|
||||
(setq-local url-http-attempt-keepalives nil))
|
||||
(setq-local url-http-attempt-keepalives nil)
|
||||
(if anaconda-mode
|
||||
(add-hook 'xref-backend-functions #'anaconda-mode-xref-backend nil t)
|
||||
(remove-hook 'xref-backend-functions #'anaconda-mode-xref-backend t)))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode anaconda-eldoc-mode
|
||||
|
||||
Reference in New Issue
Block a user