Skip to content

Commit 887da91

Browse files
arichiardibbatsov
authored andcommitted
Use inf-clojure--sanitize-command everywhere
1 parent e10ac48 commit 887da91

File tree

1 file changed

+59
-60
lines changed

1 file changed

+59
-60
lines changed

inf-clojure.el

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -607,21 +607,21 @@ The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the
607607
;;; =============
608608

609609
(defcustom inf-clojure-var-doc-form
610-
"(clojure.repl/doc %s)\n"
610+
"(clojure.repl/doc %s)"
611611
"Form to query inferior Clojure for a var's documentation."
612612
:type 'string
613613
:package-version '(inf-clojure . "2.0.0"))
614614

615615
(define-obsolete-variable-alias 'inf-clojure-var-doc-command 'inf-clojure-var-doc-form "2.0.0")
616616

617617
(defcustom inf-clojure-var-doc-form-lumo
618-
"(lumo.repl/doc %s)\n"
618+
"(lumo.repl/doc %s)"
619619
"Lumo form to query inferior Clojure for a var's documentation."
620620
:type 'string
621621
:package-version '(inf-clojure . "2.0.0"))
622622

623623
(defcustom inf-clojure-var-doc-form-planck
624-
"(planck.repl/doc %s)\n"
624+
"(planck.repl/doc %s)"
625625
"Planck form to query inferior Clojure for a var's documentation."
626626
:type 'string
627627
:package-version '(inf-clojure . "2.0.0"))
@@ -630,19 +630,20 @@ The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the
630630
"Return the form to query inferior Clojure for a var's documentation.
631631
If you are using REPL types, it will pickup the most approapriate
632632
`inf-clojure-var-doc-form` variant."
633-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
634-
(`lumo inf-clojure-var-doc-form-lumo)
635-
(`planck inf-clojure-var-doc-form-planck)
636-
(_ inf-clojure-var-doc-form)))
633+
(inf-clojure--sanitize-command
634+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
635+
(`lumo inf-clojure-var-doc-form-lumo)
636+
(`planck inf-clojure-var-doc-form-planck)
637+
(_ inf-clojure-var-doc-form))))
637638

638639
(defcustom inf-clojure-var-source-form
639-
"(clojure.repl/source %s)\n"
640+
"(clojure.repl/source %s)"
640641
"Form to query inferior Clojure for a var's source."
641642
:type 'string
642643
:package-version '(inf-clojure . "2.0.0"))
643644

644645
(defcustom inf-clojure-var-source-form-planck
645-
"(planck.repl/source %s)\n"
646+
"(planck.repl/source %s)"
646647
"Planck form to query inferior Clojure for a var's source."
647648
:type 'string
648649
:package-version '(inf-clojure . "2.0.0"))
@@ -651,9 +652,10 @@ If you are using REPL types, it will pickup the most approapriate
651652
"Return the form to query inferior Clojure for a var's source.
652653
If you are using REPL types, it will pickup the most approapriate
653654
`inf-clojure-var-source-form` variant."
654-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
655-
(`planck inf-clojure-var-source-form-planck)
656-
(_ inf-clojure-var-source-form)))
655+
(inf-clojure--sanitize-command
656+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
657+
(`planck inf-clojure-var-source-form-planck)
658+
(_ inf-clojure-var-source-form))))
657659

658660
(define-obsolete-variable-alias 'inf-clojure-var-source-command 'inf-clojure-var-source-form "2.0.0")
659661

@@ -663,7 +665,7 @@ If you are using REPL types, it will pickup the most approapriate
663665
(clojure.core/meta
664666
(clojure.core/resolve
665667
(clojure.core/read-string \"%s\"))))
666-
(catch Throwable t nil))\n"
668+
(catch Throwable t nil))"
667669
"Form to query inferior Clojure for a function's arglists."
668670
:type 'string
669671
:package-version '(inf-clojure . "2.0.0"))
@@ -680,26 +682,27 @@ If you are using REPL types, it will pickup the most approapriate
680682
"Return the form to query inferior Clojure for arglists of a var.
681683
If you are using REPL types, it will pickup the most approapriate
682684
`inf-clojure-arglists-form` variant."
683-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
684-
(`lumo inf-clojure-arglists-form-lumo)
685-
(_ inf-clojure-arglists-form)))
685+
(inf-clojure--sanitize-command
686+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
687+
(`lumo inf-clojure-arglists-form-lumo)
688+
(_ inf-clojure-arglists-form))))
686689

687690
(defcustom inf-clojure-completion-form
688-
"(complete.core/completions \"%s\")\n"
691+
"(complete.core/completions \"%s\")"
689692
"Form to query inferior Clojure for completion candidates."
690693
:type 'string
691694
:package-version '(inf-clojure . "2.0.0"))
692695

693696
(define-obsolete-variable-alias 'inf-clojure-completion-command 'inf-clojure-completion-form "2.0.0")
694697

695698
(defcustom inf-clojure-completion-form-lumo
696-
"(doall (map str (lumo.repl/get-completions \"%s\")))\n"
699+
"(doall (map str (lumo.repl/get-completions \"%s\")))"
697700
"Lumo form to query inferior Clojure for completion candidates."
698701
:type 'string
699702
:package-version '(inf-clojure . "2.0.0"))
700703

701704
(defcustom inf-clojure-completion-form-planck
702-
"(planck.repl/get-completions \"%s\")\n"
705+
"(planck.repl/get-completions \"%s\")"
703706
"Planck form to query inferior Clojure for completion candidates."
704707
:type 'string
705708
:package-version '(inf-clojure . "2.0.0"))
@@ -708,25 +711,26 @@ If you are using REPL types, it will pickup the most approapriate
708711
"Return the form to query inferior Clojure for a var's documentation.
709712
If you are using REPL types, it will pickup the most approapriate
710713
`inf-clojure-completion-form` variant."
711-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
712-
(`lumo inf-clojure-completion-form-lumo)
713-
(`planck inf-clojure-completion-form-planck)
714-
(_ inf-clojure-completion-form)))
714+
(inf-clojure--sanitize-command
715+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
716+
(`lumo inf-clojure-completion-form-lumo)
717+
(`planck inf-clojure-completion-form-planck)
718+
(_ inf-clojure-completion-form))))
715719

716720
(defcustom inf-clojure-ns-vars-form
717-
"(clojure.repl/dir %s)\n"
721+
"(clojure.repl/dir %s)"
718722
"Form to show the public vars in a namespace."
719723
:type 'string
720724
:package-version '(inf-clojure . "2.0.0"))
721725

722726
(defcustom inf-clojure-ns-vars-form-lumo
723-
"(lumo.repl/dir %s)\n"
727+
"(lumo.repl/dir %s)"
724728
"Lumo form to show the public vars in a namespace."
725729
:type 'string
726730
:package-version '(inf-clojure . "2.0.0"))
727731

728732
(defcustom inf-clojure-ns-vars-form-planck
729-
"(planck.repl/dir %s)\n"
733+
"(planck.repl/dir %s)"
730734
"Planck form to show the public vars in a namespace."
731735
:type 'string
732736
:package-version '(inf-clojure . "2.0.0"))
@@ -735,21 +739,22 @@ If you are using REPL types, it will pickup the most approapriate
735739
"Return the form to query inferior Clojure for public vars in a namespace.
736740
If you are using REPL types, it will pickup the most approapriate
737741
`inf-clojure-ns-vars-form` variant."
738-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
739-
(`lumo inf-clojure-ns-vars-form-lumo)
740-
(`planck inf-clojure-ns-vars-form-planck)
741-
(_ inf-clojure-ns-vars-form)))
742+
(inf-clojure--sanitize-command
743+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
744+
(`lumo inf-clojure-ns-vars-form-lumo)
745+
(`planck inf-clojure-ns-vars-form-planck)
746+
(_ inf-clojure-ns-vars-form))))
742747

743748
(define-obsolete-variable-alias 'inf-clojure-ns-vars-command 'inf-clojure-ns-vars-form "2.0.0")
744749

745750
(defcustom inf-clojure-set-ns-form
746-
"(clojure.core/in-ns '%s)\n"
751+
"(clojure.core/in-ns '%s)"
747752
"Form to set the namespace of the inferior Clojure process."
748753
:type 'string
749754
:package-version '(inf-clojure . "2.0.0"))
750755

751756
(defcustom inf-clojure-set-ns-form-planck
752-
"(in-ns '%s)\n"
757+
"(in-ns '%s)"
753758
"Planck form to set the namespace of the inferior Clojure process."
754759
:type 'string
755760
:package-version '(inf-clojure . "2.0.0"))
@@ -758,22 +763,23 @@ If you are using REPL types, it will pickup the most approapriate
758763
"Return the form to set the ns of the inferior Clojure process.
759764
If you are using REPL types, it will pickup the most approapriate
760765
`inf-clojure-set-ns-form` variant."
761-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
762-
(`planck inf-clojure-set-ns-form-planck)
763-
(_ inf-clojure-set-ns-form)))
766+
(inf-clojure--sanitize-command
767+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
768+
(`planck inf-clojure-set-ns-form-planck)
769+
(_ inf-clojure-set-ns-form))))
764770

765771
(define-obsolete-variable-alias 'inf-clojure-set-ns-command 'inf-clojure-set-ns-form "2.0.0")
766772

767773
(defcustom inf-clojure-apropos-form
768774
"(doseq [var (sort (clojure.repl/apropos \"%s\"))]
769-
(println (str var)))\n"
775+
(println (str var)))"
770776
"Form to invoke apropos."
771777
:type 'string
772778
:package-version '(inf-clojure . "2.0.0"))
773779

774780
(defcustom inf-clojure-apropos-form-planck
775781
"(doseq [var (sort (planck.repl/apropos \"%s\"))]
776-
(println (str var)))\n"
782+
(println (str var)))"
777783
"Planck form to invoke apropos."
778784
:type 'string
779785
:package-version '(inf-clojure . "2.0.0"))
@@ -782,20 +788,21 @@ If you are using REPL types, it will pickup the most approapriate
782788
"Return the form to query inferior Clojure for public vars in a namespace.
783789
If you are using REPL types, it will pickup the most approapriate
784790
`inf-clojure-ns-vars-form` variant."
785-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
786-
(`planck inf-clojure-apropos-form-planck)
787-
(_ inf-clojure-apropos-form)))
791+
(inf-clojure--sanitize-command
792+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
793+
(`planck inf-clojure-apropos-form-planck)
794+
(_ inf-clojure-apropos-form))))
788795

789796
(define-obsolete-variable-alias 'inf-clojure-apropos-command 'inf-clojure-apropos-form "2.0.0")
790797

791798
(defcustom inf-clojure-macroexpand-form
792-
"(clojure.core/macroexpand '%s)\n"
799+
"(clojure.core/macroexpand '%s)"
793800
"Form to invoke macroexpand."
794801
:type 'string
795802
:package-version '(inf-clojure . "2.0.0"))
796803

797804
(defcustom inf-clojure-macroexpand-form-planck
798-
"(macroexpand '%s)\n"
805+
"(macroexpand '%s)"
799806
"Planck form to invoke macroexpand."
800807
:type 'string
801808
:package-version '(inf-clojure . "2.0.0"))
@@ -804,20 +811,21 @@ If you are using REPL types, it will pickup the most approapriate
804811
"Return the form for macroexpansion in the inferior Clojure process.
805812
If you are using REPL types, it will pickup the most approapriate
806813
`inf-clojure-macroexpand-form` variant."
807-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
808-
(`planck inf-clojure-macroexpand-form-planck)
809-
(_ inf-clojure-macroexpand-form)))
814+
(inf-clojure--sanitize-command
815+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
816+
(`planck inf-clojure-macroexpand-form-planck)
817+
(_ inf-clojure-macroexpand-form))))
810818

811819
(define-obsolete-variable-alias 'inf-clojure-macroexpand-command 'inf-clojure-macroexpand-form "2.0.0")
812820

813821
(defcustom inf-clojure-macroexpand-1-form
814-
"(clojure.core/macroexpand-1 '%s)\n"
822+
"(clojure.core/macroexpand-1 '%s)"
815823
"Form to invoke macroexpand-1."
816824
:type 'string
817825
:package-version '(inf-clojure . "2.0.0"))
818826

819827
(defcustom inf-clojure-macroexpand-1-form-planck
820-
"(macroexpand-1 '%s)\n"
828+
"(macroexpand-1 '%s)"
821829
"Planck form to invoke macroexpand-1."
822830
:type 'string
823831
:package-version '(inf-clojure . "2.0.0"))
@@ -826,9 +834,10 @@ If you are using REPL types, it will pickup the most approapriate
826834
"Return the form for macroexpand-1 in the inferior Clojure process.
827835
If you are using REPL types, it will pickup the most approapriate
828836
`inf-clojure-macroexpand-1-form` variant."
829-
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
830-
(`planck inf-clojure-macroexpand-1-form-planck)
831-
(_ inf-clojure-macroexpand-1-form)))
837+
(inf-clojure--sanitize-command
838+
(pcase (inf-clojure--set-repl-type (inf-clojure-proc))
839+
(`planck inf-clojure-macroexpand-1-form-planck)
840+
(_ inf-clojure-macroexpand-1-form))))
832841

833842
(define-obsolete-variable-alias 'inf-clojure-macroexpand-1-command 'inf-clojure-macroexpand-1-form "2.0.0")
834843

@@ -885,16 +894,6 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol name."
885894
(inf-clojure-symbol-at-point))))
886895
(comint-proc-query (inf-clojure-proc) (format (inf-clojure-var-source-form) var))))
887896

888-
(defun inf-clojure-match-arglists (input-form string)
889-
"Return the arglists match from INPUT-FORM and STRING.
890-
The output depends on the correct REPL type. We assume the
891-
`inf-clojure-repl-type` var is already set, therefore this is
892-
safe to call only from inside `inf-clojure-arglists`."
893-
(pcase inf-clojure-repl-type
894-
(`lumo (let ((input-end (and (string-match input-form string) (match-end 0))))
895-
(and (string-match "(.+)" string input-end) (match-string 0 string))))
896-
(_ (and (string-match "(.+)" string) (match-string 0 string)))))
897-
898897
;; Originally from:
899898
;; https://github.com/glycerine/lush2/blob/master/lush2/etc/lush.el#L287
900899
(defun inf-clojure-results-from-process (process command &optional beg-string end-string)

0 commit comments

Comments
 (0)