emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/inf-clojure b897bb8 031/313: Show arglist in the minibuffe


From: ELPA Syncer
Subject: [nongnu] elpa/inf-clojure b897bb8 031/313: Show arglist in the minibuffer for better usability
Date: Wed, 11 Aug 2021 09:59:40 -0400 (EDT)

branch: elpa/inf-clojure
commit b897bb87a885de384d2b720e737a42d4a9e1f751
Author: Bozhidar Batsov <bozhidar@tradeo.com>
Commit: Bozhidar Batsov <bozhidar@tradeo.com>

    Show arglist in the minibuffer for better usability
---
 inf-clojure.el | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/inf-clojure.el b/inf-clojure.el
index 0c88d71..87edee1 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -426,7 +426,12 @@ Used by this command to determine defaults."
   "Command to query inferior Clojure for a var's source.")
 
 (defvar inf-clojure-arglist-command
-  "(:arglists (clojure.core/meta #'%s))\n"
+  "(try
+     (:arglists
+      (clojure.core/meta
+       (clojure.core/resolve
+        (clojure.core/read-string \"%s\"))))
+     (catch Throwable t nil))"
   "Command to query inferior Clojure for a function's arglist.")
 
 (defvar inf-clojure-completion-command
@@ -509,7 +514,25 @@ See variable `inf-clojure-var-source-command'."
   "Send a query to the inferior Clojure for the arglist for function FN.
 See variable `inf-clojure-arglist-command'."
   (interactive (inf-clojure-symprompt "Arglist" (inf-clojure-fn-called-at-pt)))
-  (comint-proc-query (inf-clojure-proc) (format inf-clojure-arglist-command 
fn)))
+  (let* ((proc (inf-clojure-proc))
+         (line (buffer-substring (save-excursion (move-beginning-of-line 1)
+                                                 (point))
+                                 (point)))
+         (comint-filt (process-filter proc))
+         (kept "")
+         eldoc)
+    (set-process-filter proc (lambda (proc string) (setq kept (concat kept 
string))))
+    (unwind-protect
+        (let ((eldoc-snippet (format inf-clojure-arglist-command fn)))
+          (process-send-string proc eldoc-snippet)
+          (while (and (not (string-match inf-clojure-prompt kept))
+                      (accept-process-output proc 2)))
+          ; some nasty #_=> garbage appears in the output
+          (setq eldoc (and (string-match "(.+)" kept) (match-string 0 kept)))
+          )
+      (set-process-filter proc comint-filt))
+    (when eldoc
+      (message "%s: %s" fn eldoc))))
 
 (defun inf-clojure-show-ns-vars (ns)
   "Send a query to the inferior Clojure for the public vars in NS.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]