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

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

[nongnu] elpa/inf-clojure b02ce23 118/313: Add arglists support in Lumo


From: ELPA Syncer
Subject: [nongnu] elpa/inf-clojure b02ce23 118/313: Add arglists support in Lumo
Date: Wed, 11 Aug 2021 09:59:58 -0400 (EDT)

branch: elpa/inf-clojure
commit b02ce23dd183743623f40c2ecc6f38ddb6ad303b
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Add arglists support in Lumo
    
    This patch adds `inf-clojure-arglists-form-lumo` and modifies the body
    of `inf-clojure-arglist` in order to comply with the different output
    lumo spits out.
---
 inf-clojure.el | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/inf-clojure.el b/inf-clojure.el
index 393df71..650df8d 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -596,7 +596,7 @@ If you are using REPL types, it will pickup the most 
approapriate
 
 (define-obsolete-variable-alias 'inf-clojure-var-source-command 
'inf-clojure-var-source-form "2.0.0")
 
-(defcustom inf-clojure-arglist-form
+(defcustom inf-clojure-arglists-form
   "(try
      (:arglists
       (clojure.core/meta
@@ -607,7 +607,21 @@ If you are using REPL types, it will pickup the most 
approapriate
   :type 'string
   :package-version '(inf-clojure . "2.0.0"))
 
-(define-obsolete-variable-alias 'inf-clojure-arglist-command 
'inf-clojure-arglist-form "2.0.0")
+(define-obsolete-variable-alias 'inf-clojure-arglist-command 
'inf-clojure-arglists-form "2.0.0")
+
+(defcustom inf-clojure-arglists-form-lumo
+  "(lumo.repl/get-arglists \"%s\")"
+  "Lumo form to query inferior Clojure for a function's arglist."
+  :type 'string
+  :package-version '(inf-clojure . "2.0.0"))
+
+(defun inf-clojure-arglists-form ()
+  "Return the form to query inferior Clojure for arglists of a var.
+If you are using REPL types, it will pickup the most approapriate
+`inf-clojure-arglist-form` variant."
+  (pcase (inf-clojure--set-repl-type (inf-clojure-proc))
+    (`lumo inf-clojure-arglists-form-lumo)
+    (_ inf-clojure-arglists-form)))
 
 (defcustom inf-clojure-completion-form
   "(complete.core/completions \"%s\")\n"
@@ -725,6 +739,16 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol 
name."
                (inf-clojure-symbol-at-point))))
     (comint-proc-query (inf-clojure-proc) (format inf-clojure-var-source-form 
var))))
 
+(defun inf-clojure-match-arglists (input-form string)
+  "Return the arglists match from INPUT-FORM and STRING.
+The output depends on the correct REPL type.  We assume the
+`inf-clojure-repl-type` var is already set, therefore this is
+safe to call only from inside `inf-clojure-arglist`."
+  (pcase inf-clojure-repl-type
+    (`lumo (let ((input-end (and (string-match input-form string) (match-end 
0))))
+             (and (string-match "(.+)" string input-end) (match-string 0 
string))))
+    (_ (and (string-match "(.+)" string) (match-string 0 string)))))
+
 (defun inf-clojure-arglist (fn)
   "Send a query to the inferior Clojure for the arglist for function FN.
 See variable `inf-clojure-arglist-form'."
@@ -734,11 +758,11 @@ See variable `inf-clojure-arglist-form'."
          eldoc)
     (set-process-filter proc (lambda (_proc string) (setq kept (concat kept 
string))))
     (unwind-protect
-        (let ((eldoc-snippet (format inf-clojure-arglist-form fn)))
-          (process-send-string proc eldoc-snippet)
+        (let ((eldoc-snippet (format (inf-clojure-arglists-form) fn)))
+          (inf-clojure--send-string proc eldoc-snippet)
           (while (and (not (string-match inf-clojure-prompt kept))
                       (accept-process-output proc 2)))
-          (setq eldoc (and (string-match "(.+)" kept) (match-string 0 kept))))
+          (setq eldoc (inf-clojure-match-arglists eldoc-snippet kept)))
       (set-process-filter proc comint-filt))
     eldoc))
 



reply via email to

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