From d770f67303b8ad9f744f0952c2ecbadb2eea9ac2 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sat, 21 Dec 2024 17:25:31 +0100 Subject: [PATCH] update cider Signed-off-by: Andreas Gerler --- elpa/cider-20230707.640/cider-cheatsheet.el | 577 ------------ elpa/cider-20230707.640/cider-inspector.el | 528 ----------- elpa/cider-20230707.640/cider-pkg.el | 26 - .../cider-apropos.el | 2 +- .../cider-autoloads.el | 455 ++++------ .../cider-browse-ns.el | 2 +- .../cider-browse-spec.el | 2 +- elpa/cider-20241203.1607/cider-cheatsheet.el | 640 ++++++++++++++ .../cider-classpath.el | 2 +- .../cider-client.el | 105 ++- .../cider-clojuredocs.el | 118 ++- .../cider-common.el | 63 +- .../cider-completion-context.el | 116 +++ .../cider-completion.el | 190 ++-- .../cider-connection.el | 193 ++-- .../cider-debug.el | 27 +- .../cider-doc.el | 137 ++- elpa/cider-20241203.1607/cider-docstring.el | 163 ++++ .../cider-eldoc.el | 28 +- .../cider-eval.el | 706 ++++++++------- .../cider-find.el | 160 ++-- .../cider-format.el | 2 +- elpa/cider-20241203.1607/cider-inspector.el | 836 ++++++++++++++++++ .../cider-jar.el | 2 +- .../cider-log.el | 107 ++- .../cider-macroexpansion.el | 27 +- .../cider-mode.el | 59 +- .../cider-ns.el | 96 +- .../cider-overlays.el | 30 +- elpa/cider-20241203.1607/cider-pkg.el | 22 + .../cider-popup.el | 69 +- .../cider-profile.el | 2 +- .../cider-repl-history.el | 2 +- .../cider-repl.el | 254 +++++- .../cider-resolve.el | 2 +- .../cider-scratch.el | 3 +- .../cider-selector.el | 19 +- .../cider-stacktrace.el | 71 +- .../cider-test.el | 215 +++-- .../cider-tracing.el | 2 +- .../cider-util.el | 39 +- .../cider-20241203.1607/cider-xref-backend.el | 166 ++++ .../cider-xref.el | 34 +- .../cider.el | 725 ++++++++++----- elpa/cider-20241203.1607/clojure.sh | 54 ++ elpa/cider-20241203.1607/lein.sh | 45 + .../nrepl-client.el | 85 +- .../nrepl-dict.el | 43 +- 48 files changed, 4610 insertions(+), 2641 deletions(-) delete mode 100644 elpa/cider-20230707.640/cider-cheatsheet.el delete mode 100644 elpa/cider-20230707.640/cider-inspector.el delete mode 100644 elpa/cider-20230707.640/cider-pkg.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-apropos.el (99%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-autoloads.el (69%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-browse-ns.el (99%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-browse-spec.el (99%) create mode 100644 elpa/cider-20241203.1607/cider-cheatsheet.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-classpath.el (98%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-client.el (89%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-clojuredocs.el (61%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-common.el (88%) create mode 100644 elpa/cider-20241203.1607/cider-completion-context.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-completion.el (57%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-connection.el (90%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-debug.el (97%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-doc.el (80%) create mode 100644 elpa/cider-20241203.1607/cider-docstring.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-eldoc.el (93%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-eval.el (73%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-find.el (70%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-format.el (98%) create mode 100644 elpa/cider-20241203.1607/cider-inspector.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-jar.el (99%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-log.el (93%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-macroexpansion.el (88%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-mode.el (95%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-ns.el (70%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-overlays.el (92%) create mode 100644 elpa/cider-20241203.1607/cider-pkg.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-popup.el (60%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-profile.el (99%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-repl-history.el (99%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-repl.el (86%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-resolve.el (98%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-scratch.el (96%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-selector.el (91%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-stacktrace.el (94%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-test.el (79%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-tracing.el (98%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-util.el (95%) create mode 100644 elpa/cider-20241203.1607/cider-xref-backend.el rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider-xref.el (88%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/cider.el (75%) create mode 100755 elpa/cider-20241203.1607/clojure.sh create mode 100755 elpa/cider-20241203.1607/lein.sh rename elpa/{cider-20230707.640 => cider-20241203.1607}/nrepl-client.el (95%) rename elpa/{cider-20230707.640 => cider-20241203.1607}/nrepl-dict.el (84%) diff --git a/elpa/cider-20230707.640/cider-cheatsheet.el b/elpa/cider-20230707.640/cider-cheatsheet.el deleted file mode 100644 index 533dae85..00000000 --- a/elpa/cider-20230707.640/cider-cheatsheet.el +++ /dev/null @@ -1,577 +0,0 @@ -;;; cider-cheatsheet.el --- Quick reference for Clojure -*- lexical-binding: t -*- - -;; Copyright © 2019-2023 Kris Jenkins, Bozhidar Batsov and CIDER contributors -;; -;; Author: Kris Jenkins - -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;; This file is not part of GNU Emacs. - -;;; Commentary: - -;; A quick reference system for Clojure. Fast, searchable & available offline. - -;; Mostly taken from Kris Jenkins' `clojure-cheatsheet' -;; See: https://github.com/clojure-emacs/clojure-cheatsheet - -;;; Code: - -(require 'cider-doc) -(require 'seq) - -(defconst cider-cheatsheet-hierarchy - '(("Primitives" - ("Numbers" - ("Arithmetic" - (clojure.core + - * / quot rem mod dec inc max min)) - ("Compare" - (clojure.core = == not= < > <= >= compare)) - ("Bitwise" - (clojure.core bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor unsigned-bit-shift-right)) - ("Cast" - (clojure.core byte short long int float double bigdec bigint biginteger num rationalize)) - ("Test" - (clojure.core nil? some? identical? zero? pos? neg? even? odd?)) - ("Random" - (clojure.core rand rand-int)) - ("BigDecimal" - (clojure.core with-precision)) - ("Ratios" - (clojure.core numerator denominator ratio?)) - ("Arbitrary Precision Arithmetic" - (clojure.core +\' -\' *\' inc\' dec\')) - ("Unchecked" - (clojure.core *unchecked-math* - unchecked-add - unchecked-add-int - unchecked-byte - unchecked-char - unchecked-dec - unchecked-dec-int - unchecked-divide-int - unchecked-double - unchecked-float - unchecked-inc - unchecked-inc-int - unchecked-int - unchecked-long - unchecked-multiply - unchecked-multiply-int - unchecked-negate - unchecked-negate-int - unchecked-remainder-int - unchecked-short - unchecked-subtract - unchecked-subtract-int))) - - ("Strings" - ("Create" - (clojure.core str format)) - ("Use" - (clojure.core count get subs compare) - (clojure.string join escape split split-lines replace replace-first reverse re-quote-replacement index-of last-index-of starts-with? ends-with? includes?)) - ("Regex" - (clojure.core re-find re-seq re-matches re-pattern re-matcher re-groups) - (clojure.string replace replace-first re-quote-replacement)) - ("Letters" - (clojure.string capitalize lower-case upper-case)) - ("Trim" - (clojure.string trim trim-newline triml trimr)) - ("Test" - (clojure.core char char? string?) - (clojure.string blank?))) - - ("Other" - ("Characters" - (clojure.core char char-name-string char-escape-string)) - ("Keywords" - (clojure.core keyword keyword? find-keyword)) - ("Symbols" - (clojure.core symbol symbol? gensym)) - ("Data Readers" - (clojure.core *data-readers* default-data-readers *default-data-reader-fn*)))) - - ("Collections" - ("Generic Ops" - (clojure.core count bounded-count empty not-empty into conj)) - ("Tree Walking" - (clojure.walk walk prewalk prewalk-demo prewalk-replace postwalk postwalk-demo postwalk-replace keywordize-keys stringify-keys)) - ("Content tests" - (clojure.core distinct? empty? every? not-every? some not-any?)) - ("Capabilities" - (clojure.core sequential? associative? sorted? counted? reversible?)) - ("Type tests" - (clojure.core type class coll? list? vector? set? map? seq? - number? integer? float? decimal? class? rational? ratio? - chunked-seq? reduced? special-symbol? record?)) - ("Lists" - ("Create" - (clojure.core list list*)) - ("Examine" - (clojure.core first nth peek)) - ("Change" - (clojure.core cons conj rest pop))) - - ("Vectors" - ("Create" - (clojure.core vec vector vector-of)) - ("Examine" - (clojure.core get peek)) - - ("Change" - (clojure.core assoc pop subvec replace conj rseq)) - ("Ops" - (clojure.core mapv filterv reduce-kv))) - - ("Sets" - ("Create" - (clojure.core set hash-set sorted-set sorted-set-by)) - ("Examine" - (clojure.core get contains?)) - ("Change" - (clojure.core conj disj)) - ("Relational Algebra" - (clojure.set join select project union difference intersection)) - ("Get map" - (clojure.set index rename-keys rename map-invert)) - ("Test" - (clojure.set subset? superset?)) - ("Sorted Sets" - (clojure.core rseq subseq rsubseq))) - - ("Maps" - ("Create" - (clojure.core hash-map array-map zipmap sorted-map sorted-map-by bean frequencies group-by)) - ("Examine" - (clojure.core get get-in contains? find keys vals map-entry?)) - ("Change" - (clojure.core assoc assoc-in dissoc merge merge-with select-keys update update-in)) - ("Entry" - (clojure.core key val)) - ("Sorted Maps" - (clojure.core rseq subseq rsubseq))) - - ("Hashes" - (clojure.core hash hash-ordered-coll hash-unordered-coll mix-collection-hash)) - - ("Volatiles" - (clojure.core volatile! volatile? vreset! vswap!))) - - ("Functions" - ("Create" - (clojure.core fn defn defn- definline identity constantly comp complement partial juxt memfn memoize fnil every-pred some-fn trampoline)) - ("Call" - (clojure.core -> ->> some-> some->> as-> cond-> cond->>)) - ("Test" - (clojure.core fn? ifn?))) - - ("Transducers" - ("Create" - (clojure.core cat dedupe distinct drop drop-while filter halt-when interpose keep keep-indexed map map-indexed mapcat partition-all partition-by random-sample remove replace take take-nth take-while)) - ("Call" - (clojure.core ->Eduction eduction into sequence transduce completing run!)) - ("Early Termination" - (clojure.core deref reduced reduced? ensure-reduced unreduced))) - - ("Spec" - ("Operations" - (clojure.spec.alpha valid? conform unform explain explain-data explain-str explain-out form describe assert check-asserts check-asserts?)) - ("Generator Ops" - (clojure.spec.alpha gen exercise exercise-fn)) - ("Defn & Registry" - (clojure.spec.alpha def fdef registry get-spec spec? spec with-gen)) - ("Logical" - (clojure.spec.alpha and or)) - ("Collection" - (clojure.spec.alpha coll-of map-of every every-kv keys merge)) - ("Regex " - (clojure.spec.alpha cat alt * + \? & keys*)) - ("Range" - (clojure.spec.alpha int-in inst-in double-in int-in-range? inst-in-range?)) - ("Custom Explain" - (clojure.spec.alpha explain-printer *explain-out*)) - ("Other" - (clojure.spec.alpha nilable multi-spec fspec conformer)) - - ("Predicates with test.check generators" - ("Numbers" - (clojure.core number? rational? integer? ratio? decimal? float? zero? double? int? nat-int? neg-int? pos-int?)) - ("Symbols & Keywords" - (clojure.core keyword? symbol? ident? qualified-ident? qualified-keyword? qualified-symbol? simple-ident? simple-keyword? simple-symbol?)) - ("Scalars" - (clojure.core string? true? false? nil? some? boolean? bytes? inst? uri? uuid?)) - ("Collections" - (clojure.core list? map? set? vector? associative? coll? sequential? seq? empty? indexed? seqable?)) - ("Other" - (clojure.core any?)))) - - ("Other" - ("XML" - (clojure.core xml-seq) - (clojure.xml parse)) - ("REPL" - (clojure.core *1 *2 *3 *e *print-dup* *print-length* *print-level* *print-meta* *print-readably*)) - ("EDN" - (clojure.edn read read-string)) - ("Compiling Code & Class Generation" - (clojure.core *compile-files* *compile-path* *file* *warn-on-reflection* compile gen-class gen-interface loaded-libs test)) - ("Misc" - (clojure.core eval force name *clojure-version* clojure-version *command-line-args*)) - ("Pretty Printing" - (clojure.pprint pprint print-table pp *print-right-margin*)) - ("Browser / Shell" - (clojure.java.browse browse-url) - (clojure.java.shell sh with-sh-dir with-sh-env))) - - ("Vars & Global Environment" - ("Def Variants" - (:special def) - (clojure.core defn defn- definline defmacro defmethod defmulti defonce defrecord)) - ("Interned Vars" - (:special var) - (clojure.core declare intern binding find-var)) - ("Var Objects" - (clojure.core with-local-vars var-get var-set alter-var-root var?)) - ("Var Validators" - (clojure.core set-validator! get-validator))) - - ("Reader Conditionals" - (clojure.core reader-conditional reader-conditional? tagged-literal tagged-literal?)) - - ("Abstractions" - ("Protocols" - (clojure.core defprotocol extend extend-type extend-protocol reify extends? satisfies? extenders)) - ("Records & Types" - (clojure.core defrecord deftype)) - ("Multimethods" - ("Define" - (clojure.core defmulti defmethod)) - ("Dispatch" - (clojure.core get-method methods)) - ("Remove" - (clojure.core remove-method remove-all-methods)) - ("Prefer" - (clojure.core prefer-method prefers)) - ("Relation" - (clojure.core derive isa? parents ancestors descendants make-hierarchy)))) - - ("Macros" - ("Create" - (clojure.core defmacro definline)) - ("Debug" - (clojure.core macroexpand-1 macroexpand) - (clojure.walk macroexpand-all)) - ("Branch" - (clojure.core and or when when-not when-let when-first if-not if-let cond condp case)) - ("Loop" - (clojure.core for doseq dotimes while)) - ("Arrange" - (clojure.core .. doto ->)) - ("Scope" - (clojure.core binding locking time) - (clojure.core with-in-str with-local-vars with-open with-out-str with-precision with-redefs with-redefs-fn)) - ("Lazy" - (clojure.core lazy-cat lazy-seq delay delay?)) - ("Doc" - (clojure.core assert comment) - (clojure.repl doc dir dir-fn source-fn))) - - ("Java Interop" - ("General" - (:special new set!) - (clojure.core .. doto bean comparator enumeration-seq import iterator-seq memfn definterface supers bases)) - ("Cast" - (clojure.core boolean byte short char int long float double bigdec bigint num cast biginteger)) - ("Exceptions" - (:special throw try catch finally) - (clojure.core ex-info ex-data Throwable->map StackTraceElement->vec) - (clojure.repl pst)) - ("Arrays" - ("Create" - (clojure.core boolean-array byte-array double-array char-array float-array int-array long-array make-array object-array short-array to-array)) - ("Manipulate" - (clojure.core aclone aget aset alength amap areduce aset-int aset-long aset-short aset-boolean aset-byte aset-char aset-double aset-float)) - ("Cast" - (clojure.core booleans bytes chars doubles floats ints longs shorts))) - ("Proxy" - ("Create" - (clojure.core proxy get-proxy-class construct-proxy init-proxy)) - ("Misc" - (clojure.core proxy-mappings proxy-super update-proxy)))) - - ("Namespaces" - ("Current" - (clojure.core *ns*)) - ("Create Switch" - (clojure.core ns in-ns create-ns)) - ("Add" - (clojure.core alias import intern refer refer-clojure)) - ("Find" - (clojure.core all-ns find-ns)) - ("Examine" - (clojure.core ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers)) - ("From symbol" - (clojure.core resolve namespace ns-resolve the-ns)) - ("Remove" - (clojure.core ns-unalias ns-unmap remove-ns))) - ("Loading" - ("Load libs" - (clojure.core require use import refer)) - ("List Loaded" - (clojure.core loaded-libs)) - ("Load Misc" - (clojure.core load load-file load-reader load-string))) - - ("Concurrency" - ("Atoms" - (clojure.core atom swap! swap-vals! reset! reset-vals! compare-and-set!)) - ("Futures" - (clojure.core future future-call future-cancel future-cancelled? future-done? future?)) - ("Threads" - (clojure.core bound-fn bound-fn* get-thread-bindings pop-thread-bindings push-thread-bindings)) - - ("Misc" - (clojure.core locking pcalls pvalues pmap seque promise deliver)) - - ("Refs & Transactions" - ("Create" - (clojure.core ref)) - ("Examine" - (clojure.core deref)) - ("Transaction" - (clojure.core sync dosync io!)) - ("In Transaction" - (clojure.core ensure ref-set alter commute)) - ("Validators" - (clojure.core get-validator set-validator!)) - ("History" - (clojure.core ref-history-count ref-max-history ref-min-history))) - - ("Agents & Asynchronous Actions" - ("Create" - (clojure.core agent)) - ("Examine" - (clojure.core agent-error)) - ("Change State" - (clojure.core send send-off restart-agent send-via set-agent-send-executor! set-agent-send-off-executor!)) - ("Block Waiting" - (clojure.core await await-for)) - ("Ref Validators" - (clojure.core get-validator set-validator!)) - ("Watchers" - (clojure.core add-watch remove-watch)) - ("Thread Handling" - (clojure.core shutdown-agents)) - ("Error" - (clojure.core error-handler set-error-handler! error-mode set-error-mode!)) - ("Misc" - (clojure.core *agent* release-pending-sends)))) - - ("Sequences" - ("Creating a Lazy Seq" - ("From Collection" - (clojure.core seq sequence keys vals rseq subseq rsubseq)) - ("From Producer Fn" - (clojure.core lazy-seq repeatedly iterate)) - ("From Constant" - (clojure.core repeat range)) - ("From Other" - (clojure.core file-seq line-seq resultset-seq re-seq tree-seq xml-seq iterator-seq enumeration-seq)) - ("From Seq" - (clojure.core keep keep-indexed))) - - ("Seq in, Seq out" - ("Get shorter" - (clojure.core distinct dedupe filter remove for)) - ("Get longer" - (clojure.core cons conj concat lazy-cat mapcat cycle interleave interpose))) - ("Tail-items" - (clojure.core rest nthrest fnext nnext drop drop-while take-last for)) - ("Head-items" - (clojure.core take take-nth take-while butlast drop-last for)) - ("Change" - (clojure.core conj concat distinct flatten group-by partition partition-all partition-by split-at split-with filter remove replace shuffle random-sample)) - ("Rearrange" - (clojure.core reverse sort sort-by compare)) - ("Process items" - (clojure.core map pmap map-indexed mapcat for replace seque)) - - ("Using a Seq" - ("Extract item" - (clojure.core first second last rest next ffirst nfirst fnext nnext nth nthnext rand-nth when-first max-key min-key)) - ("Construct coll" - (clojure.core zipmap into reduce reductions set vec into-array to-array-2d)) - ("Pass to fn" - (clojure.core apply)) - ("Search" - (clojure.core some filter)) - ("Force evaluation" - (clojure.core doseq dorun doall)) - ("Check for forced" - (clojure.core realized?)))) - - ("Zippers" - ("Create" - (clojure.zip zipper seq-zip vector-zip xml-zip)) - ("Get loc" - (clojure.zip up down left right leftmost rightmost)) - ("Get seq" - (clojure.zip lefts rights path children)) - ("Change" - (clojure.zip make-node replace edit insert-child insert-left insert-right append-child remove)) - ("Move" - (clojure.zip next prev)) - ("XML" - (clojure.data.zip.xml attr attr= seq-test tag= text text= xml-> xml1->)) - ("Misc" - (clojure.zip root node branch? end?))) - - ("Documentation" - ("REPL" - (clojure.repl doc find-doc apropos source pst) - (clojure.java.javadoc javadoc))) - - ("Transients" - ("Create" - (clojure.core transient persistent!)) - ("Change" - (clojure.core conj! pop! assoc! dissoc! disj!))) - ("Misc" - ("Compare" - (clojure.core = == identical? not= not compare) - (clojure.data diff)) - ("Test" - (clojure.core true? false? nil? instance?))) - - ("IO" - ("To/from ..." - (clojure.core spit slurp)) - ("To *out*" - (clojure.core pr prn print printf println newline) - (clojure.pprint print-table)) - ("To writer" - (clojure.pprint pprint cl-format)) - ("To string" - (clojure.core format with-out-str pr-str prn-str print-str println-str)) - ("From *in*" - (clojure.core read-line read)) - ("From reader" - (clojure.core line-seq read)) - ("From string" - (clojure.core read-string with-in-str)) - ("Open" - (clojure.core with-open) - (clojure.java.io reader writer input-stream output-stream)) - ("Interop" - (clojure.java.io make-writer make-reader make-output-stream make-input-stream)) - ("Misc" - (clojure.core flush file-seq *in* *out* *err*) - (clojure.java.io file copy delete-file resource as-file as-url as-relative-path make-parents))) - - ("Metadata" - (clojure.core meta with-meta alter-meta! reset-meta! vary-meta)) - - ("Special Forms" - (:special def if do quote var recur throw try monitor-enter monitor-exit) - (clojure.core fn loop) - ("Binding / Destructuring" - (clojure.core let fn letfn defn defmacro loop for doseq if-let if-some when-let when-some))) - - ("Async" - ("Main" - (clojure.core.async go go-loop ! >!! chan put! take take! close! timeout offer! poll! promise-chan)) - ("Choice" - (clojure.core.async alt! alt!! alts! alts!! do-alts)) - ("Buffering" - (clojure.core.async buffer dropping-buffer sliding-buffer unblocking-buffer?)) - ("Pipelines" - (clojure.core.async pipeline pipeline-async pipeline-blocking)) - ("Threading" - (clojure.core.async thread thread-call)) - ("Mixing" - (clojure.core.async admix solo-mode mix unmix unmix-all toggle merge pipe unique)) - ("Multiples" - (clojure.core.async mult tap untap untap-all)) - ("Publish/Subscribe" - (clojure.core.async pub sub unsub unsub-all)) - ("Higher Order" - (clojure.core.async filter< filter> map map< map> mapcat< mapcat> partition partition-by reduce remove< remove> split)) - ("Pre-Populate" - (clojure.core.async into onto-chan to-chan))) - ("Unit Tests" - ("Defining" - (clojure.test deftest deftest- testing is are)) - ("Running" - (clojure.test run-tests run-all-tests test-vars)) - ("Fixtures" - (clojure.test use-fixtures join-fixtures compose-fixtures)))) - "A data structure for Clojure cheatsheet information. - -It's a tree, where the head of each list determines the context of the rest -of the list. The head may be: - - - A string, in which case it's a (sub)heading for the rest of the items. - - - A symbol, in which case it's the Clojure namespace of the symbols that - follow it. - - - The keyword :special, in which case it's a Clojure special form - - - Any other keyword, in which case it's a typed item that will be passed - through. - -Note that some Clojure symbols appear in more than once. This is entirely -intentional. For instance, `map` belongs in the sections on collections -and transducers.") - -(defun cider-cheatsheet--expand-vars (list) - "Expand the symbols in LIST to fully-qualified var names. - -This list is supposed to have the following format: - - (my-ns var1 var2 var3)" - (let ((ns (car list)) - (vars (cdr list))) - (if (eq ns :special) - (mapcar #'symbol-name vars) - (mapcar (lambda (var) (format "%s/%s" ns var)) vars)))) - -(defun cider-cheatsheet--select-var (var-list) - "Expand the symbols in VAR-LIST to fully-qualified var names. - -The list can hold one or more lists inside - one per each namespace." - (let ((namespaced-vars (seq-mapcat #'cider-cheatsheet--expand-vars - (seq-remove (lambda (list) - (eq (car list) :url)) - var-list)))) - (cider-doc-lookup (completing-read "Select var: " namespaced-vars)))) - -;;;###autoload -(defun cider-cheatsheet () - "Navigate `cider-cheatsheet-hierarchy' with `completing-read'. - -When you make it to a Clojure var its doc buffer gets displayed." - (interactive) - (let ((cheatsheet-data cider-cheatsheet-hierarchy)) - (while (stringp (caar cheatsheet-data)) - (let* ((sections (mapcar #'car cheatsheet-data)) - (sel-section (completing-read "Select cheatsheet section: " sections)) - (section-data (seq-find (lambda (elem) (equal (car elem) sel-section)) cheatsheet-data))) - (setq cheatsheet-data (cdr section-data)))) - (cider-cheatsheet--select-var cheatsheet-data))) - -(provide 'cider-cheatsheet) - -;;; cider-cheatsheet.el ends here diff --git a/elpa/cider-20230707.640/cider-inspector.el b/elpa/cider-20230707.640/cider-inspector.el deleted file mode 100644 index 085e4026..00000000 --- a/elpa/cider-20230707.640/cider-inspector.el +++ /dev/null @@ -1,528 +0,0 @@ -;;; cider-inspector.el --- Object inspector -*- lexical-binding: t -*- - -;; Copyright © 2013-2014 Vital Reactor, LLC -;; Copyright © 2014-2023 Bozhidar Batsov and CIDER contributors - -;; Author: Ian Eslick -;; Bozhidar Batsov - -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;; This file is not part of GNU Emacs. - -;;; Commentary: - -;; Clojure object inspector inspired by SLIME. - -;;; Code: - -(require 'cl-lib) -(require 'easymenu) -(require 'seq) -(require 'cider-eval) - -;; =================================== -;; Inspector Key Map and Derived Mode -;; =================================== - -(defconst cider-inspector-buffer "*cider-inspect*") - -;;; Customization -(defgroup cider-inspector nil - "Presentation and behavior of the CIDER value inspector." - :prefix "cider-inspector-" - :group 'cider - :package-version '(cider . "0.10.0")) - -(defcustom cider-inspector-page-size 32 - "Default page size in paginated inspector view. -The page size can be also changed interactively within the inspector." - :type '(integer :tag "Page size" 32) - :package-version '(cider . "0.10.0")) - -(defcustom cider-inspector-max-atom-length 150 - "Default max length of nested atoms before they are truncated. -'Atom' here means any collection member that satisfies (complement coll?). -The max length can be also changed interactively within the inspector." - :type '(integer :tag "Max atom length" 150) - :package-version '(cider . "1.1.0")) - -(defcustom cider-inspector-max-coll-size 5 - "Default number of nested collection members to display before truncating. -The max size can be also changed interactively within the inspector." - :type '(integer :tag "Max collection size" 5) - :package-version '(cider . "1.1.0")) - -(defcustom cider-inspector-fill-frame nil - "Controls whether the CIDER inspector window fills its frame." - :type 'boolean - :package-version '(cider . "0.15.0")) - -(defcustom cider-inspector-skip-uninteresting t - "Controls whether to skip over uninteresting values in the inspector. -Only applies to navigation with `cider-inspector-prev-inspectable-object' -and `cider-inspector-next-inspectable-object', values are still inspectable -by clicking or navigating to them by other means." - :type 'boolean - :package-version '(cider . "0.25.0")) - -(defcustom cider-inspector-auto-select-buffer t - "Determines if the inspector buffer should be auto selected." - :type 'boolean - :package-version '(cider . "0.27.0")) - -(defvar cider-inspector-uninteresting-regexp - (concat "nil" ; nils are not interesting - "\\|:" clojure--sym-regexp ; nor keywords - ;; FIXME: This range also matches ",", is it on purpose? - "\\|[+-.0-9]+") ; nor numbers. Note: BigInts, ratios etc. are interesting - "Regexp of uninteresting and skippable values.") - -(defvar cider-inspector-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map cider-popup-buffer-mode-map) - (define-key map (kbd "RET") #'cider-inspector-operate-on-point) - (define-key map [mouse-1] #'cider-inspector-operate-on-click) - (define-key map "l" #'cider-inspector-pop) - (define-key map "g" #'cider-inspector-refresh) - ;; Page-up/down - (define-key map [next] #'cider-inspector-next-page) - (define-key map [prior] #'cider-inspector-prev-page) - (define-key map " " #'cider-inspector-next-page) - (define-key map (kbd "M-SPC") #'cider-inspector-prev-page) - (define-key map (kbd "S-SPC") #'cider-inspector-prev-page) - (define-key map "s" #'cider-inspector-set-page-size) - (define-key map "a" #'cider-inspector-set-max-atom-length) - (define-key map "c" #'cider-inspector-set-max-coll-size) - (define-key map "d" #'cider-inspector-def-current-val) - (define-key map [tab] #'cider-inspector-next-inspectable-object) - (define-key map "\C-i" #'cider-inspector-next-inspectable-object) - (define-key map "n" #'cider-inspector-next-inspectable-object) - (define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object) - (define-key map "p" #'cider-inspector-previous-inspectable-object) - (define-key map "f" #'forward-char) - (define-key map "b" #'backward-char) - ;; Emacs translates S-TAB to BACKTAB on X. - (define-key map [backtab] #'cider-inspector-previous-inspectable-object) - (easy-menu-define cider-inspector-mode-menu map - "Menu for CIDER's inspector." - `("CIDER Inspector" - ["Inspect" cider-inspector-operate-on-point] - ["Pop" cider-inspector-pop] - ["Refresh" cider-inspector-refresh] - "--" - ["Next Inspectable Object" cider-inspector-next-inspectable-object] - ["Previous Inspectable Object" cider-inspector-previous-inspectable-object] - "--" - ["Next Page" cider-inspector-next-page] - ["Previous Page" cider-inspector-prev-page] - ["Set Page Size" cider-inspector-set-page-size] - ["Set Max Atom Length" cider-inspector-set-max-atom-length] - ["Set Max Collection Size" cider-inspector-set-max-coll-size] - ["Define Var" cider-inspector-def-current-val] - "--" - ["Quit" cider-popup-buffer-quit-function] - )) - map)) - -(define-derived-mode cider-inspector-mode special-mode "Inspector" - "Major mode for inspecting Clojure data structures. - -\\{cider-inspector-mode-map}" - (set-syntax-table clojure-mode-syntax-table) - (setq-local electric-indent-chars nil) - (setq-local sesman-system 'CIDER) - (visual-line-mode 1)) - -;;;###autoload -(defun cider-inspect-last-sexp () - "Inspect the result of the the expression preceding point." - (interactive) - (cider-inspect-expr (cider-last-sexp) (cider-current-ns))) - -;;;###autoload -(defun cider-inspect-defun-at-point () - "Inspect the result of the \"top-level\" expression at point." - (interactive) - (cider-inspect-expr (cider-defun-at-point) (cider-current-ns))) - -;;;###autoload -(defun cider-inspect-last-result () - "Inspect the most recent eval result." - (interactive) - (cider-inspect-expr "*1" (cider-current-ns))) - -;;;###autoload -(defun cider-inspect (&optional arg) - "Inspect the result of the preceding sexp. - -With a prefix argument ARG it inspects the result of the \"top-level\" form. -With a second prefix argument it prompts for an expression to eval and inspect." - (interactive "p") - (pcase arg - (1 (cider-inspect-last-sexp)) - (4 (cider-inspect-defun-at-point)) - (16 (call-interactively #'cider-inspect-expr)))) - -(defvar cider-inspector-location-stack nil - "A stack used to save point locations in inspector buffers. -These locations are used to emulate `save-excursion' between -`cider-inspector-push' and `cider-inspector-pop' operations.") - -(defvar cider-inspector-page-location-stack nil - "A stack used to save point locations in inspector buffers. -These locations are used to emulate `save-excursion' between -`cider-inspector-next-page' and `cider-inspector-prev-page' operations.") - -(defvar cider-inspector-last-command nil - "Contains the value of the most recently used `cider-inspector-*' command. -This is used as an alternative to the built-in `last-command'. Whenever we -invoke any command through \\[execute-extended-command] and its variants, -the value of `last-command' is not set to the command it invokes.") - -(defvar cider-inspector--current-repl nil - "Contains the reference to the REPL where inspector was last invoked from. -This is needed for internal inspector buffer operations (push, -pop) to execute against the correct REPL session.") - -;; Operations -;;;###autoload -(defun cider-inspect-expr (expr ns) - "Evaluate EXPR in NS and inspect its value. -Interactively, EXPR is read from the minibuffer, and NS the -current buffer's namespace." - (interactive (list (cider-read-from-minibuffer "Inspect expression: " (cider-sexp-at-point)) - (cider-current-ns))) - (setq cider-inspector--current-repl (cider-current-repl)) - (when-let* ((value (cider-sync-request:inspect-expr - expr ns - cider-inspector-page-size - cider-inspector-max-atom-length - cider-inspector-max-coll-size))) - (cider-inspector--render-value value))) - -(defun cider-inspector-pop () - "Pop the last value off the inspector stack and render it. -See `cider-sync-request:inspect-pop' and `cider-inspector--render-value'." - (interactive) - (setq cider-inspector-last-command 'cider-inspector-pop) - (when-let* ((value (cider-sync-request:inspect-pop))) - (cider-inspector--render-value value))) - -(defun cider-inspector-push (idx) - "Inspect the value at IDX in the inspector stack and render it. -See `cider-sync-request:inspect-push' and `cider-inspector--render-value'" - (push (point) cider-inspector-location-stack) - (when-let* ((value (cider-sync-request:inspect-push idx))) - (cider-inspector--render-value value) - (cider-inspector-next-inspectable-object 1))) - -(defun cider-inspector-refresh () - "Re-render the currently inspected value. -See `cider-sync-request:inspect-refresh' and `cider-inspector--render-value'" - (interactive) - (when-let* ((value (cider-sync-request:inspect-refresh))) - (cider-inspector--render-value value))) - -(defun cider-inspector-next-page () - "Jump to the next page when inspecting a paginated sequence/map. - -Does nothing if already on the last page." - (interactive) - (push (point) cider-inspector-page-location-stack) - (when-let* ((value (cider-sync-request:inspect-next-page))) - (cider-inspector--render-value value))) - -(defun cider-inspector-prev-page () - "Jump to the previous page when expecting a paginated sequence/map. - -Does nothing if already on the first page." - (interactive) - (setq cider-inspector-last-command 'cider-inspector-prev-page) - (when-let* ((value (cider-sync-request:inspect-prev-page))) - (cider-inspector--render-value value))) - -(defun cider-inspector-set-page-size (page-size) - "Set the page size in pagination mode to the specified PAGE-SIZE. - -Current page will be reset to zero." - (interactive (list (read-number "Page size: " cider-inspector-page-size))) - (when-let ((value (cider-sync-request:inspect-set-page-size page-size))) - (cider-inspector--render-value value))) - -(defun cider-inspector-set-max-atom-length (max-length) - "Set the max length of nested atoms to MAX-LENGTH." - (interactive (list (read-number "Max atom length: " cider-inspector-max-atom-length))) - (when-let ((value (cider-sync-request:inspect-set-max-atom-length max-length))) - (cider-inspector--render-value value))) - -(defun cider-inspector-set-max-coll-size (max-size) - "Set the number of nested collection members to display before truncating. -MAX-SIZE is the new value." - (interactive (list (read-number "Max collection size: " cider-inspector-max-coll-size))) - (when-let ((value (cider-sync-request:inspect-set-max-coll-size max-size))) - (cider-inspector--render-value value))) - -(defun cider-inspector-def-current-val (var-name ns) - "Defines a var with VAR-NAME in current namespace. - -Doesn't modify current page. When called interactively NS defaults to -current-namespace." - (interactive (let ((ns (cider-current-ns))) - (list (read-from-minibuffer (concat "Var name: " ns "/")) - ns))) - (setq cider-inspector--current-repl (cider-current-repl)) - (when-let* ((value (cider-sync-request:inspect-def-current-val ns var-name))) - (cider-inspector--render-value value) - (message "%s#'%s/%s = %s" cider-eval-result-prefix ns var-name value))) - -;; nREPL interactions -(defun cider-sync-request:inspect-pop () - "Move one level up in the inspector stack." - (thread-first '("op" "inspect-pop") - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-push (idx) - "Inspect the inside value specified by IDX." - (thread-first `("op" "inspect-push" - "idx" ,idx) - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-refresh () - "Re-render the currently inspected value." - (thread-first '("op" "inspect-refresh") - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-next-page () - "Jump to the next page in paginated collection view." - (thread-first '("op" "inspect-next-page") - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-prev-page () - "Jump to the previous page in paginated collection view." - (thread-first '("op" "inspect-prev-page") - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-set-page-size (page-size) - "Set the page size in paginated view to PAGE-SIZE." - (thread-first `("op" "inspect-set-page-size" - "page-size" ,page-size) - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-set-max-atom-length (max-length) - "Set the max length of nested atoms to MAX-LENGTH." - (thread-first `("op" "inspect-set-max-atom-length" - "max-atom-length" ,max-length) - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-set-max-coll-size (max-size) - "Set the number of nested collection members to display before truncating. -MAX-SIZE is the new value." - (thread-first `("op" "inspect-set-max-coll-size" - "max-coll-size" ,max-size) - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-def-current-val (ns var-name) - "Defines a var with VAR-NAME in NS with the current inspector value." - (thread-first `("op" "inspect-def-current-value" - "ns" ,ns - "var-name" ,var-name) - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -(defun cider-sync-request:inspect-expr (expr ns page-size max-atom-length max-coll-size) - "Evaluate EXPR in context of NS and inspect its result. -Set the page size in paginated view to PAGE-SIZE, maximum length of atomic -collection members to MAX-ATOM-LENGTH, and maximum size of nested collections to -MAX-COLL-SIZE if non nil." - (thread-first (append (nrepl--eval-request expr ns) - `("inspect" "true" - ,@(when page-size - `("page-size" ,page-size)) - ,@(when max-atom-length - `("max-atom-length" ,max-atom-length)) - ,@(when max-coll-size - `("max-coll-size" ,max-coll-size)))) - (cider-nrepl-send-sync-request cider-inspector--current-repl) - (nrepl-dict-get "value"))) - -;; Render Inspector from Structured Values -(defun cider-inspector--render-value (value) - "Render VALUE." - (cider-make-popup-buffer cider-inspector-buffer 'cider-inspector-mode 'ancillary) - (cider-inspector-render cider-inspector-buffer value) - (cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer) - (when cider-inspector-fill-frame (delete-other-windows)) - (ignore-errors (cider-inspector-next-inspectable-object 1)) - (with-current-buffer cider-inspector-buffer - (when (eq cider-inspector-last-command 'cider-inspector-pop) - (setq cider-inspector-last-command nil) - ;; Prevents error message being displayed when we try to pop - ;; from the top-level of a data structure - (when cider-inspector-location-stack - (goto-char (pop cider-inspector-location-stack)))) - - (when (eq cider-inspector-last-command 'cider-inspector-prev-page) - (setq cider-inspector-last-command nil) - ;; Prevents error message being displayed when we try to - ;; go to a prev-page from the first page - (when cider-inspector-page-location-stack - (goto-char (pop cider-inspector-page-location-stack)))))) - -(defun cider-inspector-render (buffer str) - "Render STR in BUFFER." - (with-current-buffer buffer - (cider-inspector-mode) - (let ((inhibit-read-only t)) - (condition-case nil - (cider-inspector-render* (car (read-from-string str))) - (error (insert "\nInspector error for: " str)))) - (goto-char (point-min)))) - -(defun cider-inspector-render* (elements) - "Render ELEMENTS." - (dolist (el elements) - (cider-inspector-render-el* el))) - -(defun cider-inspector-render-el* (el) - "Render EL." - (cond ((symbolp el) (insert (symbol-name el))) - ((stringp el) (insert (propertize el 'font-lock-face 'font-lock-keyword-face))) - ((and (consp el) (eq (car el) :newline)) - (insert "\n")) - ((and (consp el) (eq (car el) :value)) - (cider-inspector-render-value (cadr el) (cl-caddr el))) - (t (message "Unrecognized inspector object: %s" el)))) - -(defun cider-inspector-render-value (value idx) - "Render VALUE at IDX." - (cider-propertize-region - (list 'cider-value-idx idx - 'mouse-face 'highlight) - (cider-inspector-render-el* (cider-font-lock-as-clojure value)))) - - -;; =================================================== -;; Inspector Navigation (lifted from SLIME inspector) -;; =================================================== - -(defun cider-find-inspectable-object (direction limit) - "Find the next/previous inspectable object. -DIRECTION can be either 'next or 'prev. -LIMIT is the maximum or minimum position in the current buffer. - -Return a list of two values: If an object could be found, the -starting position of the found object and T is returned; -otherwise LIMIT and NIL is returned." - (let ((finder (cl-ecase direction - (next 'next-single-property-change) - (prev 'previous-single-property-change)))) - (let ((prop nil) (curpos (point))) - (while (and (not prop) (not (= curpos limit))) - (let ((newpos (funcall finder curpos 'cider-value-idx nil limit))) - (setq prop (get-text-property newpos 'cider-value-idx)) - (setq curpos newpos))) - (list curpos (and prop t))))) - -(defun cider-inspector-next-inspectable-object (arg) - "Move point to the next inspectable object. -With optional ARG, move across that many objects. -If ARG is negative, move backwards." - (interactive "p") - (let ((maxpos (point-max)) (minpos (point-min)) - (previously-wrapped-p nil)) - ;; Forward. - (while (> arg 0) - (seq-let (pos foundp) (cider-find-inspectable-object 'next maxpos) - (if foundp - (progn (goto-char pos) - (unless (and cider-inspector-skip-uninteresting - (looking-at-p cider-inspector-uninteresting-regexp)) - (setq arg (1- arg)) - (setq previously-wrapped-p nil))) - (if (not previously-wrapped-p) ; cycle detection - (progn (goto-char minpos) (setq previously-wrapped-p t)) - (error "No inspectable objects"))))) - ;; Backward. - (while (< arg 0) - (seq-let (pos foundp) (cider-find-inspectable-object 'prev minpos) - ;; CIDER-OPEN-INSPECTOR inserts the title of an inspector page - ;; as a presentation at the beginning of the buffer; skip - ;; that. (Notice how this problem can not arise in ``Forward.'') - (if (and foundp (/= pos minpos)) - (progn (goto-char pos) - (unless (and cider-inspector-skip-uninteresting - (looking-at-p cider-inspector-uninteresting-regexp)) - (setq arg (1+ arg)) - (setq previously-wrapped-p nil))) - (if (not previously-wrapped-p) ; cycle detection - (progn (goto-char maxpos) (setq previously-wrapped-p t)) - (error "No inspectable objects"))))))) - -(defun cider-inspector-previous-inspectable-object (arg) - "Move point to the previous inspectable object. -With optional ARG, move across that many objects. -If ARG is negative, move forwards." - (interactive "p") - (cider-inspector-next-inspectable-object (- arg))) - -(defun cider-inspector-property-at-point () - "Return property at point." - (let* ((properties '(cider-value-idx cider-range-button - cider-action-number)) - (find-property - (lambda (point) - (cl-loop for property in properties - for value = (get-text-property point property) - when value - return (list property value))))) - (or (funcall find-property (point)) - (funcall find-property (max (point-min) (1- (point))))))) - -(defun cider-inspector-operate-on-point () - "Invoke the command for the text at point. -1. If point is on a value then recursively call the inspector on -that value. -2. If point is on an action then call that action. -3. If point is on a range-button fetch and insert the range." - (interactive) - (seq-let (property value) (cider-inspector-property-at-point) - (cl-case property - (cider-value-idx - (cider-inspector-push value)) - ;; TODO: range and action handlers - (t (error "No object at point"))))) - -(defun cider-inspector-operate-on-click (event) - "Move to EVENT's position and operate the part." - (interactive "@e") - (let ((point (posn-point (event-end event)))) - (cond ((and point - (or (get-text-property point 'cider-value-idx))) - (goto-char point) - (cider-inspector-operate-on-point)) - (t - (error "No clickable part here"))))) - -(provide 'cider-inspector) - -;;; cider-inspector.el ends here diff --git a/elpa/cider-20230707.640/cider-pkg.el b/elpa/cider-20230707.640/cider-pkg.el deleted file mode 100644 index 083de8d0..00000000 --- a/elpa/cider-20230707.640/cider-pkg.el +++ /dev/null @@ -1,26 +0,0 @@ -(define-package "cider" "20230707.640" "Clojure Interactive Development Environment that Rocks" - '((emacs "26") - (clojure-mode "5.16.0") - (parseedn "1.0.6") - (queue "0.2") - (spinner "1.7") - (seq "2.22") - (sesman "0.3.2") - (transient "0.4.1")) - :commit "bc8903b0c85cf0891f106337eabfc6f747d262a1" :authors - '(("Tim King" . "kingtim@gmail.com") - ("Phil Hagelberg" . "technomancy@gmail.com") - ("Bozhidar Batsov" . "bozhidar@batsov.dev") - ("Artur Malabarba" . "bruce.connor.am@gmail.com") - ("Hugo Duncan" . "hugo@hugoduncan.org") - ("Steve Purcell" . "steve@sanityinc.com")) - :maintainers - '(("Bozhidar Batsov" . "bozhidar@batsov.dev")) - :maintainer - '("Bozhidar Batsov" . "bozhidar@batsov.dev") - :keywords - '("languages" "clojure" "cider") - :url "http://www.github.com/clojure-emacs/cider") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/cider-20230707.640/cider-apropos.el b/elpa/cider-20241203.1607/cider-apropos.el similarity index 99% rename from elpa/cider-20230707.640/cider-apropos.el rename to elpa/cider-20241203.1607/cider-apropos.el index 5cadc3de..b94e27ed 100644 --- a/elpa/cider-20230707.640/cider-apropos.el +++ b/elpa/cider-20241203.1607/cider-apropos.el @@ -1,6 +1,6 @@ ;;; cider-apropos.el --- Apropos functionality for Clojure -*- lexical-binding: t -*- -;; Copyright © 2014-2023 Jeff Valk, Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 Jeff Valk, Bozhidar Batsov and CIDER contributors ;; ;; Author: Jeff Valk diff --git a/elpa/cider-20230707.640/cider-autoloads.el b/elpa/cider-20241203.1607/cider-autoloads.el similarity index 69% rename from elpa/cider-20230707.640/cider-autoloads.el rename to elpa/cider-20241203.1607/cider-autoloads.el index e418fe65..7762315a 100644 --- a/elpa/cider-20230707.640/cider-autoloads.el +++ b/elpa/cider-20241203.1607/cider-autoloads.el @@ -1,45 +1,48 @@ -;;; cider-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; cider-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "cider" "cider.el" (0 0 0 0)) ;;; Generated autoloads from cider.el (autoload 'cider-version "cider" "\ -Display CIDER's version." t nil) +Display CIDER's version." t) (autoload 'cider-start-map "cider" "CIDER jack-in and connect keymap." t 'keymap) - (autoload 'cider-jack-in-clj "cider" "\ Start an nREPL server for the current project and connect to it. PARAMS is a plist optionally containing :project-dir and :jack-in-cmd. With the prefix argument, allow editing of the jack in command; with a double prefix prompt for all these parameters. -\(fn PARAMS)" t nil) - +(fn PARAMS)" t) (autoload 'cider-jack-in-cljs "cider" "\ Start an nREPL server for the current project and connect to it. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument, +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). + +With the prefix argument, allow editing of the jack in command; with a double prefix prompt for all these parameters. -\(fn PARAMS)" t nil) - +(fn PARAMS)" t) (autoload 'cider-jack-in-clj&cljs "cider" "\ Start an nREPL server and connect with clj and cljs REPLs. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument, -allow for editing of the jack in command; with a double prefix prompt for -all these parameters. When SOFT-CLJS-START is non-nil, start cljs REPL -only when the ClojureScript dependencies are met. +:cljs-repl-type (e.g. 'shadow, 'node, 'fighweel, etc). + +With the prefix argument, allow for editing of the jack in command; +with a double prefix prompt for all these parameters. -\(fn &optional PARAMS SOFT-CLJS-START)" t nil) +When SOFT-CLJS-START is non-nil, start cljs REPL +only when the ClojureScript dependencies are met. +(fn &optional PARAMS SOFT-CLJS-START)" t) (autoload 'cider-connect-sibling-clj "cider" "\ Create a Clojure REPL with the same server as OTHER-REPL. PARAMS is for consistency with other connection commands and is currently @@ -47,47 +50,43 @@ ignored. OTHER-REPL defaults to `cider-current-repl' and in programs can also be a server buffer, in which case a new session with a REPL for that server is created. -\(fn PARAMS &optional OTHER-REPL)" t nil) - +(fn PARAMS &optional OTHER-REPL)" t) (autoload 'cider-connect-sibling-cljs "cider" "\ Create a ClojureScript REPL with the same server as OTHER-REPL. -PARAMS is a plist optionally containing :cljs-repl-type (e.g. Node, -Figwheel, etc). All other parameters are inferred from the OTHER-REPL. +PARAMS is a plist optionally containing :cljs-repl-type (e.g. 'node, +'figwheel, 'shadow, etc). + +All other parameters are inferred from the OTHER-REPL. OTHER-REPL defaults to `cider-current-repl' but in programs can also be a server buffer, in which case a new session for that server is created. -\(fn PARAMS &optional OTHER-REPL)" t nil) - +(fn PARAMS &optional OTHER-REPL)" t) (autoload 'cider-connect-clj "cider" "\ Initialize a Clojure connection to an nREPL server. PARAMS is a plist optionally containing :host, :port and :project-dir. On prefix argument, prompt for all the parameters. -\(fn &optional PARAMS)" t nil) - +(fn &optional PARAMS)" t) (autoload 'cider-connect-cljs "cider" "\ Initialize a ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and -:cljs-repl-type (e.g. Node, Figwheel, etc). On prefix, prompt for all the -parameters regardless of their supplied or default values. +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). -\(fn &optional PARAMS)" t nil) +On prefix, prompt for all the +parameters regardless of their supplied or default values. +(fn &optional PARAMS)" t) (autoload 'cider-connect-clj&cljs "cider" "\ Initialize a Clojure and ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and -:cljs-repl-type (e.g. Node, Figwheel, etc). When SOFT-CLJS-START is +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). When SOFT-CLJS-START is non-nil, don't start if ClojureScript requirements are not met. -\(fn PARAMS &optional SOFT-CLJS-START)" t nil) - +(fn PARAMS &optional SOFT-CLJS-START)" t) (autoload 'cider "cider" "\ -Start a connection of any type interactively." t nil) - +Start a connection of any type interactively." t) (defalias 'cider-jack-in #'cider-jack-in-clj) - (defalias 'cider-connect #'cider-connect-clj) - (autoload 'cider-jack-in-universal "cider" "\ Start and connect to an nREPL server for the current project or ARG project id. @@ -108,15 +107,16 @@ For example, to jack in to leiningen which is assigned to prefix arg 2 type M-2 \\[cider-jack-in-universal]. -\(fn ARG)" t nil) - -(with-eval-after-load 'clojure-mode (define-key clojure-mode-map (kbd "C-c M-x") #'cider) (define-key clojure-mode-map (kbd "C-c M-j") #'cider-jack-in-clj) (define-key clojure-mode-map (kbd "C-c M-J") #'cider-jack-in-cljs) (define-key clojure-mode-map (kbd "C-c M-c") #'cider-connect-clj) (define-key clojure-mode-map (kbd "C-c M-C") #'cider-connect-cljs) (define-key clojure-mode-map (kbd "C-c C-x") 'cider-start-map) (define-key clojure-mode-map (kbd "C-c C-s") 'sesman-map) (require 'sesman) (sesman-install-menu clojure-mode-map) (add-hook 'clojure-mode-hook (lambda nil (setq-local sesman-system 'CIDER)))) +(fn ARG)" t) +(autoload 'cider--setup-clojure-major-mode "cider" "\ +Setup Cider key bindings on a Clojure mode's MODE-MAP and hooks in MODE-HOOK. +(fn MODE-MAP MODE-HOOK)") +(with-eval-after-load 'clojure-mode (cider--setup-clojure-major-mode clojure-mode-map 'clojure-mode-hook)) +(with-eval-after-load 'clojure-ts-mode (cider--setup-clojure-major-mode (with-suppressed-warnings ((free-vars clojure-ts-mode-map)) clojure-ts-mode-map) 'clojure-ts-mode-hook)) (register-definition-prefixes "cider" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-apropos" "cider-apropos.el" (0 0 0 0)) ;;; Generated autoloads from cider-apropos.el (autoload 'cider-apropos "cider-apropos" "\ @@ -125,13 +125,11 @@ QUERY can also be a list of space-separated words (e.g. take while) which will be converted to a regular expression (like take.+while) automatically behind the scenes. The search may be limited to the namespace NS, and may optionally search doc strings (based on DOCS-P), include private vars -\(based on PRIVATES-P), and be case-sensitive (based on CASE-SENSITIVE-P). - -\(fn QUERY &optional NS DOCS-P PRIVATES-P CASE-SENSITIVE-P)" t nil) +(based on PRIVATES-P), and be case-sensitive (based on CASE-SENSITIVE-P). +(fn QUERY &optional NS DOCS-P PRIVATES-P CASE-SENSITIVE-P)" t) (autoload 'cider-apropos-documentation "cider-apropos" "\ -Shortcut for (cider-apropos nil t)." t nil) - +Shortcut for (cider-apropos nil t)." t) (autoload 'cider-apropos-select "cider-apropos" "\ Similar to `cider-apropos', but presents the results in a completing read. Show all symbols whose names match QUERY, a regular expression. @@ -139,90 +137,68 @@ QUERY can also be a list of space-separated words (e.g. take while) which will be converted to a regular expression (like take.+while) automatically behind the scenes. The search may be limited to the namespace NS, and may optionally search doc strings (based on DOCS-P), include private vars -\(based on PRIVATES-P), and be case-sensitive (based on CASE-SENSITIVE-P). - -\(fn QUERY &optional NS DOCS-P PRIVATES-P CASE-SENSITIVE-P)" t nil) +(based on PRIVATES-P), and be case-sensitive (based on CASE-SENSITIVE-P). +(fn QUERY &optional NS DOCS-P PRIVATES-P CASE-SENSITIVE-P)" t) (autoload 'cider-apropos-documentation-select "cider-apropos" "\ -Shortcut for (cider-apropos-select nil t)." t nil) - +Shortcut for (cider-apropos-select nil t)." t) (register-definition-prefixes "cider-apropos" '("apropos-special-form" "cider-")) -;;;*** -;;;### (autoloads nil "cider-browse-ns" "cider-browse-ns.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from cider-browse-ns.el (autoload 'cider-browse-ns "cider-browse-ns" "\ List all NAMESPACE's vars in BUFFER. -\(fn NAMESPACE)" t nil) - +(fn NAMESPACE)" t) (autoload 'cider-browse-ns-all "cider-browse-ns" "\ -List all loaded namespaces in BUFFER." t nil) - +List all loaded namespaces in BUFFER." t) (register-definition-prefixes "cider-browse-ns" '("cider-browse-ns-")) -;;;*** -;;;### (autoloads nil "cider-browse-spec" "cider-browse-spec.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from cider-browse-spec.el (autoload 'cider-browse-spec "cider-browse-spec" "\ Browse SPEC definition. -\(fn SPEC)" t nil) - +(fn SPEC)" t) (autoload 'cider-browse-spec-all "cider-browse-spec" "\ Open list of specs in a popup buffer. With a prefix argument ARG, prompts for a regexp to filter specs. No filter applied if the regexp is the empty string. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (register-definition-prefixes "cider-browse-spec" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-cheatsheet" "cider-cheatsheet.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from cider-cheatsheet.el -(autoload 'cider-cheatsheet "cider-cheatsheet" "\ -Navigate `cider-cheatsheet-hierarchy' with `completing-read'. +(autoload 'cider-cheatsheet-select "cider-cheatsheet" "\ +Navigate cheatsheet sections and show documentation for selected var. -When you make it to a Clojure var its doc buffer gets displayed." t nil) +With a prefix argument FLAT, represent each candidate as a full path to var. +(fn &optional FLAT)" t) +(autoload 'cider-cheatsheet "cider-cheatsheet" "\ +Display cheatsheet in a popup buffer." t) (register-definition-prefixes "cider-cheatsheet" '("cider-cheatsheet-")) -;;;*** -;;;### (autoloads nil "cider-classpath" "cider-classpath.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from cider-classpath.el (autoload 'cider-classpath "cider-classpath" "\ -List all classpath entries." t nil) - +List all classpath entries." t) (autoload 'cider-open-classpath-entry "cider-classpath" "\ -Open a classpath entry." t nil) - +Open a classpath entry." t) (register-definition-prefixes "cider-classpath" '("cider-classpath-")) -;;;*** -;;;### (autoloads nil "cider-client" "cider-client.el" (0 0 0 0)) ;;; Generated autoloads from cider-client.el (register-definition-prefixes "cider-client" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-clojuredocs" "cider-clojuredocs.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from cider-clojuredocs.el (autoload 'cider-clojuredocs-web "cider-clojuredocs" "\ @@ -232,11 +208,9 @@ Prompts for the symbol to use, or uses the symbol at point, depending on the value of `cider-prompt-for-symbol'. With prefix arg ARG, does the opposite of what that option dictates. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (autoload 'cider-clojuredocs-refresh-cache "cider-clojuredocs" "\ -Refresh the ClojureDocs cache." t nil) - +Refresh the ClojureDocs cache." t) (autoload 'cider-clojuredocs "cider-clojuredocs" "\ Open ClojureDocs documentation in a popup buffer. @@ -244,36 +218,30 @@ Prompts for the symbol to use, or uses the symbol at point, depending on the value of `cider-prompt-for-symbol'. With prefix arg ARG, does the opposite of what that option dictates. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (register-definition-prefixes "cider-clojuredocs" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-common" "cider-common.el" (0 0 0 0)) ;;; Generated autoloads from cider-common.el (register-definition-prefixes "cider-common" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-completion" "cider-completion.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from cider-completion.el (register-definition-prefixes "cider-completion" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-connection" "cider-connection.el" (0 -;;;;;; 0 0 0)) +;;; Generated autoloads from cider-completion-context.el + +(register-definition-prefixes "cider-completion-context" '("cider-completion-")) + + ;;; Generated autoloads from cider-connection.el (register-definition-prefixes "cider-connection" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-debug" "cider-debug.el" (0 0 0 0)) ;;; Generated autoloads from cider-debug.el (autoload 'cider-debug-defun-at-point "cider-debug" "\ @@ -283,34 +251,30 @@ immediately evaluate the instrumented expression. While debugged code is being evaluated, the user is taken through the source code and displayed the value of various expressions. At each step, -a number of keys will be prompted to the user." t nil) - +a number of keys will be prompted to the user." t) (register-definition-prefixes "cider-debug" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-doc" "cider-doc.el" (0 0 0 0)) ;;; Generated autoloads from cider-doc.el (register-definition-prefixes "cider-doc" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-eldoc" "cider-eldoc.el" (0 0 0 0)) +;;; Generated autoloads from cider-docstring.el + +(register-definition-prefixes "cider-docstring" '("cider-")) + + ;;; Generated autoloads from cider-eldoc.el (register-definition-prefixes "cider-eldoc" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-eval" "cider-eval.el" (0 0 0 0)) ;;; Generated autoloads from cider-eval.el (register-definition-prefixes "cider-eval" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-find" "cider-find.el" (0 0 0 0)) ;;; Generated autoloads from cider-find.el (autoload 'cider-find-var "cider-find" "\ @@ -321,13 +285,11 @@ A single or double prefix argument inverts the meaning of the results to be displayed in a different window. The default value is thing at point. -\(fn &optional ARG VAR LINE)" t nil) - +(fn &optional ARG VAR LINE)" t) (autoload 'cider-find-dwim-at-mouse "cider-find" "\ Find and display variable or resource at mouse EVENT. -\(fn EVENT)" t nil) - +(fn EVENT)" t) (autoload 'cider-find-dwim "cider-find" "\ Find and display the SYMBOL-FILE at point. SYMBOL-FILE could be a var or a resource. If thing at point is empty then @@ -338,8 +300,7 @@ inverts the meaning. A prefix of `-' or a double prefix argument causes the results to be displayed in a different window. A default value of thing at point is given when prompted. -\(fn SYMBOL-FILE)" t nil) - +(fn SYMBOL-FILE)" t) (autoload 'cider-find-resource "cider-find" "\ Find the resource at PATH. Prompt for input as indicated by the variable `cider-prompt-for-symbol'. @@ -348,21 +309,19 @@ A single or double prefix argument inverts the meaning of argument causes the results to be displayed in other window. The default value is thing at point. -\(fn PATH)" t nil) - +(fn PATH)" t) (autoload 'cider-find-ns "cider-find" "\ Find the file containing NS. A prefix ARG of `-` or a double prefix argument causes the results to be displayed in a different window. -\(fn &optional ARG NS)" t nil) - +(fn &optional ARG NS)" t) (autoload 'cider-find-keyword "cider-find" "\ -Find the namespace of the keyword at point and its first occurrence there. +Find the namespace of the keyword at point and its primary occurrence there. For instance - if the keyword at point is \":cider.demo/keyword\", this command -would find the namespace \"cider.demo\" and afterwards find the first mention -of \"::keyword\" there. +would find the namespace \"cider.demo\" and afterwards find the primary (most relevant or first) +mention of \"::keyword\" there. Prompt according to prefix ARG and `cider-prompt-for-symbol'. A single or double prefix argument inverts the meaning of @@ -370,96 +329,87 @@ A single or double prefix argument inverts the meaning of the results to be displayed in a different window. The default value is thing at point. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (register-definition-prefixes "cider-find" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-format" "cider-format.el" (0 0 0 0)) ;;; Generated autoloads from cider-format.el (autoload 'cider-format-region "cider-format" "\ Format the Clojure code in the current region. START and END represent the region's boundaries. -\(fn START END)" t nil) - +(fn START END)" t) (autoload 'cider-format-defun "cider-format" "\ -Format the code in the current defun." t nil) - +Format the code in the current defun." t) (autoload 'cider-format-buffer "cider-format" "\ -Format the Clojure code in the current buffer." t nil) - +Format the Clojure code in the current buffer." t) (autoload 'cider-format-edn-buffer "cider-format" "\ -Format the EDN data in the current buffer." t nil) - +Format the EDN data in the current buffer." t) (autoload 'cider-format-edn-region "cider-format" "\ Format the EDN data in the current region. START and END represent the region's boundaries. -\(fn START END)" t nil) - +(fn START END)" t) (autoload 'cider-format-edn-last-sexp "cider-format" "\ -Format the EDN data of the last sexp." t nil) - +Format the EDN data of the last sexp." t) (register-definition-prefixes "cider-format" '("cider--format-")) -;;;*** -;;;### (autoloads nil "cider-inspector" "cider-inspector.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from cider-inspector.el (autoload 'cider-inspect-last-sexp "cider-inspector" "\ -Inspect the result of the the expression preceding point." t nil) - +Inspect the result of the the expression preceding point." t) (autoload 'cider-inspect-defun-at-point "cider-inspector" "\ -Inspect the result of the \"top-level\" expression at point." t nil) - +Inspect the result of the \"top-level\" expression at point." t) (autoload 'cider-inspect-last-result "cider-inspector" "\ -Inspect the most recent eval result." t nil) - +Inspect the most recent eval result." t) (autoload 'cider-inspect "cider-inspector" "\ Inspect the result of the preceding sexp. With a prefix argument ARG it inspects the result of the \"top-level\" form. With a second prefix argument it prompts for an expression to eval and inspect. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (autoload 'cider-inspect-expr "cider-inspector" "\ Evaluate EXPR in NS and inspect its value. Interactively, EXPR is read from the minibuffer, and NS the current buffer's namespace. -\(fn EXPR NS)" t nil) +(fn EXPR NS)" t) +(autoload 'cider-sync-request:inspect-last-exception "cider-inspector" "\ +Inspects the exception in the cause stack identified by INDEX, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry. +(fn INDEX &optional V2)") (register-definition-prefixes "cider-inspector" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-jar" "cider-jar.el" (0 0 0 0)) ;;; Generated autoloads from cider-jar.el (register-definition-prefixes "cider-jar" '("cider-jar-")) -;;;*** -;;;### (autoloads nil "cider-log" "cider-log.el" (0 0 0 0)) ;;; Generated autoloads from cider-log.el + + (autoload 'cider-log-info "cider-log-info" "Show the Cider log current log buffer, framework, appender and consumer." t) (autoload 'cider-log-framework "cider-log" "Show the Cider log framework menu." t) (autoload 'cider-log-appender "cider-log" "Show the Cider log appender menu." t) (autoload 'cider-log-consumer "cider-log" "Show the Cider log consumer menu." t) (autoload 'cider-log-event "cider-log" "Show the Cider log event menu." t) - (autoload 'cider-log "cider-log" "Show the Cider log menu." t) +(autoload 'cider-log-show "cider-log" "\ +Ensures the *cider-log* buffer is visible, +setting up a framework, appender and consumer if necessary. + +Honors the `cider-log-framework-name' customization variable. +This function is offered as an alternative to workflows +based on `transient-mode'." t) + (autoload 'cider-log "cider-log" "Show the Cider log menu." t) (register-definition-prefixes "cider-log" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-macroexpansion" "cider-macroexpansion.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from cider-macroexpansion.el (autoload 'cider-macroexpand-1 "cider-macroexpansion" "\ @@ -467,16 +417,12 @@ Invoke \\=`macroexpand-1\\=` on the expression preceding point. If invoked with a PREFIX argument, use \\=`macroexpand\\=` instead of \\=`macroexpand-1\\=`. -\(fn &optional PREFIX)" t nil) - +(fn &optional PREFIX)" t) (autoload 'cider-macroexpand-all "cider-macroexpansion" "\ -Invoke \\=`macroexpand-all\\=` on the expression preceding point." t nil) - +Invoke \\=`macroexpand-all\\=` on the expression preceding point." t) (register-definition-prefixes "cider-macroexpansion" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-mode" "cider-mode.el" (0 0 0 0)) ;;; Generated autoloads from cider-mode.el (defvar cider-mode-line '(:eval (format " cider[%s]" (cider--modeline-info))) "\ @@ -489,37 +435,39 @@ about mode line templates. Customize this variable to change how cider mode displays its status in the mode line. The default value displays the current connection. Set this variable to nil to disable the mode line entirely.") - (custom-autoload 'cider-mode-line "cider-mode" t) +(autoload 'cider--setup-menu-for-clojure-major-mode "cider-mode" "\ +Setup a Cider menu for a Clojure major mode's MODE-MAP. -(with-eval-after-load 'clojure-mode (easy-menu-define cider-clojure-mode-menu-open clojure-mode-map "Menu for Clojure mode.\n This is displayed in `clojure-mode' buffers, if `cider-mode' is not active." `("CIDER" :visible (not cider-mode) ["Start a Clojure REPL" cider-jack-in-clj :help "Starts an nREPL server and connects a Clojure REPL to it."] ["Connect to a Clojure REPL" cider-connect-clj :help "Connects to a REPL that's already running."] ["Start a ClojureScript REPL" cider-jack-in-cljs :help "Starts an nREPL server and connects a ClojureScript REPL to it."] ["Connect to a ClojureScript REPL" cider-connect-cljs :help "Connects to a ClojureScript REPL that's already running."] ["Start a Clojure REPL, and a ClojureScript REPL" cider-jack-in-clj&cljs :help "Starts an nREPL server, connects a Clojure REPL to it, and then a ClojureScript REPL."] "--" ["View user manual" cider-view-manual]))) +This menu works as an easy entry-point into CIDER. Even if cider.el isn't +loaded yet, this will be shown in Clojure buffers next to the Clojure menu. +(fn MODE-MAP)") +(with-eval-after-load 'clojure-mode (cider--setup-menu-for-clojure-major-mode clojure-mode-map)) +(with-eval-after-load 'clojure-ts-mode (cider--setup-menu-for-clojure-major-mode (with-suppressed-warnings ((free-vars clojure-ts-mode-map)) clojure-ts-mode-map))) (autoload 'cider-mode "cider-mode" "\ Minor mode for REPL interaction from a Clojure buffer. -This is a minor mode. If called interactively, toggle the `Cider -mode' mode. If the prefix argument is positive, enable the mode, -and if it is zero or negative, disable the mode. - -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +\\{cider-mode-map} -To check whether the minor mode is enabled in the current buffer, -evaluate `cider-mode'. +This is a minor mode. If called interactively, toggle the `Cider mode' +mode. If the prefix argument is positive, enable the mode, and if it is +zero or negative, disable the mode. -The mode's hook is called both when the mode is enabled and when -it is disabled. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. -\\{cider-mode-map} +To check whether the minor mode is enabled in the current buffer, +evaluate the variable `cider-mode'. -\(fn &optional ARG)" t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (register-definition-prefixes "cider-mode" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-ns" "cider-ns.el" (0 0 0 0)) ;;; Generated autoloads from cider-ns.el (autoload 'cider-ns-reload "cider-ns" "\ @@ -531,8 +479,7 @@ org.clojure/tools.namespace. See Commentary of this file for a longer list of differences. From the Clojure doc: \":reload forces loading of all the identified libs even if they are already loaded\". -\(fn &optional PROMPT)" t nil) - +(fn &optional PROMPT)" t) (autoload 'cider-ns-reload-all "cider-ns" "\ Send a (require 'ns :reload-all) to the REPL. @@ -543,13 +490,13 @@ of differences. From the Clojure doc: \":reload-all implies :reload and also forces loading of all libs that the identified libs directly or indirectly load via require\". -\(fn &optional PROMPT)" t nil) - +(fn &optional PROMPT)" t) (autoload 'cider-ns-refresh "cider-ns" "\ -Reload modified and unloaded namespaces on the classpath. +Reload modified and unloaded namespaces, using the Reloaded Workflow. +Uses the configured 'refresh dirs' (defaults to the classpath dirs). With a single prefix argument, or if MODE is `refresh-all', reload all -namespaces on the classpath unconditionally. +namespaces on the classpath dirs unconditionally. With a double prefix argument, or if MODE is `clear', clear the state of the namespace tracker before reloading. This is useful for recovering from @@ -562,111 +509,82 @@ With a negative prefix argument, or if MODE is `inhibit-fns', prevent any refresh functions (defined in `cider-ns-refresh-before-fn' and `cider-ns-refresh-after-fn') from being invoked. -\(fn &optional MODE)" t nil) - +(fn &optional MODE)" t) (register-definition-prefixes "cider-ns" '("cider-ns-")) -;;;*** -;;;### (autoloads nil "cider-overlays" "cider-overlays.el" (0 0 0 -;;;;;; 0)) ;;; Generated autoloads from cider-overlays.el (register-definition-prefixes "cider-overlays" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-popup" "cider-popup.el" (0 0 0 0)) ;;; Generated autoloads from cider-popup.el (register-definition-prefixes "cider-popup" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-profile" "cider-profile.el" (0 0 0 0)) ;;; Generated autoloads from cider-profile.el (autoload 'cider-profile-samples "cider-profile" "\ Displays current max-sample-count. If optional QUERY is specified, set max-sample-count and display new value. -\(fn &optional QUERY)" t nil) - +(fn &optional QUERY)" t) (autoload 'cider-profile-var-profiled-p "cider-profile" "\ Displays the profiling status of var under point. Prompts for var if none under point or QUERY is present. -\(fn QUERY)" t nil) - +(fn QUERY)" t) (autoload 'cider-profile-ns-toggle "cider-profile" "\ Toggle profiling for the ns associated with optional QUERY. If optional argument QUERY is non-nil, prompt for ns. Otherwise use current ns. -\(fn &optional QUERY)" t nil) - +(fn &optional QUERY)" t) (autoload 'cider-profile-toggle "cider-profile" "\ Toggle profiling for the given QUERY. Defaults to the symbol at point. With prefix arg or no symbol at point, prompts for a var. -\(fn QUERY)" t nil) - +(fn QUERY)" t) (autoload 'cider-profile-summary "cider-profile" "\ -Display a summary of currently collected profile data." t nil) - +Display a summary of currently collected profile data." t) (autoload 'cider-profile-var-summary "cider-profile" "\ Display profile data for var under point QUERY. Defaults to the symbol at point. With prefix arg or no symbol at point, prompts for a var. -\(fn QUERY)" t nil) - +(fn QUERY)" t) (autoload 'cider-profile-clear "cider-profile" "\ -Clear any collected profile data." t nil) - +Clear any collected profile data." t) (register-definition-prefixes "cider-profile" '("cider-profile-")) -;;;*** -;;;### (autoloads nil "cider-repl" "cider-repl.el" (0 0 0 0)) ;;; Generated autoloads from cider-repl.el (register-definition-prefixes "cider-repl" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-repl-history" "cider-repl-history.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from cider-repl-history.el (autoload 'cider-repl-history "cider-repl-history" "\ -Display items in the CIDER command history in another buffer." t nil) - +Display items in the CIDER command history in another buffer." t) (register-definition-prefixes "cider-repl-history" '("cider-repl-history-")) -;;;*** -;;;### (autoloads nil "cider-resolve" "cider-resolve.el" (0 0 0 0)) ;;; Generated autoloads from cider-resolve.el (register-definition-prefixes "cider-resolve" '("cider-resolve-")) -;;;*** -;;;### (autoloads nil "cider-scratch" "cider-scratch.el" (0 0 0 0)) ;;; Generated autoloads from cider-scratch.el (autoload 'cider-scratch "cider-scratch" "\ -Go to the scratch buffer named `cider-scratch-buffer-name'." t nil) - +Go to the scratch buffer named `cider-scratch-buffer-name'." t) (register-definition-prefixes "cider-scratch" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-selector" "cider-selector.el" (0 0 0 -;;;;;; 0)) ;;; Generated autoloads from cider-selector.el (autoload 'cider-selector "cider-selector" "\ @@ -676,21 +594,15 @@ which to choose a new buffer. The `?' character describes the available methods. OTHER-WINDOW provides an optional target. See `def-cider-selector-method' for defining new methods. -\(fn &optional OTHER-WINDOW)" t nil) - -(register-definition-prefixes "cider-selector" '("??" "?c" "?d" "?e" "?m" "?p" "?q" "?r" "?s" "?x" "cider-selector-" "def-cider-selector-method")) +(fn &optional OTHER-WINDOW)" t) +(register-definition-prefixes "cider-selector" '("cider-selector-" "def-cider-selector-method")) -;;;*** -;;;### (autoloads nil "cider-stacktrace" "cider-stacktrace.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from cider-stacktrace.el (register-definition-prefixes "cider-stacktrace" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-test" "cider-test.el" (0 0 0 0)) ;;; Generated autoloads from cider-test.el (defvar cider-auto-test-mode nil "\ @@ -700,37 +612,32 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `cider-auto-test-mode'.") - (custom-autoload 'cider-auto-test-mode "cider-test" nil) - (autoload 'cider-auto-test-mode "cider-test" "\ Toggle automatic testing of Clojure files. -This is a minor mode. If called interactively, toggle the -`Cider-Auto-Test mode' mode. If the prefix argument is positive, -enable the mode, and if it is zero or negative, disable the mode. +When enabled this reruns tests every time a Clojure file is loaded. +Only runs tests corresponding to the loaded file's namespace and does +nothing if no tests are defined or if the file failed to load. + +This is a global minor mode. If called interactively, toggle the +`Cider-Auto-Test mode' mode. If the prefix argument is positive, enable +the mode, and if it is zero or negative, disable the mode. -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `(default-value \\='cider-auto-test-mode)'. -The mode's hook is called both when the mode is enabled and when -it is disabled. - -When enabled this reruns tests every time a Clojure file is loaded. -Only runs tests corresponding to the loaded file's namespace and does -nothing if no tests are defined or if the file failed to load. - -\(fn &optional ARG)" t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (register-definition-prefixes "cider-test" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-tracing" "cider-tracing.el" (0 0 0 0)) ;;; Generated autoloads from cider-tracing.el (autoload 'cider-toggle-trace-var "cider-tracing" "\ @@ -739,77 +646,67 @@ Prompts for the symbol to use, or uses the symbol at point, depending on the value of `cider-prompt-for-symbol'. With prefix arg ARG, does the opposite of what that option dictates. -\(fn ARG)" t nil) - +(fn ARG)" t) (autoload 'cider-toggle-trace-ns "cider-tracing" "\ Toggle ns tracing. Defaults to the current ns. With prefix arg QUERY, prompts for a ns. -\(fn QUERY)" t nil) - +(fn QUERY)" t) (register-definition-prefixes "cider-tracing" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-util" "cider-util.el" (0 0 0 0)) ;;; Generated autoloads from cider-util.el (autoload 'cider-view-manual "cider-util" "\ -View the manual in your default browser." t nil) - +View the manual in your default browser." t) (register-definition-prefixes "cider-util" '("cider-")) -;;;*** -;;;### (autoloads nil "cider-xref" "cider-xref.el" (0 0 0 0)) ;;; Generated autoloads from cider-xref.el (autoload 'cider-xref-fn-refs "cider-xref" "\ Show all functions that reference the var matching NS and SYMBOL. -\(fn &optional NS SYMBOL)" t nil) - +(fn &optional NS SYMBOL)" t) (autoload 'cider-xref-fn-deps "cider-xref" "\ Show all functions referenced by the var matching NS and SYMBOL. -\(fn &optional NS SYMBOL)" t nil) - +(fn &optional NS SYMBOL)" t) (autoload 'cider-xref-fn-refs-select "cider-xref" "\ Displays the references for NS and SYMBOL using completing read. -\(fn &optional NS SYMBOL)" t nil) - +(fn &optional NS SYMBOL)" t) (autoload 'cider-xref-fn-deps-select "cider-xref" "\ Displays the function dependencies for NS and SYMBOL using completing read. -\(fn &optional NS SYMBOL)" t nil) - +(fn &optional NS SYMBOL)" t) (register-definition-prefixes "cider-xref" '("cider-")) -;;;*** -;;;### (autoloads nil "nrepl-client" "nrepl-client.el" (0 0 0 0)) +;;; Generated autoloads from cider-xref-backend.el + +(register-definition-prefixes "cider-xref-backend" '("cider--")) + + ;;; Generated autoloads from nrepl-client.el (register-definition-prefixes "nrepl-client" '("cider-" "emacs-bug-46284/when-27.1-windows-nt" "nrepl-")) -;;;*** -;;;### (autoloads nil "nrepl-dict" "nrepl-dict.el" (0 0 0 0)) ;;; Generated autoloads from nrepl-dict.el (register-definition-prefixes "nrepl-dict" '("nrepl-")) - -;;;*** -;;;### (autoloads nil nil ("cider-pkg.el") (0 0 0 0)) +;;; End of scraped data + +(provide 'cider-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; cider-autoloads.el ends here diff --git a/elpa/cider-20230707.640/cider-browse-ns.el b/elpa/cider-20241203.1607/cider-browse-ns.el similarity index 99% rename from elpa/cider-20230707.640/cider-browse-ns.el rename to elpa/cider-20241203.1607/cider-browse-ns.el index 88811fdb..4e9e6be7 100644 --- a/elpa/cider-20230707.640/cider-browse-ns.el +++ b/elpa/cider-20241203.1607/cider-browse-ns.el @@ -1,6 +1,6 @@ ;;; cider-browse-ns.el --- CIDER namespace browser -*- lexical-binding: t; -*- -;; Copyright © 2014-2023 John Andrews, Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 John Andrews, Bozhidar Batsov and CIDER contributors ;; Author: John Andrews diff --git a/elpa/cider-20230707.640/cider-browse-spec.el b/elpa/cider-20241203.1607/cider-browse-spec.el similarity index 99% rename from elpa/cider-20230707.640/cider-browse-spec.el rename to elpa/cider-20241203.1607/cider-browse-spec.el index 0ccf2390..7163a25f 100644 --- a/elpa/cider-20230707.640/cider-browse-spec.el +++ b/elpa/cider-20241203.1607/cider-browse-spec.el @@ -1,6 +1,6 @@ ;;; cider-browse-spec.el --- CIDER spec browser -*- lexical-binding: t; -*- -;; Copyright © 2017-2023 Juan Monetta, Bozhidar Batsov and CIDER contributors +;; Copyright © 2017-2024 Juan Monetta, Bozhidar Batsov and CIDER contributors ;; Author: Juan Monetta diff --git a/elpa/cider-20241203.1607/cider-cheatsheet.el b/elpa/cider-20241203.1607/cider-cheatsheet.el new file mode 100644 index 00000000..fbc07dad --- /dev/null +++ b/elpa/cider-20241203.1607/cider-cheatsheet.el @@ -0,0 +1,640 @@ +;;; cider-cheatsheet.el --- Quick reference for Clojure -*- lexical-binding: t -*- + +;; Copyright © 2019-2024 Kris Jenkins, Bozhidar Batsov and CIDER contributors +;; +;; Author: Kris Jenkins +;; Kato Muso + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; A quick reference system for Clojure. Fast, searchable & available offline. + +;;; Code: + +(require 'cider-doc) +(require 'cl-lib) +(require 'map) +(require 'seq) +(require 'subr-x) + +(defgroup cider-cheatsheet nil + "Clojure cheatsheet in CIDER." + :prefix "cider-cheatsheet-" + :group 'cider) + +(defconst cider-cheatsheet-buffer "*cider-cheatsheet*") + +(defcustom cider-cheatsheet-auto-select-buffer t + "Whether to auto-select the cheatsheet popup buffer." + :type 'boolean + :package-version '(cider . "1.15.0")) + +(defcustom cider-cheatsheet-default-action-function #'cider-doc-lookup + "Function to use on a var when it is selected. + +By default, documentation for a var is displayed using `cider-doc-lookup`, +but it can also be set to `cider-clojuredocs-lookup` to show documentation +from ClojureDocs or any other function accepting a var as an argument." + :type '(choice (const cider-doc-lookup) + (const cider-clojuredocs-lookup) + function) + :package-version '(cider . "1.15.0")) + +(defconst cider-cheatsheet-hierarchy + '(("Documentation" + ("REPL" + (clojure.repl doc find-doc apropos dir source pst) + (clojure.java.javadoc javadoc))) + ("Primitives" + ("Numbers" + ("Arithmetic" + (clojure.core + - * / quot rem mod inc dec max min abs) + (clojure.math floor-div floor-mod ceil floor rint round pow sqrt cbrt E exp expm1 log log10 log1p PI sin cos tan asin acos atan atan2)) + ("Arbitrary Precision Arithmetic" + (clojure.core +\' -\' *\' inc\' dec\')) + ("Compare" + (clojure.core == < > <= >= compare)) + ("Bitwise" + (clojure.core bit-and bit-or bit-xor bit-not bit-flip bit-set bit-shift-right bit-shift-left bit-and-not bit-clear bit-test unsigned-bit-shift-right)) + ("Cast" + (clojure.core byte short int long float double bigdec bigint num rationalize biginteger)) + ("Test" + (clojure.core zero? pos? neg? even? odd? number? rational? integer? ratio? decimal? float? double? int? nat-int? neg-int? pos-int? NaN? infinite?)) + ("Random" + (clojure.core rand rand-int) + (clojure.math random)) + ("BigDecimal" + (clojure.core with-precision)) + ("Unchecked" + (clojure.core *unchecked-math* unchecked-add unchecked-dec unchecked-inc unchecked-multiply unchecked-negate unchecked-subtract)) + ("Ratios" + (clojure.core numerator denominator ratio?))) + ("Strings" + ("Create" + (clojure.core str format)) + ("Use" + (clojure.core count get subs compare parse-boolean parse-double parse-long parse-uuid) + (clojure.string join escape split split-lines replace replace-first reverse index-of last-index-of)) + ("Regex" + (clojure.core re-find re-seq re-matches re-pattern re-matcher re-groups) + (clojure.string replace replace-first re-quote-replacement)) + ("Letters" + (clojure.string capitalize lower-case upper-case)) + ("Trim" + (clojure.string trim trim-newline triml trimr)) + ("Test" + (clojure.core string?) + (clojure.string blank? starts-with? ends-with? includes?))) + ("Other" + ("Characters" + (clojure.core char char? char-name-string char-escape-string)) + ("Keywords" + (clojure.core keyword keyword? find-keyword)) + ("Symbols" + (clojure.core symbol symbol? gensym)))) + ("Collections" + ("Generic ops" + (clojure.core count empty not-empty into conj bounded-count)) + ("Tree walking" + (clojure.walk walk prewalk prewalk-demo prewalk-replace postwalk postwalk-demo postwalk-replace keywordize-keys stringify-keys)) + ("Content tests" + (clojure.core distinct? empty? every? not-every? some not-any?)) + ("Capabilities" + (clojure.core sequential? associative? sorted? counted? reversible?)) + ("Type tests" + (clojure.core coll? list? vector? set? map? seq? record? map-entry?)) + ("Lists" + ("Create" + (clojure.core list list*)) + ("Examine" + (clojure.core first nth peek)) + ("Change" + (clojure.core cons conj rest pop))) + ("Vectors" + ("Create" + (clojure.core vector vec vector-of mapv filterv)) + ("Examine" + (clojure.core nth get peek)) + ("Change" + (clojure.core assoc assoc-in pop subvec replace conj rseq update update-in)) + ("Ops" + (clojure.core reduce-kv))) + ("Sets" + ("Create unsorted" + (clojure.core set hash-set)) + ("Create sorted" + (clojure.core sorted-set sorted-set-by) + (clojure.data.avl sorted-set sorted-set-by) + (clojure.data.int-map int-set dense-int-set)) + ("Examine" + (clojure.core get contains?)) + ("Change" + (clojure.core conj disj)) + ("Set ops" + (clojure.set union difference intersection select)) + ("Test" + (clojure.set subset? superset?)) + ("Sorted sets" + (clojure.core rseq subseq rsubseq))) + ("Maps" + ("Create unsorted" + (clojure.core hash-map array-map zipmap bean frequencies group-by) + (clojure.set index)) + ("Create sorted" + (clojure.core sorted-map sorted-map-by) + (clojure.data.avl sorted-map sorted-map-by) + (clojure.data.priority-map priority-map) + (clojure.data.int-map int-map)) + ("Examine" + (clojure.core get get get-in contains? find keys vals)) + ("Change" + (clojure.core assoc assoc-in dissoc merge merge-with select-keys update update-in update-keys update-vals) + (clojure.set rename-keys map-invert)) + ("Ops" + (clojure.core reduce-kv)) + ("Entry" + (clojure.core key val)) + ("Sorted maps" + (clojure.core rseq subseq rsubseq))) + ("Queues" + ("Examine" + (clojure.core peek)) + ("Change" + (clojure.core conj pop))) + ("Relations" + ("Relational algebra" + (clojure.set join select project union difference intersection index rename))) + ("Transients" + ("Create" + (clojure.core transient persistent!)) + ("Change" + (clojure.core conj! pop! assoc! dissoc! disj!))) + ("Misc" + ("Compare" + (clojure.core = identical? not= not compare) + (clojure.data diff)) + ("Test" + (clojure.core true? false? instance? nil? some?))) + ("Hashes" + (clojure.core hash hash-ordered-coll hash-unordered-coll mix-collection-hash))) + ("Sequences" + ("Creating a Lazy Seq" + ("From collection" + (clojure.core seq vals keys rseq subseq rsubseq sequence)) + ("From producer fn" + (clojure.core lazy-seq repeatedly iterate iteration)) + ("From constant" + (clojure.core repeat range)) + ("From other" + (clojure.core file-seq line-seq resultset-seq re-seq tree-seq xml-seq iterator-seq enumeration-seq)) + ("From seq" + (clojure.core keep keep-indexed))) + ("Seq in, Seq out" + ("Get shorter" + (clojure.core distinct filter remove take-nth for dedupe random-sample)) + ("Get longer" + (clojure.core cons conj concat lazy-cat mapcat cycle interleave interpose)) + ("Tail-items" + (clojure.core rest nthrest next fnext nnext drop drop-while take-last for)) + ("Head-items" + (clojure.core take take-while butlast drop-last for)) + ("Change" + (clojure.core conj concat distinct flatten group-by partition partition-all partition-by split-at split-with filter remove replace shuffle)) + ("Rearrange" + (clojure.core reverse sort sort-by compare)) + ("Process items" + (clojure.core map pmap map-indexed mapcat for replace seque))) + ("Using a Seq" + ("Extract item" + (clojure.core first second last rest next ffirst nfirst fnext nnext nth nthnext rand-nth when-first max-key min-key)) + ("Construct coll" + (clojure.core zipmap into reduce reductions set vec into-array to-array-2d mapv filterv)) + ("Pass to fn" + (clojure.core apply)) + ("Search" + (clojure.core some filter)) + ("Force evaluation" + (clojure.core doseq dorun doall run!)) + ("Check for forced" + (clojure.core realized?)))) + ("Transducers" + ("Off the shelf" + (clojure.core map mapcat filter remove take take-while take-nth drop drop-while replace partition-by partition-all keep keep-indexed map-indexed distinct interpose cat dedupe random-sample halt-when)) + ("Create your own" + (clojure.core completing ensure-reduced unreduced)) + ("Use" + (clojure.core into sequence transduce eduction)) + ("Early termination" + (clojure.core reduced reduced? deref))) + ("Spec" + ("Operations" + (clojure.spec.alpha valid? conform unform explain explain-data explain-str explain-out form describe assert check-asserts check-asserts?)) + ("Generator ops" + (clojure.spec.alpha gen exercise exercise-fn)) + ("Defn & Registry" + (clojure.spec.alpha def fdef registry get-spec spec? spec with-gen)) + ("Logical" + (clojure.spec.alpha and or)) + ("Collection" + (clojure.spec.alpha coll-of map-of every every-kv keys merge)) + ("Regex" + (clojure.spec.alpha cat alt * + \? & keys*)) + ("Range" + (clojure.spec.alpha int-in inst-in double-in int-in-range? inst-in-range?)) + ("Other" + (clojure.spec.alpha nilable multi-spec fspec conformer)) + ("Custom explain" + (clojure.spec.alpha explain-printer *explain-out*)) + ("Predicates with test.check generators" + ("Numbers" + (clojure.core number? rational? integer? ratio? decimal? float? zero? double? int? nat-int? neg-int? pos-int?)) + ("Symbols, keywords" + (clojure.core keyword? symbol? ident? qualified-ident? qualified-keyword? qualified-symbol? simple-ident? simple-keyword? simple-symbol?)) + ("Scalars" + (clojure.core string? true? false? nil? some? boolean? bytes? inst? uri? uuid?)) + ("Collections" + (clojure.core list? map? set? vector? associative? coll? sequential? seq? empty? indexed? seqable?)) + ("Other" + (clojure.core any?)))) + ("IO" + ("To/from ..." + (clojure.core spit slurp)) + ("To *out*" + (clojure.core pr prn print printf println newline) + (clojure.pprint print-table)) + ("To writer" + (clojure.pprint pprint cl-format)) + ("To string" + (clojure.core format with-out-str pr-str prn-str print-str println-str)) + ("From *in*" + (clojure.core read-line) + (clojure.edn read) + (clojure.tools.reader.edn read)) + ("From reader" + (clojure.core line-seq) + (clojure.edn read) + (clojure.tools.reader.edn read)) + ("From string" + (clojure.core with-in-str) + (clojure.edn read-string) + (clojure.tools.reader.edn read-string)) + ("Open" + (clojure.core with-open) + (clojure.java.io reader writer input-stream output-stream)) + ("Misc" + (clojure.core flush file-seq *in* *out* *err*) + (clojure.java.io file copy delete-file resource as-file as-url as-relative-path make-parents)) + ("Data readers" + (clojure.core *data-readers* default-data-readers *default-data-reader-fn*)) + ("Tap" + (clojure.core tap> add-tap remove-tap)) + ("Interop" + (clojure.java.io make-writer make-reader make-output-stream make-input-stream))) + ("Functions" + ("Create" + (:special fn) + (clojure.core defn defn- definline identity constantly memfn comp complement partial juxt memoize fnil every-pred some-fn)) + ("Call" + (clojure.core apply -> ->> trampoline as-> cond-> cond->> some-> some->>)) + ("Test" + (clojure.core fn? ifn?))) + ("Abstractions" + ("Protocols" + ("Define" + (clojure.core defprotocol)) + ("Extend" + (clojure.core extend-type)) + ("Reify" + (clojure.core reify)) + ("Test" + (clojure.core satisfies? extends?)) + ("Other" + (clojure.core extend extend-protocol extenders))) + ("Records" + ("Define" + (clojure.core defrecord)) + ("Test" + (clojure.core record?))) + ("Types" + ("Define" + (clojure.core deftype)) + ("With methods" + (clojure.core deftype))) + ("Multimethods" + ("Define" + (clojure.core defmulti)) + ("Method define" + (clojure.core defmethod)) + ("Dispatch" + (clojure.core get-method methods)) + ("Remove" + (clojure.core remove-method remove-all-methods)) + ("Prefer" + (clojure.core prefer-method prefers)) + ("Relation" + (clojure.core derive underive isa? parents ancestors descendants make-hierarchy)))) + ("Macros" + ("Create" + (clojure.core defmacro definline)) + ("Debug" + (clojure.core macroexpand-1 macroexpand) + (clojure.walk macroexpand-all)) + ("Branch" + (clojure.core and or when when-not when-let when-first if-not if-let cond condp case when-some if-some)) + ("Loop" + (clojure.core for doseq dotimes while)) + ("Arrange" + (clojure.core .. doto -> ->> as-> cond-> cond->> some-> some->>)) + ("Scope" + (clojure.core binding locking time with-in-str with-local-vars with-open with-out-str with-precision with-redefs with-redefs-fn)) + ("Lazy" + (clojure.core lazy-cat lazy-seq delay)) + ("Doc" + (clojure.core assert comment) + (clojure.repl doc))) + ("Metadata" + (clojure.core meta with-meta vary-meta alter-meta! reset-meta! test) + (clojure.repl doc find-doc)) + ("Special Forms" + ("General" + (:special def if do let letfn quote var fn loop recur set! throw try monitor-enter monitor-exit)) + ("Binding Forms / Destructuring" + (:special let fn loop) + (clojure.core defn defmacro for doseq if-let when-let if-some when-some))) + ("Vars and global environment" + ("Def variants" + (:special def) + (clojure.core defn defn- definline defmacro defmethod defmulti defonce defrecord)) + ("Interned vars" + (clojure.core declare intern binding find-var) + (:special var)) + ("Var objects" + (clojure.core with-local-vars var-get var-set alter-var-root var? bound? thread-bound?)) + ("Var validators" + (clojure.core set-validator! get-validator))) + ("Namespaces" + ("Current" + (clojure.core *ns*)) + ("Create/Switch" + (clojure.core ns in-ns create-ns)) + ("Add" + (clojure.core alias import intern refer) + (:special def)) + ("Find" + (clojure.core all-ns find-ns)) + ("Examine" + (clojure.core ns-name ns-aliases ns-map ns-interns ns-publics ns-refers ns-imports)) + ("From symbol" + (clojure.core resolve ns-resolve namespace the-ns requiring-resolve)) + ("Remove" + (clojure.core ns-unalias ns-unmap remove-ns))) + ("Loading" + ("Load libs" + (clojure.core require use import refer)) + ("List loaded" + (clojure.core loaded-libs)) + ("Load misc" + (clojure.core load load-file load-reader load-string))) + ("Concurrency" + ("Atoms" + (clojure.core atom swap! reset! compare-and-set! swap-vals! reset-vals!)) + ("Futures" + (clojure.core future future-call future-done? future-cancel future-cancelled? future?)) + ("Threads" + (clojure.core bound-fn bound-fn* get-thread-bindings push-thread-bindings pop-thread-bindings thread-bound?)) + ("Volatiles" + (clojure.core volatile! vreset! vswap! volatile?)) + ("Misc" + (clojure.core locking pcalls pvalues pmap seque promise deliver)) + ("Refs and Transactions" + ("Create" + (clojure.core ref)) + ("Examine" + (clojure.core deref)) + ("Transaction" + (clojure.core sync dosync io!)) + ("In transaction" + (clojure.core ensure ref-set alter commute)) + ("Validators" + (clojure.core set-validator! get-validator)) + ("History" + (clojure.core ref-history-count ref-min-history ref-max-history))) + ("Agents and Asynchronous Actions" + ("Create" + (clojure.core agent)) + ("Examine" + (clojure.core agent-error)) + ("Change state" + (clojure.core send send-off restart-agent send-via set-agent-send-executor! set-agent-send-off-executor!)) + ("Block waiting" + (clojure.core await await-for)) + ("Ref validators" + (clojure.core set-validator! get-validator)) + ("Watchers" + (clojure.core add-watch remove-watch)) + ("Thread handling" + (clojure.core shutdown-agents)) + ("Error" + (clojure.core error-handler set-error-handler! error-mode set-error-mode!)) + ("Misc" + (clojure.core *agent* release-pending-sends)))) + ("Java Interoperation" + ("General" + (clojure.core .. doto bean comparator enumeration-seq import iterator-seq memfn class class? bases supers type gen-class gen-interface definterface) + (:special new set!)) + ("Cast" + (clojure.core boolean byte short char int long float double bigdec bigint num cast biginteger)) + ("Exceptions" + (:special throw try catch finally) + (clojure.repl pst) + (clojure.core ex-info ex-data Throwable->map StackTraceElement->vec ex-cause ex-message) + (clojure.main ex-triage ex-str err->msg report-error)) + ("Arrays" + ("Create" + (clojure.core make-array object-array boolean-array byte-array short-array char-array int-array long-array float-array double-array aclone to-array to-array-2d into-array)) + ("Use" + (clojure.core aget aset aset-boolean aset-byte aset-short aset-char aset-int aset-long aset-float aset-double alength amap areduce)) + ("Cast" + (clojure.core booleans bytes shorts chars ints longs floats doubles))) + ("Proxy" + ("Create" + (clojure.core proxy get-proxy-class construct-proxy init-proxy)) + ("Misc" + (clojure.core proxy-mappings proxy-super update-proxy)))) + ("Zippers" + ("Create" + (clojure.zip zipper seq-zip vector-zip xml-zip)) + ("Get loc" + (clojure.zip up down left right leftmost rightmost)) + ("Get seq" + (clojure.zip lefts rights path children)) + ("Change" + (clojure.zip make-node replace edit insert-child insert-left insert-right append-child remove)) + ("Move" + (clojure.zip next prev)) + ("Misc" + (clojure.zip root node branch? end?)) + ("XML" + (clojure.data.zip.xml attr attr= seq-test tag= text text= xml-> xml1->))) + ("Other" + ("XML" + (clojure.xml parse) + (clojure.core xml-seq)) + ("REPL" + (clojure.core *1 *2 *3 *e *print-dup* *print-length* *print-level* *print-meta* *print-readably*)) + ("Code" + (clojure.core *compile-files* *compile-path* *file* *warn-on-reflection* compile loaded-libs test)) + ("Misc" + (clojure.core eval force hash *clojure-version* clojure-version *command-line-args* random-uuid)) + ("Browser / Shell" + (clojure.java.browse browse-url) + (clojure.java.shell sh with-sh-dir with-sh-env)) + ("EDN" + (clojure.edn read read-string)) + ("Pretty Printing" + (clojure.pprint pprint print-table pp *print-right-margin*)) + ("Compiling Code & Class Generation" + (clojure.core *compile-files* *compile-path* *file* *warn-on-reflection* compile gen-class gen-interface loaded-libs test))) + ("Reader Conditionals" + (clojure.core reader-conditional reader-conditional? tagged-literal tagged-literal?)) + ("Unit Tests" + ("Defining" + (clojure.test deftest deftest- testing is are)) + ("Running" + (clojure.test run-tests run-all-tests test-vars)) + ("Fixtures" + (clojure.test use-fixtures join-fixtures compose-fixtures))) + ("Async" + ("Main" + (clojure.core.async go go-loop ! >!! chan put! take take! close! timeout offer! poll! promise-chan)) + ("Choice" + (clojure.core.async alt! alt!! alts! alts!! do-alts)) + ("Buffering" + (clojure.core.async buffer dropping-buffer sliding-buffer unblocking-buffer?)) + ("Pipelines" + (clojure.core.async pipeline pipeline-async pipeline-blocking)) + ("Threading" + (clojure.core.async thread thread-call)) + ("Mixing" + (clojure.core.async admix solo-mode mix unmix unmix-all toggle merge pipe unique)) + ("Multiples" + (clojure.core.async mult tap untap untap-all)) + ("Publish/Subscribe" + (clojure.core.async pub sub unsub unsub-all)) + ("Higher Order" + (clojure.core.async filter< filter> map map< map> mapcat< mapcat> partition partition-by reduce remove< remove> split)) + ("Pre-Populate" + (clojure.core.async into onto-chan to-chan)))) + "A data structure for Clojure cheatsheet information. + +It's a tree, where the head of each list determines the context of the rest +of the list. The head may be: + + - A string, in which case it's a (sub)heading for the rest of the items. + + - A symbol, in which case it's the Clojure namespace of the symbols that + follow it. + + - The keyword :special, in which case it's a Clojure special form + + - Any other keyword, in which case it's a typed item that will be passed + through. + +Note that some Clojure symbols appear in more than once. This is entirely +intentional. For instance, `map` belongs in the sections on collections +and transducers.") + +(defun cider-cheatsheet--expand-vars (list) + "Expand the symbols in LIST to fully-qualified var names. + +This list is supposed to have the following format: + + (my-ns var1 var2 var3)" + (let ((ns (car list)) + (vars (cdr list))) + (if (eq ns :special) + (mapcar #'symbol-name vars) + (mapcar (lambda (var) (format "%s/%s" ns var)) vars)))) + +(defun cider-cheatsheet--flatten-hierarchy (hierarchy &optional sections) + "Transform HIERARCHY to lists each representing a path with SECTIONS before var." + (seq-mapcat (lambda (node) + (if (stringp (car node)) + (cider-cheatsheet--flatten-hierarchy (cdr node) (cons (car node) sections)) + (mapcar (lambda (var) (reverse (cons var sections))) + (cider-cheatsheet--expand-vars node)))) + hierarchy)) + +;;;###autoload +(defun cider-cheatsheet-select (&optional flat) + "Navigate cheatsheet sections and show documentation for selected var. + +With a prefix argument FLAT, represent each candidate as a full path to var." + (interactive "P") + (if flat + (let* ((hierarchy (cider-cheatsheet--flatten-hierarchy cider-cheatsheet-hierarchy)) + (paths (mapcar (lambda (sections) (string-join sections " > ")) hierarchy)) + (path (completing-read "Select path: " paths)) + (var (car (last (split-string path " > "))))) + (funcall cider-cheatsheet-default-action-function var)) + (let ((hierarchy cider-cheatsheet-hierarchy)) + (while (stringp (caar hierarchy)) + (let* ((sections (mapcar #'car hierarchy)) + (section (completing-read "Select section: " sections))) + (setq hierarchy (map-elt hierarchy section)))) + (let* ((vars (seq-mapcat #'cider-cheatsheet--expand-vars hierarchy)) + (var (completing-read "Select var: " vars))) + (funcall cider-cheatsheet-default-action-function var))))) + +(cl-defun cider-cheatsheet--insert-hierarchy (hierarchy &optional (level 0)) + "Insert HIERARCHY with visual indentation for LEVEL." + (dolist (node hierarchy) + (if (stringp (car node)) + (progn + (insert (make-string (* level 2) ?\s) (car node) "\n") + (cider-cheatsheet--insert-hierarchy (cdr node) (1+ level))) + (dolist (var (cider-cheatsheet--expand-vars node)) + (insert (make-string (* level 2) ?\s)) + (insert-text-button var + 'var var + 'action (lambda (btn) + (funcall cider-cheatsheet-default-action-function + (button-get btn 'var))) + 'help-echo (format "Show documentation for %s" var)) + (insert "\n"))))) + +(defun cider-cheatsheet--buffer-contents () + "Generate cheatsheet buffer contents based on the cheatsheet hierarchy." + (with-temp-buffer + (cider-cheatsheet--insert-hierarchy cider-cheatsheet-hierarchy) + (buffer-string))) + +;;;###autoload +(defun cider-cheatsheet () + "Display cheatsheet in a popup buffer." + (interactive) + (with-current-buffer (cider-popup-buffer cider-cheatsheet-buffer + cider-cheatsheet-auto-select-buffer) + (read-only-mode -1) + (insert (cider-cheatsheet--buffer-contents)) + (read-only-mode 1) + (goto-char (point-min)))) + +(provide 'cider-cheatsheet) + +;;; cider-cheatsheet.el ends here diff --git a/elpa/cider-20230707.640/cider-classpath.el b/elpa/cider-20241203.1607/cider-classpath.el similarity index 98% rename from elpa/cider-20230707.640/cider-classpath.el rename to elpa/cider-20241203.1607/cider-classpath.el index 0b628eeb..3ebe8650 100644 --- a/elpa/cider-20230707.640/cider-classpath.el +++ b/elpa/cider-20241203.1607/cider-classpath.el @@ -1,6 +1,6 @@ ;;; cider-classpath.el --- Basic Java classpath browser -*- lexical-binding: t; -*- -;; Copyright © 2014-2023 Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 Bozhidar Batsov and CIDER contributors ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/elpa/cider-20230707.640/cider-client.el b/elpa/cider-20241203.1607/cider-client.el similarity index 89% rename from elpa/cider-20230707.640/cider-client.el rename to elpa/cider-20241203.1607/cider-client.el index d9975263..26b22299 100644 --- a/elpa/cider-20230707.640/cider-client.el +++ b/elpa/cider-20241203.1607/cider-client.el @@ -1,6 +1,6 @@ ;;; cider-client.el --- A layer of abstraction above low-level nREPL client code. -*- lexical-binding: t -*- -;; Copyright © 2013-2023 Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov ;; ;; Author: Bozhidar Batsov @@ -34,6 +34,7 @@ (require 'spinner) (require 'cider-connection) +(require 'cider-completion-context) (require 'cider-common) (require 'cider-util) (require 'nrepl-client) @@ -107,7 +108,7 @@ EVAL-BUFFER is the buffer where the spinner was started." ;;; Evaluation helpers (defun cider-ns-form-p (form) "Check if FORM is an ns form." - (string-match-p "^[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" form)) + (string-match-p "\\`[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" form)) (defun cider-ns-from-form (ns-form) "Get ns substring from NS-FORM." @@ -120,16 +121,19 @@ Useful for special buffers (e.g. REPL, doc buffers) that have to keep track of a namespace. This should never be set in Clojure buffers, as there the namespace should be extracted from the buffer's ns form.") -(defun cider-current-ns (&optional no-default) +(defun cider-current-ns (&optional no-default no-repl-check) "Return the current ns. The ns is extracted from the ns form for Clojure buffers and from `cider-buffer-ns' for all other buffers. If it's missing, use the current -REPL's ns, otherwise fall back to \"user\". When NO-DEFAULT is non-nil, it -will return nil instead of \"user\"." +REPL's ns, otherwise fall back to \"user\". +When NO-DEFAULT is non-nil, it will return nil instead of \"user\". +When NO-REPL-CHECK is non-nil, `cider-current-repl' will not be queried, +improving performance (at the possible cost of accuracy)." (or cider-buffer-ns - (clojure-find-ns) - (when-let* ((repl (cider-current-repl))) - (buffer-local-value 'cider-buffer-ns repl)) + (cider-get-ns-name) + (unless no-repl-check + (when-let* ((repl (cider-current-repl))) + (buffer-local-value 'cider-buffer-ns repl))) (if no-default nil "user"))) (defun cider-path-to-ns (relpath) @@ -470,6 +474,38 @@ itself is present." (with-current-buffer (cider-current-repl) nrepl-tooling-session)) +(declare-function ido-exit-minibuffer "ido" t) + +;; Not used anywhere, except in documentation as a suggestion for users. +(defmacro cider--with-temporary-ido-keys (UP DOWN &rest body) + "Temporarily define UP, DOWN keys for ido and execute BODY. + +This makes the UX for auto-completion more streamlined, +since one often wants to go to the next candidate (DOWN key) +without having to specify a Java class for the current candidate +\(because the current candidate may be irrelevant to the user)." + `(if (bound-and-true-p ido-common-completion-map) + (let ((original-up-binding (lookup-key ido-common-completion-map (kbd ,UP))) + (original-down-binding (lookup-key ido-common-completion-map (kbd ,DOWN)))) + (define-key ido-common-completion-map (kbd ,UP) (lambda () + (interactive) + (ido-exit-minibuffer))) + (define-key ido-common-completion-map (kbd ,DOWN) (lambda () + (interactive) + (ido-exit-minibuffer))) + (unwind-protect + (progn ,@body) + (define-key ido-common-completion-map (kbd ,UP) original-up-binding) + (define-key ido-common-completion-map (kbd ,DOWN) original-down-binding))) + ,@body)) + +(defun cider-class-choice-completing-read (prompt candidates) + "A completing read that can be customized with the `advice' mechanism, +forwarding PROMPT and CANDIDATES as-is. + +See also: `cider--with-temporary-ido-keys'." + (completing-read prompt candidates)) + (defun cider--var-choice (var-info) "Prompt to choose from among multiple VAR-INFO candidates, if required. This is needed only when the symbol queried is an unqualified host platform @@ -478,7 +514,7 @@ contain a `candidates' key, it is returned as is." (let ((candidates (nrepl-dict-get var-info "candidates"))) (if candidates (let* ((classes (nrepl-dict-keys candidates)) - (choice (completing-read "Member in class: " classes nil t)) + (choice (cider-class-choice-completing-read "Member in class: " classes)) (info (nrepl-dict-get candidates choice))) info) var-info))) @@ -512,20 +548,20 @@ Used only when the info nREPL middleware is not available." var-info)) (defun cider-var-info (var &optional all) - "Return VAR's info as an alist with list cdrs. + "Return info for VAR as an nREPL dict. When multiple matching vars are returned you'll be prompted to select one, unless ALL is truthy." (when (and var (not (string= var ""))) (let ((var-info (cond - ((cider-nrepl-op-supported-p "info") (cider-sync-request:info var)) + ((cider-nrepl-op-supported-p "info") (cider-sync-request:info var nil nil (cider-completion-get-context t))) ((cider-nrepl-op-supported-p "lookup") (cider-sync-request:lookup var)) (t (cider-fallback-eval:info var))))) (if all var-info (cider--var-choice var-info))))) (defun cider-member-info (class member) - "Return the CLASS MEMBER's info as an alist with list cdrs." + "Return info for MEMBER of CLASS as an nREPL dict." (when (and class member) - (cider-sync-request:info nil class member))) + (cider-sync-request:info nil class member (cider-completion-get-context t)))) ;;; Requests @@ -643,13 +679,14 @@ CONTEXT represents a completion context for compliment." nil 'abort-on-input)) -(defun cider-sync-request:info (symbol &optional class member) - "Send \"info\" op with parameters SYMBOL or CLASS and MEMBER." +(defun cider-sync-request:info (symbol &optional class member context) + "Send \"info\" op with parameters SYMBOL or CLASS and MEMBER, honor CONTEXT." (let ((var-info (thread-first `("op" "info" "ns" ,(cider-current-ns) ,@(when symbol `("sym" ,symbol)) ,@(when class `("class" ,class)) - ,@(when member `("member" ,member))) + ,@(when member `("member" ,member)) + ,@(when context `("context" ,context))) (cider-nrepl-send-sync-request (cider-current-repl))))) (if (member "no-info" (nrepl-dict-get var-info "status")) nil @@ -666,13 +703,14 @@ CONTEXT represents a completion context for compliment." nil (nrepl-dict-get var-info "info")))) -(defun cider-sync-request:eldoc (symbol &optional class member) - "Send \"eldoc\" op with parameters SYMBOL or CLASS and MEMBER." +(defun cider-sync-request:eldoc (symbol &optional class member context) + "Send \"eldoc\" op with parameters SYMBOL or CLASS and MEMBER, honor CONTEXT." (when-let* ((eldoc (thread-first `("op" "eldoc" "ns" ,(cider-current-ns) ,@(when symbol `("sym" ,symbol)) ,@(when class `("class" ,class)) - ,@(when member `("member" ,member))) + ,@(when member `("member" ,member)) + ,@(when context `("context" ,context))) (cider-nrepl-send-sync-request (cider-current-repl) 'abort-on-input)))) (if (member "no-eldoc" (nrepl-dict-get eldoc "status")) @@ -729,12 +767,29 @@ returned." (cider-nrepl-send-sync-request) (nrepl-dict-get "ns-vars"))) -(defun cider-sync-request:ns-path (ns) - "Get the path to the file containing NS." - (thread-first `("op" "ns-path" - "ns" ,ns) - (cider-nrepl-send-sync-request) - (nrepl-dict-get "path"))) +(defun cider-sync-request:ns-path (ns &optional favor-url) + "Get the path to the file containing NS, FAVOR-URL if specified. + +FAVOR-URL ensures a Java URL is returned. + +* This always is the case if the underlying runtime is JVM Clojure. +* For ClojureScript, the default is a resource name. + * This often cannot be open by `cider-find-file' + (unless there was already a buffer opening that file) + +Generally, you always want to FAVOR-URL. +The option is kept for backwards compatibility. + +Note that even when favoring a url, the url itself might be nil, +in which case we'll fall back to the resource name." + (unless ns + (error "No ns provided")) + (let ((response (cider-nrepl-send-sync-request `("op" "ns-path" + "ns" ,ns)))) + (nrepl-dbind-response response (path url) + (if (and favor-url url) + url + path)))) (defun cider-sync-request:ns-vars-with-meta (ns) "Get a map of the vars in NS to its metadata information." diff --git a/elpa/cider-20230707.640/cider-clojuredocs.el b/elpa/cider-20241203.1607/cider-clojuredocs.el similarity index 61% rename from elpa/cider-20230707.640/cider-clojuredocs.el rename to elpa/cider-20241203.1607/cider-clojuredocs.el index 3e51a075..bfe8800d 100644 --- a/elpa/cider-20230707.640/cider-clojuredocs.el +++ b/elpa/cider-20241203.1607/cider-clojuredocs.el @@ -1,6 +1,6 @@ ;;; cider-clojuredocs.el --- ClojureDocs integration -*- lexical-binding: t -*- -;; Copyright © 2014-2023 Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 Bozhidar Batsov and CIDER contributors ;; ;; Author: Bozhidar Batsov @@ -25,21 +25,22 @@ ;;; Code: +(require 'subr-x) +(require 'url-vars) + (require 'cider-client) (require 'cider-common) -(require 'subr-x) +(require 'cider-docstring) (require 'cider-popup) - +(require 'cider-util) (require 'nrepl-dict) -(require 'url-vars) - (defconst cider-clojuredocs-url "https://clojuredocs.org/") (defconst cider-clojuredocs-buffer "*cider-clojuredocs*") (defun cider-sync-request:clojuredocs-lookup (ns sym) - "Perform nREPL \"resource\" op with NS and SYM." + "Perform nREPL \"clojuredocs-lookup\" op with NS and SYM." (thread-first `("op" "clojuredocs-lookup" "ns" ,ns "sym" ,sym) @@ -108,49 +109,80 @@ opposite of what that option dictates." (goto-char (point-min)) (current-buffer))) +(defun cider-clojuredocs--insert-overview (dict) + "Insert \"Overview\" section based on data from DICT." + (insert (format "= %s/%s\n" + (nrepl-dict-get dict "ns") + (nrepl-dict-get dict "name"))) + (newline) + (when-let ((arglists (nrepl-dict-get dict "arglists"))) + (dolist (arglist arglists) + (insert (format " [%s]\n" arglist))) + (newline)) + (when-let* ((doc (nrepl-dict-get dict "doc")) + (doc (cider-docstring--format doc))) + (insert doc "\n") + (newline))) + +(defun cider-clojuredocs--insert-see-also (dict) + "Insert \"See Also\" section based on data from DICT." + (insert "== See Also\n") + (newline) + (if-let ((see-alsos (nrepl-dict-get dict "see-alsos"))) + (dolist (see-also see-alsos) + (insert "* ") + (insert-text-button see-also + 'sym see-also + 'action (lambda (btn) + (cider-clojuredocs-lookup (button-get btn 'sym))) + 'help-echo (format "Press Enter or middle click to jump to %s" see-also)) + (insert "\n")) + (insert "Not available\n")) + (newline)) + +(defun cider-clojuredocs--insert-examples (dict) + "Insert \"Examples\" section based on data from DICT." + (insert "== Examples\n") + (newline) + (if-let ((examples (nrepl-dict-get dict "examples"))) + (dolist (example examples) + (insert (cider-font-lock-as-clojure example) "\n") + (insert "-------------------------------------------------\n")) + (insert "Not available\n")) + (newline)) + +(defun cider-clojuredocs--insert-notes (dict) + "Insert \"Notes\" section based on data from DICT." + (insert "== Notes\n") + (newline) + (if-let ((notes (nrepl-dict-get dict "notes"))) + (dolist (note notes) + (insert note "\n") + (insert "-------------------------------------------------\n")) + (insert "Not available\n")) + (newline)) + (defun cider-clojuredocs--content (dict) "Generate a nice string from DICT." (with-temp-buffer - (insert "= " (nrepl-dict-get dict "ns") "/" (nrepl-dict-get dict "name") "\n\n") - (let ((arglists (nrepl-dict-get dict "arglists"))) - (dolist (arglist arglists) - (insert (format " [%s]\n" arglist))) - (insert "\n") - (insert (nrepl-dict-get dict "doc")) - (insert "\n")) - (insert "\n== See Also\n\n") - (if-let ((see-alsos (nrepl-dict-get dict "see-alsos"))) - (dolist (see-also see-alsos) - (insert-text-button (format "* %s\n" see-also) - 'sym see-also - 'action (lambda (btn) - (cider-clojuredocs-lookup (button-get btn 'sym))) - 'help-echo (format "Press Enter or middle click to jump to %s" see-also))) - (insert "Not available\n")) - (insert "\n== Examples\n\n") - (if-let ((examples (nrepl-dict-get dict "examples"))) - (dolist (example examples) - (insert (cider-font-lock-as-clojure example)) - (insert "\n-------------------------------------------------\n")) - (insert "Not available\n")) - (insert "\n== Notes\n\n") - (if-let ((notes (nrepl-dict-get dict "notes"))) - (dolist (note notes) - (insert note) - (insert "\n-------------------------------------------------\n")) - (insert "Not available\n")) + (cider-clojuredocs--insert-overview dict) + (cider-clojuredocs--insert-see-also dict) + (cider-clojuredocs--insert-examples dict) + (cider-clojuredocs--insert-notes dict) (buffer-string))) (defun cider-clojuredocs-lookup (sym) "Look up the ClojureDocs documentation for SYM." - (let ((docs (cider-sync-request:clojuredocs-lookup (cider-current-ns) sym))) - (pop-to-buffer (cider-create-clojuredocs-buffer (cider-clojuredocs--content docs))) - ;; highlight the symbol in question in the docs buffer - (highlight-regexp - (regexp-quote - (or (cadr (split-string sym "/")) - sym)) - 'bold))) + (if-let ((docs (cider-sync-request:clojuredocs-lookup (cider-current-ns) sym))) + (progn + (pop-to-buffer (cider-create-clojuredocs-buffer (cider-clojuredocs--content docs))) + ;; highlight the symbol in question in the docs buffer + (highlight-regexp + (regexp-quote + (or (cadr (split-string sym "/")) + sym)) + 'bold)) + (user-error "ClojureDocs documentation for %s is not found" sym))) ;;;###autoload (defun cider-clojuredocs (&optional arg) @@ -160,7 +192,7 @@ Prompts for the symbol to use, or uses the symbol at point, depending on the value of `cider-prompt-for-symbol'. With prefix arg ARG, does the opposite of what that option dictates." (interactive "P") - (when (derived-mode-p 'clojurescript-mode) + (when (cider-clojurescript-major-mode-p) (user-error "`cider-clojuredocs' doesn't support ClojureScript")) (funcall (cider-prompt-for-symbol-function arg) "ClojureDocs doc for" diff --git a/elpa/cider-20230707.640/cider-common.el b/elpa/cider-20241203.1607/cider-common.el similarity index 88% rename from elpa/cider-20230707.640/cider-common.el rename to elpa/cider-20241203.1607/cider-common.el index 90a7382a..f3e6582f 100644 --- a/elpa/cider-20230707.640/cider-common.el +++ b/elpa/cider-20241203.1607/cider-common.el @@ -1,6 +1,6 @@ ;;; cider-common.el --- Common use functions -*- lexical-binding: t; -*- -;; Copyright © 2015-2023 Artur Malabarba +;; Copyright © 2015-2024 Artur Malabarba ;; Author: Artur Malabarba @@ -84,12 +84,13 @@ INVERT inverts the semantics of the function `cider--should-prompt-for-symbol'." (declare-function cider-complete-at-point "cider-completion") (declare-function cider-eldoc "cider-eldoc") -(defun cider-read-from-minibuffer (prompt &optional value) +(defun cider-read-from-minibuffer (prompt &optional value skip-colon) "Read a string from the minibuffer, prompting with PROMPT. If VALUE is non-nil, it is inserted into the minibuffer as initial-input. -PROMPT need not end with \": \". If it doesn't, VALUE is displayed on the +PROMPT need not end with \": \". If it doesn't, VALUE is displayed on the prompt as a default value (used if the user doesn't type anything) and is -not used as initial input (input is left empty)." +not used as initial input (input is left empty). +If SKIP-COLON is non-nil, no \": \" is forced at the end of the prompt." (minibuffer-with-setup-hook (lambda () (set-syntax-table clojure-mode-syntax-table) @@ -100,6 +101,7 @@ not used as initial input (input is left empty)." (let* ((has-colon (string-match ": \\'" prompt)) (input (read-from-minibuffer (cond (has-colon prompt) + (skip-colon prompt) (value (format "%s (default %s): " prompt value)) (t (format "%s: " prompt))) (when has-colon value) ; initial-input @@ -226,8 +228,8 @@ create a valid path." (match-string 1 filename) filename))) -(defun cider-make-tramp-prefix (method user host) - "Constructs a Tramp file prefix from METHOD, USER, HOST. +(defun cider-make-tramp-prefix (method user host &optional port) + "Constructs a Tramp file prefix from METHOD, USER, HOST, PORT. It originated from Tramp's `tramp-make-tramp-file-name'. The original be forced to make full file name with `with-parsed-tramp-file-name', not providing prefix only option." @@ -240,6 +242,8 @@ prefix only option." (if (string-match tramp-ipv6-regexp host) (concat tramp-prefix-ipv6-format host tramp-postfix-ipv6-format) host)) + (when port + (concat "#" port)) tramp-postfix-host-format)) (defun cider-tramp-prefix (&optional buffer) @@ -253,7 +257,7 @@ if BUFFER is local." (when (tramp-tramp-file-p name) (with-parsed-tramp-file-name name v (with-no-warnings - (cider-make-tramp-prefix v-method v-user v-host)))))) + (cider-make-tramp-prefix v-method v-user v-host v-port)))))) (defun cider--client-tramp-filename (name &optional buffer) "Return the tramp filename for path NAME relative to BUFFER. @@ -284,22 +288,38 @@ in the container, the alist would be `((\"/src\" \"~/projects/foo/src\"))." :group 'cider :package-version '(cider . "0.23.0")) -(defun cider--translate-path (path direction) - "Attempt to translate the PATH in the given DIRECTION. +(defun cider--translate-path (path direction &optional return-all) + "Attempt to translate the PATH in the given DIRECTION, optionally RETURN-ALL. Looks at `cider-path-translations' for (container . host) alist of path prefixes and translates PATH from container to host or vice-versa depending on whether DIRECTION is 'from-nrepl or 'to-nrepl." (seq-let [from-fn to-fn path-fn] (cond ((eq direction 'from-nrepl) '(car cdr identity)) ((eq direction 'to-nrepl) '(cdr car expand-file-name))) - (let ((path (funcall path-fn path))) - (seq-some (lambda (translation) - (let ((prefix (file-name-as-directory (expand-file-name (funcall from-fn translation))))) - (when (string-prefix-p prefix path) - (replace-regexp-in-string (format "^%s" (regexp-quote prefix)) - (file-name-as-directory - (expand-file-name (funcall to-fn translation))) - path)))) - cider-path-translations)))) + (let ((f (lambda (translation) + (let ((path (funcall path-fn path)) + (prefix (file-name-as-directory (expand-file-name (funcall from-fn translation))))) + (when (string-prefix-p prefix path) + (replace-regexp-in-string (format "^%s" (regexp-quote prefix)) + (file-name-as-directory + (expand-file-name (funcall to-fn translation))) + path)))))) + (if return-all + (seq-filter #'identity (mapcar f cider-path-translations)) + (seq-some f cider-path-translations))))) + +(defun cider--all-path-translations () + "Returns `cider-path-translations' if non-empty, else seeks a present value." + (or cider-path-translations + ;; cider-path-translations often is defined as a directory-local variable, + ;; so after jumping to a .jar file, its value can be lost, + ;; so we have to figure out a possible translation: + (thread-last (buffer-list) + (seq-map (lambda (buffer) + (buffer-local-value 'cider-path-translations buffer))) + (seq-filter #'identity) + (seq-uniq) + (apply #'append) + (seq-uniq)))) (defun cider--translate-path-from-nrepl (path) "Attempt to translate the nREPL PATH to a local path." @@ -334,7 +354,12 @@ If no local or remote file exists, return nil." ((and tramp-path (file-exists-p tramp-path)) tramp-path) ((and local-path (file-exists-p local-path)) - local-path)))) + local-path) + (t + (when-let* ((cider-path-translations (cider--all-path-translations))) + (thread-last (cider--translate-path local-path 'from-nrepl :return-all) + (seq-filter #'file-exists-p) + car)))))) (declare-function archive-extract "arc-mode") (declare-function archive-zip-extract "arc-mode") diff --git a/elpa/cider-20241203.1607/cider-completion-context.el b/elpa/cider-20241203.1607/cider-completion-context.el new file mode 100644 index 00000000..3ebbf203 --- /dev/null +++ b/elpa/cider-20241203.1607/cider-completion-context.el @@ -0,0 +1,116 @@ +;;; cider-completion-context.el --- Context parsing -*- lexical-binding: t -*- + +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; +;; Author: Bozhidar Batsov +;; Artur Malabarba + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Context-parsing utilities. Extracted from cider-completion.el. + +;;; Code: + +(defcustom cider-completion-use-context t + "When true, uses context at point to improve completion suggestions." + :type 'boolean + :group 'cider + :package-version '(cider . "0.7.0")) + +(defun cider-completion--bounds-of-non-string-symbol-at-point () + "Returns the bounds of the symbol at point, unless it's inside a string." + (let ((sap (symbol-at-point))) + (when (and sap (not (nth 3 (syntax-ppss)))) + (bounds-of-thing-at-point 'symbol)))) + +(defun cider-completion-symbol-start-pos () + "Find the starting position of the symbol at point, unless inside a string." + (car (cider-completion--bounds-of-non-string-symbol-at-point))) + +(defun cider-completion-symbol-end-pos () + "Find the end position of the symbol at point, unless inside a string." + (cdr (cider-completion--bounds-of-non-string-symbol-at-point))) + +(defun cider-completion-get-info-context-at-point () + "Extract a context at point that is suitable for eldoc and info ops. +Note that this context is slightly different than that of +`cider-completion-get-context-at-point': this one does not include +the current symbol at point." + (when (save-excursion + (condition-case _ + (progn + (up-list) + (check-parens) + t) + (scan-error nil) + (user-error nil))) + (save-excursion + (let* ((pref-start (cider-completion-symbol-start-pos)) + (context (cider-defun-at-point)) + (end (cider-completion-symbol-end-pos)) + (_ (beginning-of-defun-raw)) + (expr-start (point)) + (_ (if (derived-mode-p 'cider-repl-mode) + (goto-char (point-max)) + (end-of-defun))) + (expr-end (point))) + (string-remove-suffix "\n" + (concat (when pref-start (substring context 0 (- pref-start expr-start))) + "__prefix__" + (substring context (- (- expr-end end))))))))) + +(defun cider-completion-get-context-at-point () + "Extract the context at point. +If point is not inside the list, returns nil; otherwise return \"top-level\" +form, with symbol at point replaced by __prefix__." + (when (save-excursion + (condition-case _ + (progn + (up-list) + (check-parens) + t) + (scan-error nil) + (user-error nil))) + (save-excursion + (let* ((pref-end (point)) + (pref-start (cider-completion-symbol-start-pos)) + (context (cider-defun-at-point)) + (_ (beginning-of-defun-raw)) + (expr-start (point))) + (concat (when pref-start (substring context 0 (- pref-start expr-start))) + "__prefix__" + (substring context (- pref-end expr-start))))))) + +(defun cider-completion-get-context (&optional info) + "Extract context depending (maybe of INFO type). + +Output depends on `cider-completion-use-context' and the current major mode." + (if cider-completion-use-context + ;; We use ignore-errors here since grabbing the context + ;; might fail because of unbalanced parens, or other + ;; technical reasons, yet we don't want to lose all + ;; completions and throw error to user because of that. + (or (ignore-errors + (if info + (cider-completion-get-info-context-at-point) + (cider-completion-get-context-at-point))) + "nil") + "nil")) + +(provide 'cider-completion-context) +;;; cider-completion-context.el ends here diff --git a/elpa/cider-20230707.640/cider-completion.el b/elpa/cider-20241203.1607/cider-completion.el similarity index 57% rename from elpa/cider-20230707.640/cider-completion.el rename to elpa/cider-20241203.1607/cider-completion.el index 20b75e46..1e89adca 100644 --- a/elpa/cider-20230707.640/cider-completion.el +++ b/elpa/cider-20241203.1607/cider-completion.el @@ -1,6 +1,6 @@ ;;; cider-completion.el --- Smart REPL-powered code completion -*- lexical-binding: t -*- -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Bozhidar Batsov ;; Artur Malabarba @@ -31,15 +31,12 @@ (require 'cider-client) (require 'cider-common) +(require 'cider-completion-context) (require 'cider-doc) +(require 'cider-docstring) (require 'cider-eldoc) (require 'nrepl-dict) - -(defcustom cider-completion-use-context t - "When true, uses context at point to improve completion suggestions." - :type 'boolean - :group 'cider - :package-version '(cider . "0.7.0")) +(require 'seq) (defcustom cider-annotate-completion-candidates t "When true, annotate completion candidates with some extra information." @@ -116,55 +113,6 @@ if the candidate is not namespace-qualified." :group 'cider :package-version '(cider . "0.9.0")) -(defvar cider-completion-last-context nil) - -(defun cider-completion-symbol-start-pos () - "Find the starting position of the symbol at point, unless inside a string." - (let ((sap (symbol-at-point))) - (when (and sap (not (nth 3 (syntax-ppss)))) - (car (bounds-of-thing-at-point 'symbol))))) - -(defun cider-completion-get-context-at-point () - "Extract the context at point. -If point is not inside the list, returns nil; otherwise return \"top-level\" -form, with symbol at point replaced by __prefix__." - (when (save-excursion - (condition-case _ - (progn - (up-list) - (check-parens) - t) - (scan-error nil) - (user-error nil))) - (save-excursion - (let* ((pref-end (point)) - (pref-start (cider-completion-symbol-start-pos)) - (context (cider-defun-at-point)) - (_ (beginning-of-defun)) - (expr-start (point))) - (concat (when pref-start (substring context 0 (- pref-start expr-start))) - "__prefix__" - (substring context (- pref-end expr-start))))))) - -(defun cider-completion-get-context () - "Extract context depending on `cider-completion-use-context' and major mode." - (let ((context (if (and cider-completion-use-context - ;; Important because `beginning-of-defun' and - ;; `ending-of-defun' work incorrectly in the REPL - ;; buffer, so context extraction fails there. - (derived-mode-p 'clojure-mode)) - ;; We use ignore-errors here since grabbing the context - ;; might fail because of unbalanced parens, or other - ;; technical reasons, yet we don't want to lose all - ;; completions and throw error to user because of that. - (or (ignore-errors (cider-completion-get-context-at-point)) - "nil") - "nil"))) - (if (string= cider-completion-last-context context) - ":same" - (setq cider-completion-last-context context) - context))) - (defun cider-completion--parse-candidate-map (candidate-map) "Get \"candidate\" from CANDIDATE-MAP. Put type and ns properties on the candidate" @@ -233,29 +181,45 @@ performed by `cider-annotate-completion-function'." (defun cider-complete-at-point () "Complete the symbol at point." - (when-let* ((bounds (bounds-of-thing-at-point 'symbol))) + (when-let* ((bounds (or (bounds-of-thing-at-point 'symbol) + (cons (point) (point)))) + (bounds-string (buffer-substring (car bounds) (cdr bounds)))) (when (and (cider-connected-p) (not (or (cider-in-string-p) (cider-in-comment-p)))) - (list (car bounds) (cdr bounds) - (lambda (prefix pred action) - ;; When the 'action is 'metadata, this lambda returns metadata about this - ;; capf, when action is (boundaries . suffix), it returns nil. With every - ;; other value of 'action (t, nil, or lambda), 'action is forwarded to - ;; (complete-with-action), together with (cider-complete), prefix and pred. - ;; And that function performs the completion based on those arguments. - ;; - ;; This api is better described in the section - ;; '21.6.7 Programmed Completion' of the elisp manual. - (cond ((eq action 'metadata) `(metadata (category . cider))) - ((eq (car-safe action) 'boundaries) nil) - (t (with-current-buffer (current-buffer) - (complete-with-action action - (cider-complete prefix) prefix pred))))) - :annotation-function #'cider-annotate-symbol - :company-kind #'cider-company-symbol-kind - :company-doc-buffer #'cider-create-doc-buffer - :company-location #'cider-company-location - :company-docsig #'cider-company-docsig)))) + (let* (last-bounds-string + last-result + (complete + (lambda () + ;; We are Not using the prefix extracted within the (prefix pred action) + ;; lambda. In certain completion styles, the prefix might be an empty + ;; string, which is unreliable. A more dependable method is to use the + ;; string defined by the bounds of the symbol at point. + ;; + ;; Caching just within the function is sufficient. Keeping it local + ;; ensures that it will not extend across different CIDER sessions. + (unless (string= bounds-string last-bounds-string) + (setq last-bounds-string bounds-string) + (setq last-result (cider-complete bounds-string))) + last-result))) + (list (car bounds) (cdr bounds) + (lambda (prefix pred action) + ;; When the 'action is 'metadata, this lambda returns metadata about this + ;; capf, when action is (boundaries . suffix), it returns nil. With every + ;; other value of 'action (t, nil, or lambda), 'action is forwarded to + ;; (complete-with-action), together with (cider-complete), prefix and pred. + ;; And that function performs the completion based on those arguments. + ;; + ;; This api is better described in the section + ;; '21.6.7 Programmed Completion' of the elisp manual. + (cond ((eq action 'metadata) `(metadata (category . cider))) ;; defines a completion category named 'cider, used later in our `completion-category-overrides` logic. + ((eq (car-safe action) 'boundaries) nil) + (t (with-current-buffer (current-buffer) + (complete-with-action action (funcall complete) prefix pred))))) + :annotation-function #'cider-annotate-symbol + :company-kind #'cider-company-symbol-kind + :company-doc-buffer #'cider-create-compact-doc-buffer + :company-location #'cider-company-location + :company-docsig #'cider-company-docsig))))) (defun cider-completion-flush-caches () "Force Compliment to refill its caches. @@ -281,11 +245,10 @@ in the buffer." (defun cider-company-docsig (thing) "Return signature for THING." - (let* ((eldoc-info (cider-eldoc-info thing)) - (ns (lax-plist-get eldoc-info "ns")) - (symbol (lax-plist-get eldoc-info "symbol")) - (arglists (lax-plist-get eldoc-info "arglists"))) - (when eldoc-info + (when-let ((eldoc-info (cider-eldoc-info thing))) + (let* ((ns (lax-plist-get eldoc-info "ns")) + (symbol (lax-plist-get eldoc-info "symbol")) + (arglists (lax-plist-get eldoc-info "arglists"))) (format "%s: %s" (cider-eldoc-format-thing ns symbol thing (cider-eldoc-thing-type eldoc-info)) @@ -297,15 +260,72 @@ in the buffer." "Return CIDER completion candidates for STRING as is, unfiltered." (cider-complete string)) +;; defines a completion style named `cider' (which ideally would have been named `cider-fuzzy'). +;; note that there's already a completion category named `cider' (grep for `(metadata (category . cider))` in this file), +;; which can be confusing given the identical name. +;; The `cider' completion style should be removed because the `flex' style is essentially equivalent. +;; (To be fair, `flex' was introduced in Emacs 27, 3 years in after our commit 04e428b +;; which introduced `cider-company-enable-fuzzy-completion') (add-to-list 'completion-styles-alist '(cider - cider-company-unfiltered-candidates + ;; Use `ignore' in place of "try-competion function". + ignore cider-company-unfiltered-candidates "CIDER backend-driven completion style.")) (defun cider-company-enable-fuzzy-completion () - "Enable backend-driven fuzzy completion in the current buffer." - (setq-local completion-styles '(cider))) + "Enables `cider' completion style for CIDER in all buffers. + +DEPRECATED: please use `cider-enable-cider-completion-style' instead." + (interactive) + (cider-enable-cider-completion-style)) + +(defun cider-enable-cider-completion-style () + "Enables `cider' completion style for CIDER in all buffers. + +This style supports non-prefix completion candidates returned by the +completion backend. Only affects the `cider' completion category." + (interactive) + (let* ((cider (assq 'cider completion-category-overrides)) + (found-styles (assq 'styles cider)) + (new-styles (if found-styles + (cons 'styles (cons 'cider (cdr found-styles))) + '(styles cider basic))) + (new-cider (if cider + (cons 'cider + (cons new-styles + (seq-remove (lambda (x) (equal 'styles (car x))) + (cdr cider)))) + (list 'cider new-styles))) + (new-overrides (cons new-cider + (seq-remove (lambda (x) (equal 'cider (car x))) + completion-category-overrides)))) + (setq completion-category-overrides new-overrides))) + +(make-obsolete 'cider-company-enable-fuzzy-completion 'cider-enable-cider-completion-style "1.17.0") + +(defun cider-enable-flex-completion () + "Enables `flex' (fuzzy) completion for CIDER in all buffers. + +Only affects the `cider' completion category.`" + (interactive) + (when (< emacs-major-version 27) + (user-error "`cider-enable-flex-completion' requires Emacs 27 or later")) + (let ((found-styles (when-let ((cider (assq 'cider completion-category-overrides))) + (assq 'styles cider))) + (found-cycle (when-let ((cider (assq 'cider completion-category-overrides))) + (assq 'cycle cider)))) + (setq completion-category-overrides (seq-remove (lambda (x) + (equal 'cider (car x))) + completion-category-overrides)) + (unless found-styles + (setq found-styles '(styles basic))) + (unless (member 'flex found-styles) + ;; This expression makes sure that 'flex style has a priority over other + ;; styles, see https://github.com/clojure-emacs/cider/pull/3696. + (setq found-styles (apply #'list 'styles 'flex (cdr found-styles)))) + (add-to-list 'completion-category-overrides (apply #'list 'cider found-styles (when found-cycle + (list found-cycle)))))) (provide 'cider-completion) ;;; cider-completion.el ends here diff --git a/elpa/cider-20230707.640/cider-connection.el b/elpa/cider-20241203.1607/cider-connection.el similarity index 90% rename from elpa/cider-20230707.640/cider-connection.el rename to elpa/cider-20241203.1607/cider-connection.el index 35fc7927..35a8f2f0 100644 --- a/elpa/cider-20230707.640/cider-connection.el +++ b/elpa/cider-20241203.1607/cider-connection.el @@ -1,6 +1,6 @@ ;;; cider-connection.el --- Connection and session life-cycle management for CIDER -*- lexical-binding: t -*- ;; -;; Copyright © 2019-2023 Artur Malabarba, Bozhidar Batsov, Vitalie Spinu and CIDER contributors +;; Copyright © 2019-2024 Artur Malabarba, Bozhidar Batsov, Vitalie Spinu and CIDER contributors ;; ;; Author: Artur Malabarba ;; Bozhidar Batsov @@ -105,7 +105,14 @@ Possible choices are `prompt', `auto', `any', and nil. (defconst cider-required-nrepl-version "0.6.0" "The minimum nREPL version that's known to work properly with CIDER.") - +(defcustom cider-clojurec-eval-destination 'multi + "The REPL type to be chosen in .cljc buffers." + :type '(choice (const :tag "Clojure" clj) + (const :tag "ClojureScript" cljs) + (const :tag "Multi (evaluate in Clojure and ClojureScript simultaneously)" multi)) + :group 'cider + :package-version '(cider . "1.8")) + ;;; Connect (defun cider-nrepl-connect (params) @@ -160,22 +167,19 @@ PROC-BUFFER is either server or client buffer, defaults to current buffer." nrepl-server-buffer))) (cl-loop for l on nrepl-endpoint by #'cddr do (setq params (plist-put params (car l) (cadr l)))) - (setq params (thread-first - params - (plist-put :project-dir nrepl-project-dir))) + (setq params (thread-first params + (plist-put :project-dir nrepl-project-dir))) (when (buffer-live-p server-buf) - (setq params (thread-first - params - (plist-put :server (get-buffer-process server-buf)) - (plist-put :server-command nrepl-server-command)))) + (setq params (thread-first params + (plist-put :server (get-buffer-process server-buf)) + (plist-put :server-command nrepl-server-command)))) ;; repl-specific parameters (do not pollute server params!) (unless (nrepl-server-p proc-buffer) - (setq params (thread-first - params - (plist-put :session-name cider-session-name) - (plist-put :repl-type cider-repl-type) - (plist-put :cljs-repl-type cider-cljs-repl-type) - (plist-put :repl-init-function cider-repl-init-function)))) + (setq params (thread-first params + (plist-put :session-name cider-session-name) + (plist-put :repl-type cider-repl-type) + (plist-put :cljs-repl-type cider-cljs-repl-type) + (plist-put :repl-init-function cider-repl-init-function)))) params)))) (defun cider--close-buffer (buffer) @@ -198,10 +202,9 @@ buffer." (cider--close-buffer nrepl-tunnel-buffer)) (when no-kill ;; inform sentinel not to kill the server, if any - (thread-first - (get-buffer-process repl) - (process-plist) - (plist-put :keep-server t)))) + (thread-first (get-buffer-process repl) + (process-plist) + (plist-put :keep-server t)))) (let ((proc (get-buffer-process repl))) (when (and (process-live-p proc) (or (not nrepl-server-buffer) @@ -303,6 +306,7 @@ message in the REPL area." See command `cider-mode'." (interactive) (add-hook 'clojure-mode-hook #'cider-mode) + (add-hook 'clojure-ts-mode-hook #'cider-mode) (dolist (buffer (cider-util--clojure-buffers)) (with-current-buffer buffer (unless cider-mode @@ -342,20 +346,18 @@ See `cider-connection-capabilities'." (pcase (cider-runtime) ('clojure '(clojure jvm-compilation-errors)) ('babashka '(babashka jvm-compilation-errors)) + ('nbb '(cljs)) + ('scittle '(cljs)) (_ '())) (when - (or - (eq cider-repl-type 'cljs) - ;; This check is currently basically for nbb. - ;; See `cider-sync-tooling-eval', but it is defined on a higher layer - (nrepl-dict-get - (nrepl-sync-request:eval "cljs.core/demunge" (current-buffer) nil 'tooling) - "value")) + (eq cider-repl-type 'cljs) '(cljs)))))) (declare-function cider--debug-init-connection "cider-debug") (declare-function cider-repl-init "cider-repl") (declare-function cider-nrepl-op-supported-p "cider-client") +(declare-function cider-nrepl-request:eval "cider-client") + (defun cider--connected-handler () "Handle CIDER initialization after nREPL connection has been established. This function is appended to `nrepl-connected-hook' in the client process @@ -415,28 +417,25 @@ process buffer." "Retrieve the underlying connection's Java version." (with-current-buffer (cider-current-repl) (when nrepl-versions - (thread-first - nrepl-versions - (nrepl-dict-get "java") - (nrepl-dict-get "version-string"))))) + (thread-first nrepl-versions + (nrepl-dict-get "java") + (nrepl-dict-get "version-string"))))) (defun cider--clojure-version () "Retrieve the underlying connection's Clojure version." (with-current-buffer (cider-current-repl) (when nrepl-versions - (thread-first - nrepl-versions - (nrepl-dict-get "clojure") - (nrepl-dict-get "version-string"))))) + (thread-first nrepl-versions + (nrepl-dict-get "clojure") + (nrepl-dict-get "version-string"))))) (defun cider--nrepl-version () "Retrieve the underlying connection's nREPL version." (with-current-buffer (cider-current-repl) (when nrepl-versions - (thread-first - nrepl-versions - (nrepl-dict-get "nrepl") - (nrepl-dict-get "version-string"))))) + (thread-first nrepl-versions + (nrepl-dict-get "nrepl") + (nrepl-dict-get "version-string"))))) (defun cider--babashka-version () "Retrieve the underlying connection's Babashka version." @@ -450,11 +449,28 @@ process buffer." (when nrepl-versions (nrepl-dict-get nrepl-versions "babashka.nrepl")))) +(defun cider--nbb-nrepl-version () + "Retrieve the underlying connection's nbb version. + +Note that this is currently not a real version number. +But helps us know if this is a nbb repl, or not." + (with-current-buffer (cider-current-repl) + (when nrepl-versions + (nrepl-dict-get nrepl-versions "nbb-nrepl")))) + +(defun cider--scittle-nrepl-version () + "Retrieve the underlying connection's scittle version." + (with-current-buffer (cider-current-repl) + (when nrepl-versions + (nrepl-dict-get nrepl-versions "scittle-nrepl")))) + (defun cider-runtime () "Return the runtime of the nREPl server." (cond ((cider--clojure-version) 'clojure) ((cider--babashka-version) 'babashka) + ((cider--nbb-nrepl-version) 'nbb) + ((cider--scittle-nrepl-version) 'scittle) (t 'generic))) (defun cider-runtime-clojure-p () @@ -531,11 +547,10 @@ entire session." (let* ((repl (or repl (sesman-browser-get 'object) (cider-current-repl nil 'ensure))) - (params (thread-first - () - (cider--gather-connect-params repl) - (plist-put :session-name (sesman-session-name-for-object 'CIDER repl)) - (plist-put :repl-buffer repl)))) + (params (thread-first () + (cider--gather-connect-params repl) + (plist-put :session-name (sesman-session-name-for-object 'CIDER repl)) + (plist-put :repl-buffer repl)))) (cider--close-connection repl 'no-kill) (cider-nrepl-connect params) ;; need this to refresh sesman browser @@ -607,35 +622,6 @@ REPL defaults to the current REPL." (sesman-more-recent-p (cdr session1) (cdr session2))) (declare-function cider-classpath-entries "cider-client") -(cl-defmethod sesman-friendly-session-p ((_system (eql CIDER)) session) - "Check if SESSION is a friendly session." - (setcdr session (seq-filter #'buffer-live-p (cdr session))) - (when-let* ((repl (cadr session)) - (proc (get-buffer-process repl)) - (file (file-truename (or (buffer-file-name) default-directory)))) - ;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj - (when (string-match-p "#uzip" file) - (let ((avfs-path (directory-file-name (expand-file-name (or (getenv "AVFSBASE") "~/.avfs/"))))) - (setq file (replace-regexp-in-string avfs-path "" file t t)))) - (when (process-live-p proc) - (let* ((classpath (or (process-get proc :cached-classpath) - (let ((cp (with-current-buffer repl - (cider-classpath-entries)))) - (process-put proc :cached-classpath cp) - cp))) - (classpath-roots (or (process-get proc :cached-classpath-roots) - (let ((cp (thread-last - classpath - (seq-filter (lambda (path) (not (string-match-p "\\.jar$" path)))) - (mapcar #'file-name-directory) - (seq-remove #'null) - (seq-uniq)))) - (process-put proc :cached-classpath-roots cp) - cp)))) - (or (seq-find (lambda (path) (string-prefix-p path file)) - classpath) - (seq-find (lambda (path) (string-prefix-p path file)) - classpath-roots)))))) (defvar cider-sesman-browser-map (let ((map (make-sparse-keymap))) @@ -645,7 +631,6 @@ REPL defaults to the current REPL." (define-key map (kbd "j d") #'cider-describe-connection) (define-key map (kbd "j i") #'cider-describe-connection) (define-key map (kbd "C-c C-q") #'cider-quit) - (define-key map (kbd "C-c C-q") #'cider-quit) (define-key map (kbd "C-c C-r") #'cider-restart) (define-key map (kbd "C-c M-r") #'cider-restart) (define-key map (kbd "C-c C-d") #'cider-describe-connection) @@ -694,24 +679,35 @@ Fallback on `cider' command." ;; 4) restart the repls reusing the buffer (dolist (r repls) (cider-nrepl-connect - (thread-first - () - (cider--gather-connect-params r) - ;; server params (:port, :project-dir etc) have precedence - (cider--gather-connect-params server-buf) - (plist-put :session-name ses-name) - (plist-put :repl-buffer r)))) + (thread-first () + (cider--gather-connect-params r) + ;; server params (:port, :project-dir etc) have precedence + (cider--gather-connect-params server-buf) + (plist-put :session-name ses-name) + (plist-put :repl-buffer r)))) (sesman-browser-revert-all 'CIDER) (message "Restarted CIDER %s session" ses-name)))) ;; server-less session (dolist (r repls) (cider--close-connection r 'no-kill) (cider-nrepl-connect - (thread-first - () - (cider--gather-connect-params r) - (plist-put :session-name ses-name) - (plist-put :repl-buffer r))))))) + (thread-first () + (cider--gather-connect-params r) + (plist-put :session-name ses-name) + (plist-put :repl-buffer r))))))) + +(defun cider--ensure-spec-is-not-invokable (spec) + "Ensures SPEC cannot be invoked as a function. + +Invokeable specs are an Emacs 29 feature +that we don't intend to use in this context." + (let ((spec-char (car spec)) + (spec-value (cdr spec))) + `(,spec-char + . + ,(if (symbolp spec-value) + (prin1-to-string spec-value) + spec-value)))) (defun cider-format-connection-params (template params) "Format PARAMS with TEMPLATE string. @@ -735,7 +731,8 @@ removed." default-directory)))) (short-proj (file-name-nondirectory (directory-file-name dir))) (parent-dir (ignore-errors - (thread-first dir file-name-directory + (thread-first dir + file-name-directory directory-file-name file-name-nondirectory file-name-as-directory))) (long-proj (format "%s%s" (or parent-dir "") short-proj)) @@ -764,13 +761,13 @@ removed." (?S . ,cljs-repl-type))) (ses-name (or (plist-get params :session-name) (format-spec cider-session-name-template specs))) - (specs (append `((?s . ,ses-name)) specs))) - (thread-last - (format-spec template specs) - ;; remove extraneous separators - (replace-regexp-in-string "\\([:-]\\)[:-]+" "\\1") - (replace-regexp-in-string "\\(^[:-]\\)\\|\\([:-]$\\)" "") - (replace-regexp-in-string "[:-]\\([])*]\\)" "\\1")))) + (specs (append `((?s . ,ses-name)) specs)) + (specs (mapcar #'cider--ensure-spec-is-not-invokable specs))) + (thread-last (format-spec template specs) + ;; remove extraneous separators + (replace-regexp-in-string "\\([:-]\\)[:-]+" "\\1") + (replace-regexp-in-string "\\(^[:-]\\)\\|\\([:-]$\\)" "") + (replace-regexp-in-string "[:-]\\([])*]\\)" "\\1")))) (defun cider-make-session-name (params) "Create new session name given plist of connection PARAMS. @@ -788,7 +785,7 @@ Session name can be customized with `cider-session-name-template'." ;;; REPL Buffer Init (defvar-local cider-cljs-repl-type nil - "The type of the ClojureScript runtime (Browser, Node, Figwheel, etc.).") + "The type of the ClojureScript runtime ('browser, 'node, 'figwheel, etc.).") (defvar-local cider-repl-type nil "The type of this REPL buffer, usually either clj or cljs.") @@ -811,9 +808,9 @@ multi. This function infers connection type based on the major mode. For the REPL type use the function `cider-repl-type'." (with-current-buffer (or buffer (current-buffer)) (cond - ((derived-mode-p 'clojurescript-mode) 'cljs) - ((derived-mode-p 'clojurec-mode) 'multi) - ((derived-mode-p 'clojure-mode) 'clj) + ((cider-clojurescript-major-mode-p) 'cljs) + ((cider-clojurec-major-mode-p) cider-clojurec-eval-destination) + ((cider-clojure-major-mode-p) 'clj) (cider-repl-type)))) (defun cider-set-repl-type (&optional type) @@ -919,6 +916,8 @@ function with the repl buffer set as current." ;; ran at the end of cider--connected-handler cider-repl-init-function (plist-get params :repl-init-function) cider-launch-params params) + (when-let ((type (plist-get params :cljs-repl-type))) + (setq cider-cljs-repl-type type)) (cider-repl-reset-markers) (add-hook 'nrepl-response-handler-functions #'cider-repl--state-handler nil 'local) (add-hook 'nrepl-connected-hook #'cider--connected-handler nil 'local) diff --git a/elpa/cider-20230707.640/cider-debug.el b/elpa/cider-20241203.1607/cider-debug.el similarity index 97% rename from elpa/cider-20230707.640/cider-debug.el rename to elpa/cider-20241203.1607/cider-debug.el index ec67a87a..5b9a69b3 100644 --- a/elpa/cider-20230707.640/cider-debug.el +++ b/elpa/cider-20241203.1607/cider-debug.el @@ -1,6 +1,6 @@ ;;; cider-debug.el --- CIDER interaction with the cider.debug nREPL middleware -*- lexical-binding: t; -*- -;; Copyright © 2015-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2015-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; Author: Artur Malabarba @@ -125,14 +125,16 @@ configure `cider-debug-prompt' instead." (defun cider--debug-response-handler (response) "Handles RESPONSE from the cider.debug middleware." - (nrepl-dbind-response response (status id causes) + (nrepl-dbind-response response (status id causes caught-msg) (when (member "enlighten" status) (cider--handle-enlighten response)) (when (or (member "eval-error" status) (member "stack" status)) ;; TODO: Make the error buffer a bit friendlier when we're just printing ;; the stack. - (cider--render-stacktrace-causes causes)) + (if cider-show-error-buffer + (cider--render-stacktrace-causes causes) + (cider--debug-display-result-overlay nil caught-msg))) (when (member "need-debug-input" status) (cider--handle-debug response)) (when (member "done" status) @@ -154,15 +156,18 @@ configure `cider-debug-prompt' instead." #("." 0 1 (display (left-fringe right-triangle))) "Used as an overlay's before-string prop to place a fringe arrow.") -(defun cider--debug-display-result-overlay (value) - "Place an overlay at point displaying VALUE." +(defun cider--debug-display-result-overlay (value caught) + "Place an overlay at point displaying VALUE. +When CAUGHT is non-nil, display it as an error message overlay." (when cider-debug-use-overlays ;; This is cosmetic, let's ensure it doesn't break the session no matter what. (ignore-errors ;; Result - (cider--make-result-overlay (cider-font-lock-as-clojure value) + (cider--make-result-overlay (or caught (cider-font-lock-as-clojure value)) :where (point-marker) :type 'debug-result + :prepend-face (if caught 'cider-error-overlay-face + 'cider-result-overlay-face) 'before-string cider--fringe-arrow-string) ;; Code (cider--make-overlay (save-excursion (clojure-backward-logical-sexp 1) (point)) @@ -652,7 +657,7 @@ is a coordinate measure in sexps." RESPONSE is a message received from the nrepl describing the input needed. It is expected to contain at least \"key\", \"input-type\", and \"prompt\", and possibly other entries depending on the input-type." - (nrepl-dbind-response response (debug-value key input-type prompt inspect) + (nrepl-dbind-response response (debug-value key input-type prompt inspect caught-msg) (condition-case-unless-debug e (progn (pcase input-type @@ -674,7 +679,7 @@ needed. It is expected to contain at least \"key\", \"input-type\", and ;; flicker even if we immediately recreate the overlays. (cider--debug-remove-overlays) (when cider-debug-use-overlays - (cider--debug-display-result-overlay debug-value)) + (cider--debug-display-result-overlay debug-value caught-msg)) (setq cider--debug-mode-response response) (cider--debug-mode 1))) (when inspect @@ -762,15 +767,15 @@ The boolean value of FORCE will be sent in the reply." (progn ;; Get to the proper line & column in the file (forward-line (1- (- line (line-number-at-pos)))) (move-to-column column)) - (beginning-of-defun)) + (beginning-of-defun-raw)) ;; Is HERE inside the sexp being debugged? (when (or (< here (point)) (save-excursion - (forward-sexp 1) + (clojure-forward-logical-sexp 1) (> here (point)))) (user-error "Point is outside the sexp being debugged")) ;; Move forward until start of sexp. - (comment-normalize-vars) + (comment-normalize-vars t) (comment-forward (point-max)) ;; Find the coordinate and send it. (cider-debug-mode-send-reply diff --git a/elpa/cider-20230707.640/cider-doc.el b/elpa/cider-20241203.1607/cider-doc.el similarity index 80% rename from elpa/cider-20230707.640/cider-doc.el rename to elpa/cider-20241203.1607/cider-doc.el index 5120ecc8..addfdeb8 100644 --- a/elpa/cider-20230707.640/cider-doc.el +++ b/elpa/cider-20241203.1607/cider-doc.el @@ -1,6 +1,6 @@ ;;; cider-doc.el --- CIDER documentation functionality -*- lexical-binding: t -*- -;; Copyright © 2014-2023 Bozhidar Batsov, Jeff Valk and CIDER contributors +;; Copyright © 2014-2024 Bozhidar Batsov, Jeff Valk and CIDER contributors ;; Author: Jeff Valk @@ -26,6 +26,7 @@ ;;; Code: (require 'cider-common) +(require 'cider-docstring) (require 'subr-x) (require 'cider-util) (require 'cider-popup) @@ -265,10 +266,17 @@ opposite of what that option dictates." (defconst cider-doc-buffer "*cider-doc*") -(defun cider-create-doc-buffer (symbol) - "Populates *cider-doc* with the documentation for SYMBOL." +(defun cider-create-doc-buffer (symbol &optional compact) + "Populates *cider-doc* with the documentation for SYMBOL, +favoring a COMPACT format if specified." (when-let* ((info (cider-var-info symbol))) - (cider-docview-render (cider-make-popup-buffer cider-doc-buffer nil 'ancillary) symbol info))) + (cider-docview-render (cider-make-popup-buffer cider-doc-buffer nil 'ancillary) symbol info compact))) + +(defun cider-create-compact-doc-buffer (symbol) + "Populates *cider-doc* with the documentation for SYMBOL. + +Favors a compact rendering of docstrings" + (cider-create-doc-buffer symbol :compact)) (defun cider-doc-lookup (symbol) "Look up documentation for SYMBOL." @@ -384,18 +392,24 @@ Tables are marked to be ignored by line wrap." (cider-docview-wrap-text buffer))))) ; ignores code, table blocks (defun cider--abbreviate-file-protocol (file-with-protocol) - "Abbreviate the file-path in `file:/path/to/file' of FILE-WITH-PROTOCOL." - (if (string-match "\\`file:\\(.*\\)" file-with-protocol) - (let ((file (match-string 1 file-with-protocol)) - (proj-dir (clojure-project-dir))) - (if (and proj-dir - (file-in-directory-p file proj-dir)) - (file-relative-name file proj-dir) - file)) - file-with-protocol)) - -(defun cider-docview-render-info (buffer info) - "Emit into BUFFER formatted INFO for the Clojure or Java symbol." + "Abbreviate the file-path in `file:/path/to/file' of FILE-WITH-PROTOCOL. + +Same for `jar:file:...!/' segments." + (let ((result (if (string-match "^\\(jar\\|zip\\):\\(file:.+\\)!/\\(.+\\)" file-with-protocol) + (match-string 3 file-with-protocol) + file-with-protocol))) + (if (string-match "\\`file:\\(.*\\)" result) + (let ((file (match-string 1 result)) + (proj-dir (clojure-project-dir))) + (if (and proj-dir + (file-in-directory-p file proj-dir)) + (file-relative-name file proj-dir) + file)) + result))) + +(defun cider-docview-render-info (buffer info &optional compact for-tooltip) + "Emit into BUFFER formatted INFO for the Clojure or Java symbol, +in a COMPACT format is specified, FOR-TOOLTIP if specified." (let* ((ns (nrepl-dict-get info "ns")) (name (nrepl-dict-get info "name")) (added (nrepl-dict-get info "added")) @@ -405,10 +419,21 @@ Tables are marked to be ignored by line wrap." (builtin (nrepl-dict-get info "built-in")) ;; babashka specific (forms (when-let* ((str (nrepl-dict-get info "forms-str"))) (split-string str "\n"))) - (args (when-let* ((str (nrepl-dict-get info "arglists-str"))) - (split-string str "\n"))) - (doc (or (nrepl-dict-get info "doc") - "Not documented.")) + (args (or (nrepl-dict-get info "annotated-arglists") + (when-let* ((str (nrepl-dict-get info "arglists-str"))) + (split-string str "\n")))) + (rendered-fragments (cider--render-docstring (list "doc-fragments" (unless compact + (nrepl-dict-get info "doc-fragments")) + "doc-block-tags-fragments" (nrepl-dict-get info "doc-block-tags-fragments") + "doc-first-sentence-fragments" (nrepl-dict-get info "doc-first-sentence-fragments")))) + (fetched-doc (nrepl-dict-get info "doc")) + (doc (or rendered-fragments + (if compact + (cider-docstring--trim + (cider-docstring--format fetched-doc)) + fetched-doc) + (unless compact + "Not documented."))) (url (nrepl-dict-get info "url")) (class (nrepl-dict-get info "class")) (member (nrepl-dict-get info "member")) @@ -421,24 +446,35 @@ Tables are marked to be ignored by line wrap." (see-also (nrepl-dict-get info "see-also"))) (cider--help-setup-xref (list #'cider-doc-lookup (format "%s/%s" ns name)) nil buffer) (with-current-buffer buffer - (cl-flet ((emit (text &optional face) + (cl-flet ((emit (text &optional face sep) (insert (if face (propertize text 'font-lock-face face) text) - "\n"))) + (or sep "\n")))) (emit (if class java-name clj-name) 'font-lock-function-name-face) (when super - (emit (concat " Extends: " (cider-font-lock-as 'java-mode super)))) + (emit (concat "Extends: " (cider-font-lock-as 'java-mode super)))) (when ifaces (emit (concat "Implements: " (cider-font-lock-as 'java-mode (car ifaces)))) - (dolist (iface (cdr ifaces)) - (emit (concat " "(cider-font-lock-as 'java-mode iface))))) + ;; choose a separator that will produce correct alignment on monospace and regular fonts: + (let ((sep (if for-tooltip + " " + " "))) + (dolist (iface (cdr ifaces)) + (emit (concat sep (cider-font-lock-as 'java-mode iface)))))) (when (or super ifaces) (insert "\n")) - (when-let* ((forms (or forms args))) + (when-let* ((forms (or forms args)) + (forms (delq nil (mapcar (lambda (f) + (unless (equal f "nil") + f)) + forms)))) (dolist (form forms) - (insert " ") - (emit (cider-font-lock-as-clojure form)))) + (emit (cider-font-lock-as-clojure form) + nil)) + (when compact + ;; Compensate for the newlines not `emit`ted in the previous call: + (insert "\n"))) (when special (emit "Special Form" 'font-lock-keyword-face)) (when macro @@ -449,9 +485,12 @@ Tables are marked to be ignored by line wrap." (emit (concat "Added in " added) 'font-lock-comment-face)) (when depr (emit (concat "Deprecated in " depr) 'font-lock-keyword-face)) - (if class + (if (and doc class (not rendered-fragments)) (cider-docview-render-java-doc (current-buffer) doc) - (emit (concat " " doc))) + (when doc + (emit (if rendered-fragments + doc + (concat " " doc))))) (when url (insert "\n Please see ") (insert-text-button url @@ -460,7 +499,7 @@ Tables are marked to be ignored by line wrap." 'action (lambda (x) (browse-url (button-get x 'url)))) (insert "\n")) - (when javadoc + (when (and (not compact) javadoc) (insert "\n\nFor additional documentation, see the ") (insert-text-button "Javadoc" 'url javadoc @@ -478,18 +517,20 @@ Tables are marked to be ignored by line wrap." 'action (lambda (_) (cider-browse-spec (format "%s/%s" ns name)))) (insert "\n\n")) - (if (and cider-docview-file (not (string= cider-docview-file ""))) - (progn - (insert (propertize (if class java-name clj-name) - 'font-lock-face 'font-lock-function-name-face) - " is defined in ") - (insert-text-button (cider--abbreviate-file-protocol cider-docview-file) - 'follow-link t - 'action (lambda (_x) - (cider-docview-source))) - (insert ".")) - (insert "Definition location unavailable.")) - (when see-also + (unless compact + (if (and cider-docview-file (not (string= cider-docview-file ""))) + (progn + (insert (propertize (if class java-name clj-name) + 'font-lock-face 'font-lock-function-name-face) + " is defined in ") + (insert-text-button (cider--abbreviate-file-protocol cider-docview-file) + 'follow-link t + 'action (lambda (_x) + (cider-docview-source))) + (insert ".")) + (insert "Definition location unavailable."))) + (when (and (not compact) + see-also) (insert "\n\n Also see: ") (mapc (lambda (ns-sym) (let* ((ns-sym-split (split-string ns-sym "/")) @@ -503,7 +544,8 @@ Tables are marked to be ignored by line wrap." 'help-function (apply-partially #'cider-doc-lookup symbol))) (insert " ")) see-also)) - (cider--doc-make-xrefs) + (unless compact + (cider--doc-make-xrefs)) (let ((beg (point-min)) (end (point-max))) (nrepl-dict-map (lambda (k v) @@ -512,8 +554,9 @@ Tables are marked to be ignored by line wrap." (current-buffer)))) (declare-function cider-set-buffer-ns "cider-mode") -(defun cider-docview-render (buffer symbol info) - "Emit into BUFFER formatted documentation for SYMBOL's INFO." +(defun cider-docview-render (buffer symbol info &optional compact for-tooltip) + "Emit into BUFFER formatted documentation for SYMBOL's INFO, +favoring a COMPACT format if specified, FOR-TOOLTIP if specified." (with-current-buffer buffer (let ((javadoc (nrepl-dict-get info "javadoc")) (file (nrepl-dict-get info "file")) @@ -529,7 +572,7 @@ Tables are marked to be ignored by line wrap." (setq-local cider-docview-line line) (remove-overlays) - (cider-docview-render-info buffer info) + (cider-docview-render-info buffer info compact for-tooltip) (goto-char (point-min)) (current-buffer)))) diff --git a/elpa/cider-20241203.1607/cider-docstring.el b/elpa/cider-20241203.1607/cider-docstring.el new file mode 100644 index 00000000..2ff46e1e --- /dev/null +++ b/elpa/cider-20241203.1607/cider-docstring.el @@ -0,0 +1,163 @@ +;;; cider-docstring.el --- Docstring rendering -*- lexical-binding: t -*- + +;; Copyright © 2013-2024 Bozhidar Batsov and CIDER contributors +;; +;; Author: Bozhidar Batsov + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Utilities for rendering a docstring into a shorter, especially-formatted string +;; that will look nice in UIs. + +;;; Code: + +(require 'cl-lib) +(require 'seq) +(require 'shr) +(require 'subr-x) + +(defsubst cider--render-pre* (dom) + "Render DOM nodes, formatting them them as Java if they are strings." + (dolist (sub (dom-children dom)) + (if (stringp sub) + (shr-insert (cider-font-lock-as 'java-mode sub)) + (shr-descend sub)))) + +(defun cider--render-pre (dom) + "Render DOM nodes without folding, a monospaced font, and Java syntax coloring." + (let ((shr-folding-mode 'none) + (shr-current-font 'default)) + (cider--render-pre* dom))) + +(defun cider--string-rstrip-newlines (str) + "Remove newlines at the end of STR." + (if (string-match "\\([\n\r]+\\)$" str) + (replace-match "" nil nil str) + str)) + +(defun cider--html-to-propertized-string (html-string) + "Convert an HTML-STRING into a propertized string using SHR." + (with-temp-buffer + (insert html-string) + (cider--string-rstrip-newlines ;; shr-insert-document adds a final newline. Plain text fragments are responsible for separating fragments if needed.. + (let ((dom (libxml-parse-html-region (point-min) (point-max)))) + (erase-buffer) + (shr-insert-document dom) + (buffer-string))))) + +(defun cider--fragments-to-s (fragments) + "Convert FRAGMENTS into a concatenated string representation. +If a given fragment is of html type, it's converted to a propertized string; +otherwise, it's included as-is." + (when (and fragments + (> (length fragments) + 0)) + (string-trim (cl-reduce (lambda (new-s fragment) + (let* ((html? (equal "html" (nrepl-dict-get fragment "type"))) + (v (nrepl-dict-get fragment "content"))) + (concat new-s (if html? + (let ((shr-use-fonts nil) + (shr-external-rendering-functions '((pre . cider--render-pre)))) + (cider--html-to-propertized-string v)) + v)))) + fragments + :initial-value "")))) + +(defcustom cider-docstring-max-lines 20 + "The maximum number of docstring lines that will be rendered in a UI widget (or the echo area). + +Note that `cider-docstring' will trim thing smartly, for Java doc comments: +* First, the whole doc comment will be attempted to be rendered. +* If that exceeds `cider-docstring-max-lines', + we will use only the first sentence and the block tags + (that is, the params/throws/returns info). +* If that exceeds `cider-docstring-max-lines', we will use only the block tags. +* If that exceeds `cider-docstring-max-lines', we will use only the first sentence." + :type 'integer + :group 'cider + :package-version '(cider . "1.8.0")) + +(defun cider--attempt-invalid? (attempt) + "Check if ATTEMPT is either nil or exceeds `cider-docstring-max-lines' in line count." + (or (not attempt) + (and attempt + (> (length (split-string attempt "\n")) + cider-docstring-max-lines)))) + +(defun cider--render-docstring-first-sentence (eldoc-info) + "Render the first sentence of the docstring extracted from ELDOC-INFO." + (when-let ((first-sentence-fragments (lax-plist-get eldoc-info "doc-first-sentence-fragments"))) + (cider--fragments-to-s first-sentence-fragments))) + +(defun cider--render-docstring (eldoc-info) + "Renders the docstring from ELDOC-INFO based on its length and content. +Prioritize rendering as much as possible while staying within `cider-docstring-max-lines'." + (let* ((first-sentence-fragments (lax-plist-get eldoc-info "doc-first-sentence-fragments")) + (body-fragments (lax-plist-get eldoc-info "doc-fragments")) + (block-tags-fragments (lax-plist-get eldoc-info "doc-block-tags-fragments")) + (block-tags-fragments-rendered (cider--fragments-to-s block-tags-fragments)) + (first-sentence-fragments-rendered) ;; mutable, for performance + (first-attempt (when body-fragments + (concat (cider--fragments-to-s body-fragments) + (when block-tags-fragments + "\n\n") + block-tags-fragments-rendered))) + (first-attempt-invalid? (cider--attempt-invalid? first-attempt)) + (second-attempt (when (and first-sentence-fragments + first-attempt-invalid?) + (setq first-sentence-fragments-rendered (cider--fragments-to-s first-sentence-fragments)) + (concat first-sentence-fragments-rendered + (when block-tags-fragments-rendered + "\n\n") + block-tags-fragments-rendered))) + (second-attempt-invalid? (cider--attempt-invalid? second-attempt)) + (third-attempt (when (and block-tags-fragments-rendered + first-attempt-invalid? + second-attempt-invalid?) + block-tags-fragments-rendered)) + (third-attempt-invalid? (cider--attempt-invalid? third-attempt)) + (last-attempt (when (and first-sentence-fragments-rendered + first-attempt-invalid? + second-attempt-invalid? + third-attempt-invalid?) + first-sentence-fragments-rendered))) + (or last-attempt ;; the last attempt has to go first - it takes priority over an attempt deemed invalid. + third-attempt + second-attempt + first-attempt))) + +(cl-defun cider-docstring--trim (string &optional (max-lines cider-docstring-max-lines)) + "Return MAX-LINES of STRING, adding \"...\" if trimming was necessary." + (when string + (let* ((lines (split-string string "\n")) + (string (string-join (seq-take lines max-lines) "\n"))) + (concat string (when (> (length lines) max-lines) "..."))))) + +(defun cider-docstring--format (string) + "Return a nicely formatted STRING to be displayed to the user. + +We need to format the docstring before displaying it to the user +because it is obtained from the source code. For example, this means +that it usually has two spaces before each line used for indentation +\(see https://guide.clojure.style/#docstring-indentation). While displaying +the docstring to the user, we usually want to control indentation and +other aspects of the presentation, so we format it before displaying." + (replace-regexp-in-string "\n " "\n" string)) + +(provide 'cider-docstring) +;;; cider-docstring.el ends here diff --git a/elpa/cider-20230707.640/cider-eldoc.el b/elpa/cider-20241203.1607/cider-eldoc.el similarity index 93% rename from elpa/cider-20230707.640/cider-eldoc.el rename to elpa/cider-20241203.1607/cider-eldoc.el index 0a43203b..1137046b 100644 --- a/elpa/cider-20230707.640/cider-eldoc.el +++ b/elpa/cider-20241203.1607/cider-eldoc.el @@ -1,7 +1,7 @@ ;;; cider-eldoc.el --- eldoc support for Clojure -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -33,6 +33,8 @@ (require 'cider-client) (require 'cider-common) ; for cider-symbol-at-point +(require 'cider-completion-context) +(require 'cider-docstring) (require 'subr-x) (require 'cider-util) (require 'nrepl-dict) @@ -214,8 +216,16 @@ THING is the variable name. ELDOC-INFO is a p-list containing the eldoc information." (let* ((ns (lax-plist-get eldoc-info "ns")) (symbol (lax-plist-get eldoc-info "symbol")) - (docstring (lax-plist-get eldoc-info "docstring")) - (formatted-var (cider-eldoc-format-thing ns symbol thing 'var))) + (docstring (or (cider--render-docstring-first-sentence eldoc-info) + (cider--render-docstring eldoc-info) + (when-let (docstring (lax-plist-get eldoc-info "docstring")) + (cider-docstring--trim + (cider-docstring--format docstring))))) + ;; if it's a single class (and not multiple class candidates), that's it + (maybe-class (car (lax-plist-get eldoc-info "class"))) + (formatted-var (or (when maybe-class + (cider-propertize maybe-class 'var)) + (cider-eldoc-format-thing ns symbol thing 'var)))) (when docstring (cider-eldoc-format-sym-doc formatted-var ns docstring)))) @@ -382,7 +392,7 @@ Otherwise return the eldoc of the first symbol of the sexp." (_ thing))) (defun cider-eldoc-info (thing) - "Return the info for THING. + "Return the info for THING (as string). This includes the arglist and ns and symbol name (if available)." (let ((thing (cider-eldoc--convert-ns-keywords thing))) (when (and (cider-nrepl-op-supported-p "eldoc") @@ -410,7 +420,7 @@ This includes the arglist and ns and symbol name (if available)." ;; generic case (t (if (equal thing (car cider-eldoc-last-symbol)) (cadr cider-eldoc-last-symbol) - (when-let* ((eldoc-info (cider-sync-request:eldoc thing))) + (when-let* ((eldoc-info (cider-sync-request:eldoc thing nil nil (cider-completion-get-context t)))) (let* ((arglists (nrepl-dict-get eldoc-info "eldoc")) (docstring (nrepl-dict-get eldoc-info "docstring")) (type (nrepl-dict-get eldoc-info "type")) @@ -425,9 +435,15 @@ This includes the arglist and ns and symbol name (if available)." name (format ".%s" member))) (eldoc-plist (list "ns" ns-or-class + "class" class "symbol" name-or-member "arglists" arglists "docstring" docstring + "doc-fragments" (nrepl-dict-get eldoc-info "doc-fragments") + "doc-first-sentence-fragments" (nrepl-dict-get eldoc-info + "doc-first-sentence-fragments") + "doc-block-tags-fragments" (nrepl-dict-get eldoc-info + "doc-block-tags-fragments") "type" type))) ;; add context dependent args if requested by defcustom ;; do not cache this eldoc info to avoid showing info diff --git a/elpa/cider-20230707.640/cider-eval.el b/elpa/cider-20241203.1607/cider-eval.el similarity index 73% rename from elpa/cider-20230707.640/cider-eval.el rename to elpa/cider-20241203.1607/cider-eval.el index 110505bd..e5a68c46 100644 --- a/elpa/cider-20230707.640/cider-eval.el +++ b/elpa/cider-20241203.1607/cider-eval.el @@ -1,7 +1,7 @@ ;;; cider-eval.el --- Interactive evaluation (compilation) functionality -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -70,7 +70,15 @@ not to be automatically shown. Irrespective of the value of this variable, the `cider-error-buffer' is always generated in the background. Use `cider-selector' to -navigate to this buffer." +navigate to this buffer. + +Please note, if the error phase belongs to +one of the `cider-clojure-compilation-error-phases', +then no stacktrace showing will happen. +That defcustom takes precedence over this one. + +See its doc for understanding its rationale. You can also customize it to nil +in order to void its effect." :type '(choice (const :tag "always" t) (const except-in-repl) (const only-in-repl) @@ -196,190 +204,6 @@ When invoked with a prefix ARG the command doesn't prompt for confirmation." (save-excursion (quit-window nil error-win)))) - -;;; Sideloader -;; -;; nREPL includes sideloader middleware which provides a Java classloader that -;; is able to dynamically load classes and resources at runtime by interacting -;; with the nREPL client (as opposed to using the classpath of the JVM hosting -;; nREPL server). -;; -;; This performs a similar functionality as the load-file -;; operation, where we can load Clojure namespaces (as source files) or Java -;; classes (as bytecode) by simply requiring or importing them. -;; -;; See https://nrepl.org/nrepl/design/middleware.html#sideloading - -(defcustom cider-sideloader-path nil - "List of directories and jar files to scan for sideloader resources. -When not set the cider-nrepl jar will be added automatically when upgrading -an nREPL connection." - :type 'list - :group 'cider - :package-version '(cider . "1.2.0")) - -(defcustom cider-dynload-cider-nrepl-version nil - "Version of the cider-nrepl jar used for dynamically upgrading a connection. -Defaults to `cider-required-middleware-version'." - :type 'string - :group 'cider - :package-version '(cider . "1.2.0")) - -(defun cider-read-bytes (path) - "Read binary data from PATH. -Return the binary data as unibyte string." - ;; based on f-read-bytes - (with-temp-buffer - (set-buffer-multibyte nil) - (setq buffer-file-coding-system 'binary) - (insert-file-contents-literally path nil) - (buffer-substring-no-properties (point-min) (point-max)))) - -(defun cider-retrieve-resource (dirs name) - "Find a resource NAME in a list DIRS of directories or jar files. -Similar to a classpath lookup. Returns the file contents as a string." - (seq-some - (lambda (path) - (cond - ((file-directory-p path) - (let ((expanded (expand-file-name name path))) - (when (file-exists-p expanded) - (cider-read-bytes expanded)))) - ((and (file-exists-p path) (string-suffix-p ".jar" path)) - (cider-jar-retrieve-resource path name)))) - dirs)) - -(defun cider-provide-file (file) - "Provide FILE in a format suitable for sideloading." - (let ((contents (cider-retrieve-resource cider-sideloader-path file))) - (if contents - (base64-encode-string contents 'no-line-breaks) - ;; if we can't find the file we should return an empty string - (base64-encode-string "")))) - -(defun cider-sideloader-lookup-handler () - "Make a sideloader-lookup handler." - (lambda (response) - (nrepl-dbind-response response (id status type name) - (if status - (when (member "sideloader-lookup" status) - (cider-request:sideloader-provide id type name)))))) - -(defun cider-add-middleware-handler (continue) - "Make a add-middleware handler. -CONTINUE is an optional continuation function." - (lambda (response) - (nrepl-dbind-response response (status unresolved-middleware) ;; id middleware - (when unresolved-middleware - (seq-do - (lambda (mw) - (cider-repl-emit-interactive-stderr - (concat "WARNING: middleware " mw " was not found or failed to load.\n"))) - unresolved-middleware)) - (when (and status (member "done" status) continue) - (funcall continue))))) - -(defun cider-request:sideloader-start (&optional connection tooling) - "Perform the nREPL \"sideloader-start\" op. -If CONNECTION is nil, use `cider-current-repl'. -If TOOLING is truthy then the operation is performed over the tooling -session, rather than the regular session." - (cider-ensure-op-supported "sideloader-start") - (cider-nrepl-send-request `("op" "sideloader-start") - (cider-sideloader-lookup-handler) - connection - tooling)) - -(defun cider-request:sideloader-provide (id type file &optional connection) - "Perform the nREPL \"sideloader-provide\" op for ID, TYPE and FILE. -If CONNECTION is nil, use `cider-current-repl'." - (cider-nrepl-send-request `("id" ,id - "op" "sideloader-provide" - "type" ,type - "name" ,file - "content" ,(cider-provide-file file)) - (cider-sideloader-lookup-handler) - connection)) - -(defun cider-sideloader-start (&optional connection) - "Start nREPL's sideloader. -If CONNECTION is nil, use `cider-current-repl'." - (interactive) - (message "Starting nREPL's sideloader") - (cider-request:sideloader-start connection) - (cider-request:sideloader-start connection 'tooling)) - -(defvar cider-nrepl-middlewares - '("cider.nrepl/wrap-apropos" - "cider.nrepl/wrap-classpath" - "cider.nrepl/wrap-clojuredocs" - "cider.nrepl/wrap-complete" - "cider.nrepl/wrap-content-type" - "cider.nrepl/wrap-debug" - "cider.nrepl/wrap-enlighten" - "cider.nrepl/wrap-format" - "cider.nrepl/wrap-info" - "cider.nrepl/wrap-inspect" - "cider.nrepl/wrap-log" - "cider.nrepl/wrap-macroexpand" - "cider.nrepl/wrap-ns" - "cider.nrepl/wrap-out" - "cider.nrepl/wrap-slurp" - "cider.nrepl/wrap-profile" - "cider.nrepl/wrap-refresh" - "cider.nrepl/wrap-resource" - "cider.nrepl/wrap-spec" - "cider.nrepl/wrap-stacktrace" - "cider.nrepl/wrap-test" - "cider.nrepl/wrap-trace" - "cider.nrepl/wrap-tracker" - "cider.nrepl/wrap-undef" - "cider.nrepl/wrap-version" - "cider.nrepl/wrap-xref")) - -(defun cider-request:add-middleware (middlewares - &optional connection tooling continue) - "Use the nREPL dynamic loader to add MIDDLEWARES to the nREPL session. - -- If CONNECTION is nil, use `cider-current-repl'. -- If TOOLING it truthy, use the tooling session instead of the main session. -- CONTINUE is an optional continuation function, which will be called when the -add-middleware op has finished successfully." - (cider-nrepl-send-request `("op" "add-middleware" - "middleware" ,middlewares) - (cider-add-middleware-handler continue) - connection - tooling)) - -(defun cider-add-cider-nrepl-middlewares (&optional connection) - "Use dynamic loading to add the cider-nrepl middlewares to nREPL. -If CONNECTION is nil, use `cider-current-repl'." - (cider-request:add-middleware - cider-nrepl-middlewares connection nil - (lambda () - ;; When the main session is done adding middleware, then do the tooling - ;; session. At this point all the namespaces have been sideloaded so this - ;; is faster, we don't want these to race to sideload resources. - (cider-request:add-middleware - cider-nrepl-middlewares connection 'tooling - (lambda () - ;; Ask nREPL again what its capabilities are, so we know which new - ;; operations are supported. - (nrepl--init-capabilities (or connection (cider-current-repl)))))))) - -(defvar cider-required-middleware-version) -(defun cider-upgrade-nrepl-connection (&optional connection) - "Sideload cider-nrepl middleware. -If CONNECTION is nil, use `cider-current-repl'." - (interactive) - (when (not cider-sideloader-path) - (setq cider-sideloader-path (list (cider-jar-find-or-fetch - "cider" "cider-nrepl" - (or cider-dynload-cider-nrepl-version - cider-required-middleware-version))))) - (cider-sideloader-start connection) - (cider-add-cider-nrepl-middlewares connection)) - ;;; Dealing with compilation (evaluation) errors and warnings (defun cider-find-property (property &optional backward) @@ -478,8 +302,42 @@ op/situation that originated this error." (let ((error-buffer (cider-new-error-buffer #'cider-stacktrace-mode error-types))) (cider-stacktrace-render error-buffer (reverse causes) error-types)))) -(defun cider--handle-stacktrace-response (response causes) - "Handle stacktrace op RESPONSE, aggregating the result into CAUSES. +(defconst cider-clojure-compilation-error-phases-default-value + '("read-source" + "macro-syntax-check" + "macroexpansion" + "compile-syntax-check" + "compilation" + ;; "execution" is certainly not to be included here. + ;; "read-eval-result" and "print-eval-result" are not to be included here, + ;; because they mean that the code has been successfully executed. + )) + +(defcustom cider-clojure-compilation-error-phases cider-clojure-compilation-error-phases-default-value + "Error phases which will not cause the `*cider-error*' buffer to pop up. + +The default value results in no stacktrace being shown for compile-time errors. + +Note that `*cider-error*' pop behavior is otherwise controlled +by the `cider-show-error-buffer' defcustom. + +`cider-clojure-compilation-error-phases' takes precedence. +If you wish phases to be ignored, set this variable to nil instead. + +You can learn more about Clojure's error phases at: +https://clojure.org/reference/repl_and_main#_at_repl" + :type 'list + :group 'cider + :package-version '(cider . "0.18.0")) + +(defun cider-clojure-compilation-error-phases () + "Get the normalized value of the `cider-clojure-compilation-error-phases' var." + (if (equal t cider-clojure-compilation-error-phases) + cider-clojure-compilation-error-phases-default-value + cider-clojure-compilation-error-phases)) + +(defun cider--handle-stacktrace-response (response causes ex-phase) + "Handle stacktrace RESPONSE, aggregate the result into CAUSES, honor EX-PHASE. If RESPONSE contains a cause, cons it onto CAUSES and return that. If RESPONSE is the final message (i.e. it contains a status), render CAUSES into a new error buffer." @@ -487,12 +345,14 @@ into a new error buffer." (cond ((and (member "notification" status) causes) (nrepl-notify msg type)) (class (cons response causes)) - (status (cider--render-stacktrace-causes causes))))) + (status + (unless (member ex-phase (cider-clojure-compilation-error-phases)) + (cider--render-stacktrace-causes causes)))))) (defun cider-default-err-op-handler () "Display the last exception, with middleware support." ;; Causes are returned as a series of messages, which we aggregate in `causes' - (let (causes) + (let (causes ex-phase) (cider-nrepl-send-request (thread-last (map-merge 'list @@ -500,10 +360,13 @@ into a new error buffer." (cider--nrepl-print-request-map fill-column)) (seq-mapcat #'identity)) (lambda (response) + (nrepl-dbind-response response (phase) + (when phase + (setq ex-phase phase))) ;; While the return value of `cider--handle-stacktrace-response' is not ;; meaningful for the last message, we do not need the value of `causes' ;; after it has been handled, so it's fine to set it unconditionally here - (setq causes (cider--handle-stacktrace-response response causes)))))) + (setq causes (cider--handle-stacktrace-response response causes ex-phase)))))) (defun cider-default-err-handler () "This function determines how the error buffer is shown. @@ -514,54 +377,113 @@ It delegates the actual error content to the eval or op handler." (cider-default-err-eval-handler)) (t (cider-default-err-eval-print-handler)))) - -;; The format of the error messages emitted by Clojure's compiler changed in -;; Clojure 1.10. That's why we're trying to match error messages to both the -;; old and the new format, by utilizing a combination of two different regular -;; expressions. - -(defconst cider-clojure-1.10-error `(sequence - "Syntax error " - (minimal-match (zero-or-more anything)) - "compiling " - (minimal-match (zero-or-more anything)) - "at (" - (group-n 2 (minimal-match (zero-or-more anything))) - ":" - (group-n 3 (one-or-more digit)) - (optional ":" (group-n 4 (one-or-more digit))) - ").")) - -(defconst cider-clojure-1.9-error `(sequence - (zero-or-more anything) - ", compiling:(" - (group-n 2 (minimal-match (zero-or-more anything))) - ":" - (group-n 3 (one-or-more digit)) - (optional ":" (group-n 4 (one-or-more digit))) - ")")) - -(defconst cider-clojure-warning `(sequence - (minimal-match (zero-or-more anything)) - (group-n 1 "warning") - ", " - (group-n 2 (minimal-match (zero-or-more anything))) - ":" - (group-n 3 (one-or-more digit)) - (optional ":" (group-n 4 (one-or-more digit))) - " - ")) - - +;; Reference: +;; https://github.com/clojure/clojure/blob/clojure-1.10.0/src/clj/clojure/main.clj#L251 +;; See `cider-compilation-regexp' for interpretation of match groups. +(defconst cider--clojure-1.10-location + '(sequence + "at " (minimal-match (zero-or-more anything)) ;; the fully-qualified name of the function that triggered the error + "(" + (group-n 2 (minimal-match (zero-or-more anything))) ; source file + ":" (group-n 3 (one-or-more (any "-" digit))) ; line number, may be negative (#3687) + (optional + ":" (group-n 4 (one-or-more (any "-" digit)))) ; column number + ").")) + +(defconst cider--clojure-1.10-error + `(sequence + (or "Syntax error reading source " ; phase = :read-source + (sequence + (or "Syntax error " "Unexpected error ") + (minimal-match (zero-or-more anything)) ; optional class, eg. (ClassCastException) + (or "macroexpanding " ; phase = :macro-syntax-check / :macroexpansion + "compiling ") ; phase = :compile-syntax-check / :compilation + (minimal-match (zero-or-more anything)))) ; optional symbol, eg. foo/bar + ,cider--clojure-1.10-location) + "Regexp matching error messages triggered in compilation / read / print phases.") + +(defconst cider--clojure-warning + `(sequence + (minimal-match (zero-or-more anything)) + (group-n 1 "warning") + ", " (group-n 2 (minimal-match (zero-or-more anything))) + ":" (group-n 3 (one-or-more (any "-" digit))) + (optional + ":" (group-n 4 (one-or-more (any "-" digit)))) + " - ") + "Regexp matching various non-error messages, e.g. reflection warnings.") + +;; Please keep this in sync with `cider-clojure-compilation-error-regexp', +;; which is a subset of these regexes. (defconst cider-clojure-compilation-regexp - (eval - `(rx bol (or ,cider-clojure-1.9-error - ,cider-clojure-warning - ,cider-clojure-1.10-error)) - t)) - + (rx-to-string + `(seq bol (or ,cider--clojure-warning + ,cider--clojure-1.10-error)) + 'nogroup) + "A few example values that will match: +\"Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - \" +\"Syntax error compiling at (src/workspace_service.clj:227:3).\" +\"Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).\"") + +(defconst cider-clojure-compilation-error-regexp + (rx-to-string + `(seq bol ,cider--clojure-1.10-error) + 'nogroup) + "Like `cider-clojure-compilation-regexp', +but excluding warnings such as reflection warnings. + +A few example values that will match: +\"Syntax error compiling at (src/workspace_service.clj:227:3).\" +\"Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).\"") + +(defconst cider--clojure-execution-error + `(sequence + (or "Error reading eval result " ; phase = :read-eval-result + "Error printing return value " ; phase = :print-eval-result + "Execution error ") ; phase = :execution + (minimal-match (zero-or-more anything)) ; optional class, eg. (ArithmeticException) + ,cider--clojure-1.10-location)) + +(defconst cider--clojure-spec-execution-error + `(sequence + "Execution error - invalid arguments to " + (minimal-match (one-or-more anything)) + " " + ,cider--clojure-1.10-location)) + +(defconst cider-clojure-runtime-error-regexp + (rx-to-string + `(seq bol (or ,cider--clojure-execution-error + ,cider--clojure-spec-execution-error)) + 'nogroup) + "Matches runtime errors, as oppsed to compile-time/macroexpansion-time errors. + +A few example values that will match: + +\"Execution error (ArithmeticException) at foo/foo (src/haystack/parser.cljc:4).\" +\"Execution error - invalid arguments to foo/bar at (src/haystack/parser.cljc:4).\"") + +(defconst cider-module-info-regexp + (rx " (" + (minimal-match (one-or-more anything)) + " is in" + (minimal-match (one-or-more anything)) ;; module or unnamed module + " of loader " + (minimal-match (one-or-more anything)) + "; " + (minimal-match (one-or-more anything)) + " is in " + (minimal-match (one-or-more anything)) ;; module or unnamed module + " of loader " + (minimal-match (one-or-more anything)) + ")")) (defvar cider-compilation-regexp - (list cider-clojure-compilation-regexp 2 3 4 '(1)) + (list cider-clojure-compilation-regexp + 2 ; FILE + 3 ; LINE + 4 ; COLUMN + '(1)) ; TYPE = (WARNING . INFO) "Specifications for matching errors and warnings in Clojure stacktraces. See `compilation-error-regexp-alist' for help on their format.") @@ -585,7 +507,7 @@ See `compilation-error-regexp-alist' for help on their format.") (list (when file (let ((val (match-string-no-properties file message))) - (unless (string= val "NO_SOURCE_PATH") val))) + (unless (or (string= val "REPL") (string= val "NO_SOURCE_PATH")) val))) (when line (string-to-number (match-string-no-properties line message))) (when col (let ((val (match-string-no-properties col message))) @@ -626,14 +548,21 @@ If location could not be found, return nil." (goto-char (point-min)) (forward-line (1- line)) (move-to-column (or col 0)) - (let ((begin (progn (if col (cider--goto-expression-start) (back-to-indentation)) - (point))) - (end (progn (if col (forward-list) (move-end-of-line nil)) - (point)))) - (list begin end buffer)))))))))))) - -(defun cider-handle-compilation-errors (message eval-buffer) - "Highlight and jump to compilation error extracted from MESSAGE. + ;; if this condition is false, it means that `col` was a spuriously large value, + ;; therefore the whole calculation should be discarded: + (when (or (not col) ;; if there's no col info, we cannot judge if it's spurious/not + ;; (current-column) never goes past the last column in the actual line, + ;; so if it's <, then the message had spurious info: + (>= (1+ (current-column)) + col)) + (let ((begin (progn (if col (cider--goto-expression-start) (back-to-indentation)) + (point))) + (end (progn (if col (forward-list) (move-end-of-line nil)) + (point)))) + (list begin end buffer))))))))))))) + +(defun cider-handle-compilation-errors (message eval-buffer &optional no-jump) + "Highlight and jump to compilation error extracted from MESSAGE, honor NO-JUMP. EVAL-BUFFER is the buffer that was current during user's interactive evaluation command. Honor `cider-auto-jump-to-error'." (when-let* ((loc (cider--find-last-error-location message)) @@ -641,10 +570,11 @@ evaluation command. Honor `cider-auto-jump-to-error'." (info (cider-extract-error-info cider-compilation-regexp message))) (let* ((face (nth 3 info)) (note (nth 4 info)) - (auto-jump (if (eq cider-auto-jump-to-error 'errors-only) - (not (or (eq face 'cider-warning-highlight-face) - (string-match-p "warning" note))) - cider-auto-jump-to-error))) + (auto-jump (unless no-jump + (if (eq cider-auto-jump-to-error 'errors-only) + (not (or (eq face 'cider-warning-highlight-face) + (string-match-p "warning" note))) + cider-auto-jump-to-error)))) (overlay-put overlay 'cider-note-p t) (overlay-put overlay 'font-lock-face face) (overlay-put overlay 'cider-note note) @@ -666,24 +596,50 @@ evaluation command. Honor `cider-auto-jump-to-error'." ;;; Interactive evaluation handlers -(defun cider-insert-eval-handler (&optional buffer) - "Make an nREPL evaluation handler for the BUFFER. +(defun cider-insert-eval-handler (&optional buffer bounds source-buffer on-success-callback) + "Make an nREPL evaluation handler for the BUFFER, +BOUNDS representing the buffer bounds of the evaled input, +SOURCE-BUFFER the original buffer, +and ON-SUCCESS-CALLBACK an optional callback. + The handler simply inserts the result value in BUFFER." (let ((eval-buffer (current-buffer)) - (res "")) + (res "") + (failed nil) + (error-phase-requested nil)) ;; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request. (nrepl-make-response-handler (or buffer eval-buffer) + ;; value handler: (lambda (_buffer value) (with-current-buffer buffer (insert value)) (when cider-eval-register (setq res (concat res value)))) + ;; stdout handler: (lambda (_buffer out) (cider-repl-emit-interactive-stdout out)) + ;; stderr handler: (lambda (_buffer err) + (setq failed t) + (when (and source-buffer + (listp bounds)) ;; if it's a list, it represents bounds, otherwise it's a string (code) and we can't display the overlay + (with-current-buffer source-buffer + (let* ((phase (if error-phase-requested + nil + (setq error-phase-requested t) + (cider--error-phase-of-last-exception buffer))) + (end (or (car-safe (cdr-safe bounds)) bounds)) + (end (when end + (copy-marker end)))) + (cider--maybe-display-error-as-overlay phase err end)))) + (cider-handle-compilation-errors err eval-buffer)) + ;; done handler: (lambda (_buffer) (when cider-eval-register - (set-register cider-eval-register res)))))) + (set-register cider-eval-register res)) + (when (and (not failed) + on-success-callback) + (funcall on-success-callback)))))) (defun cider--emit-interactive-eval-output (output repl-emit-function) "Emit output resulting from interactive code evaluation. @@ -728,6 +684,66 @@ REPL buffer. This is controlled via (cider--make-fringe-overlay (point))) (scan-error nil))))) +(defun cider--error-phase-of-last-exception (buffer) + "Returns the :phase of the latest exception associated to BUFFER, if any." + (when (cider-clojure-compilation-error-phases) + (when-let ((conn (with-current-buffer buffer + (cider-current-repl)))) + (when (cider-nrepl-op-supported-p "analyze-last-stacktrace" conn) + (let ((nrepl-sync-request-timeout 4)) ;; ensure that this feature cannot possibly create an overly laggy UX + (when-let* ((result (nrepl-send-sync-request (thread-last (map-merge 'list + '(("op" "analyze-last-stacktrace")) + (cider--nrepl-print-request-map fill-column)) + (seq-mapcat #'identity)) + conn + 'abort-on-input ;; favor responsiveness over this feature, in case something went wrong. + ))) + (nrepl-dict-get result "phase"))))))) + +(defcustom cider-inline-error-message-function #'cider--shorten-error-message + "A function that will shorten a given error message, +as shown in overlays / the minibuffer (per `cider-use-overlays'). + +The function takes a single arg. You may want to use `identity', +for leaving the message as-is." + :type 'boolean + :group 'cider + :package-version '(cider . "1.19.0")) + +(defun cider--shorten-error-message (err) + "Removes from ERR the prefix matched by `cider-clojure-compilation-regexp', +and the suffix matched by `cider-module-info-regexp'." + (thread-last err + (replace-regexp-in-string cider-clojure-compilation-regexp + "") + (replace-regexp-in-string cider-module-info-regexp + "") + (string-trim))) + +(defun cider--maybe-display-error-as-overlay (phase err end) + "Possibly display ERR as an overlay honoring END, +depending on the PHASE." + (when (and (or + ;; if we won't show *cider-error*, because of configuration, the overlay is adequate because it compensates for the lack of info in a compact manner: + (not cider-show-error-buffer) + (not (cider-connection-has-capability-p 'jvm-compilation-errors)) + ;; if we won't show *cider-error*, because of an ignored phase, the overlay is adequate: + (and cider-show-error-buffer + (member phase (cider-clojure-compilation-error-phases)))) + ;; Only show overlays for things that do look like an exception (#3587): + ;; Note: only applicable to JVM Clojure error messages (#3687) + (if (cider-runtime-clojure-p) + (or (string-match-p cider-clojure-runtime-error-regexp err) + (string-match-p cider-clojure-compilation-error-regexp err)) + t)) + ;; Display errors as temporary overlays + (let ((cider-result-use-clojure-font-lock nil) + (trimmed-err (funcall cider-inline-error-message-function err))) + (cider--display-interactive-eval-result trimmed-err + 'error + end + 'cider-error-overlay-face)))) + (declare-function cider-inspect-last-result "cider-inspector") (defun cider-interactive-eval-handler (&optional buffer place) "Make an interactive eval handler for BUFFER. @@ -743,24 +759,36 @@ when `cider-auto-inspect-after-eval' is non-nil." (beg (when beg (copy-marker beg))) (end (when end (copy-marker end))) (fringed nil) - (res "")) + (res "") + (error-phase-requested nil)) ;; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request. (nrepl-make-response-handler (or buffer eval-buffer) + ;; value handler: (lambda (_buffer value) (setq res (concat res value)) - (cider--display-interactive-eval-result res end)) + (cider--display-interactive-eval-result res 'value end)) + ;; stdout handler: (lambda (_buffer out) (cider-emit-interactive-eval-output out)) - (lambda (_buffer err) + ;; stderr handler: + (lambda (buffer err) (cider-emit-interactive-eval-err-output err) - (when (or (not cider-show-error-buffer) - (not (cider-connection-has-capability-p 'jvm-compilation-errors))) - - ;; Display errors as temporary overlays - (let ((cider-result-use-clojure-font-lock nil)) - (cider--display-interactive-eval-result - err end 'cider-error-overlay-face))) - (cider-handle-compilation-errors err eval-buffer)) + (let ((phase (if error-phase-requested + nil + (setq error-phase-requested t) + (cider--error-phase-of-last-exception buffer)))) + + (cider--maybe-display-error-as-overlay phase err end) + + (cider-handle-compilation-errors err + eval-buffer + ;; we prevent jumping behavior on compilation errors, + ;; because lines tend to be spurious (e.g. 0:0) + ;; and because on compilation errors, normally + ;; the error is 'right there' in the current line + ;; and needs no jumping: + phase))) + ;; done handler: (lambda (buffer) (if beg (unless fringed @@ -780,10 +808,11 @@ when `cider-auto-inspect-after-eval' is non-nil." "Make a load file handler for BUFFER. Optional argument DONE-HANDLER lambda will be run once load is complete." (let ((eval-buffer (current-buffer)) - (res "")) + (res "") + (error-phase-requested nil)) ;; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request. (nrepl-make-response-handler (or buffer eval-buffer) (lambda (buffer value) - (cider--display-interactive-eval-result value) + (cider--display-interactive-eval-result value 'value) (when cider-eval-register (setq res (concat res value))) (when (buffer-live-p buffer) @@ -794,7 +823,20 @@ Optional argument DONE-HANDLER lambda will be run once load is complete." (cider-emit-interactive-eval-output value)) (lambda (_buffer err) (cider-emit-interactive-eval-err-output err) - (cider-handle-compilation-errors err eval-buffer)) + ;; 1.- Jump to the error line: + (cider-handle-compilation-errors err eval-buffer) + (with-current-buffer eval-buffer + (let* ((phase (if error-phase-requested + nil + (setq error-phase-requested t) + (cider--error-phase-of-last-exception buffer))) + ;; 2.- Calculate the overlay position, which is the point (per the previous jump), + ;; and then end-of-line (for ensuring the overlay will be rendered properly): + (end (save-excursion + (when (equal cider-result-overlay-position 'at-eol) + (end-of-line)) + (point)))) + (cider--maybe-display-error-as-overlay phase err end)))) (lambda (buffer) (when cider-eval-register (set-register cider-eval-register res)) @@ -888,24 +930,55 @@ COMMENT-POSTFIX is the text to output after the last line." (lambda (_buffer warning) (setq res (concat res warning)))))) -(defun cider-popup-eval-handler (&optional buffer) - "Make a handler for printing evaluation results in popup BUFFER. +(defun cider-popup-eval-handler (&optional buffer bounds source-buffer) + "Make a handler for printing evaluation results in popup BUFFER, +BOUNDS representing the buffer bounds of the evaled input, +and SOURCE-BUFFER the original buffer + This is used by pretty-printing commands." ;; NOTE: cider-eval-register behavior is not implemented here for performance reasons. ;; See https://github.com/clojure-emacs/cider/pull/3162 - (nrepl-make-response-handler - (or buffer (current-buffer)) - (lambda (buffer value) - (cider-emit-into-popup-buffer buffer (ansi-color-apply value) nil t)) - (lambda (_buffer out) - (cider-emit-interactive-eval-output out)) - (lambda (_buffer err) - (cider-emit-interactive-eval-err-output err)) - nil - nil - nil - (lambda (buffer warning) - (cider-emit-into-popup-buffer buffer warning 'font-lock-warning-face t)))) + (let ((chosen-buffer (or buffer (current-buffer))) + (error-phase-requested nil)) ;; avoid requesting the phase more than once - can happen if there are errors during the phase nrepl sync request. + (nrepl-make-response-handler + chosen-buffer + ;; value handler: + (lambda (buffer value) + (cider-emit-into-popup-buffer buffer (ansi-color-apply value) nil t)) + ;; stdout handler: + (lambda (_buffer out) + (cider-emit-interactive-eval-output out)) + ;; stderr handler: + (lambda (buffer err) + (cider-emit-interactive-eval-err-output err) + (when (and source-buffer + (listp bounds)) ;; if it's a list, it represents bounds, otherwise it's a string (code) and we can't display the overlay + (with-current-buffer source-buffer + (let* ((phase (if error-phase-requested + nil + (setq error-phase-requested t) + (cider--error-phase-of-last-exception buffer))) + (end (or (car-safe (cdr-safe bounds)) bounds)) + (end (when end + (copy-marker end)))) + (cider--maybe-display-error-as-overlay phase err end))))) + ;; done handler: + nil + ;; eval-error handler: + (lambda () + (when (and (buffer-live-p chosen-buffer) + (member (buffer-name chosen-buffer) + cider-ancillary-buffers)) + (with-selected-window (get-buffer-window chosen-buffer) + (cider-popup-buffer-quit-function t))) + ;; also call the default nrepl-err-handler, so that our custom behavior doesn't void the base behavior: + (when nrepl-err-handler + (funcall nrepl-err-handler))) + ;; content type handler: + nil + ;; truncated handler: + (lambda (buffer warning) + (cider-emit-into-popup-buffer buffer warning 'font-lock-warning-face t))))) ;;; Interactive valuation commands @@ -968,7 +1041,11 @@ arguments and only proceed with evaluation if it returns nil." (delete-overlay ov)))) (unless (and cider-interactive-eval-override (functionp cider-interactive-eval-override) - (funcall cider-interactive-eval-override form callback bounds)) + (condition-case _ + (funcall cider-interactive-eval-override form callback bounds additional-params) + (wrong-number-of-arguments + ;; fallback for backward compatibility + (funcall cider-interactive-eval-override form callback bounds)))) (cider-map-repls :auto (lambda (connection) (cider--prep-interactive-eval form connection) @@ -1195,27 +1272,31 @@ If INSERT-BEFORE is non-nil, insert before the form, otherwise afterwards." (declare-function cider-switch-to-repl-buffer "cider-mode") +(defun cider--eval-last-sexp-to-repl (switch-to-repl request-map) + "Evaluate the expression preceding point and insert its result in the REPL, +honoring SWITCH-TO-REPL, REQUEST-MAP." + (let ((bounds (cider-last-sexp 'bounds))) + (cider-interactive-eval nil + (cider-insert-eval-handler (cider-current-repl) + bounds + (current-buffer) + (lambda () + (when switch-to-repl + (cider-switch-to-repl-buffer)))) + bounds + request-map))) + (defun cider-eval-last-sexp-to-repl (&optional prefix) "Evaluate the expression preceding point and insert its result in the REPL. If invoked with a PREFIX argument, switch to the REPL buffer." (interactive "P") - (cider-interactive-eval nil - (cider-insert-eval-handler (cider-current-repl)) - (cider-last-sexp 'bounds) - (cider--nrepl-pr-request-map)) - (when prefix - (cider-switch-to-repl-buffer))) + (cider--eval-last-sexp-to-repl prefix (cider--nrepl-pr-request-map))) (defun cider-pprint-eval-last-sexp-to-repl (&optional prefix) "Evaluate expr before point and insert its pretty-printed result in the REPL. If invoked with a PREFIX argument, switch to the REPL buffer." (interactive "P") - (cider-interactive-eval nil - (cider-insert-eval-handler (cider-current-repl)) - (cider-last-sexp 'bounds) - (cider--nrepl-print-request-map fill-column)) - (when prefix - (cider-switch-to-repl-buffer))) + (cider--eval-last-sexp-to-repl prefix (cider--nrepl-print-request-map fill-column))) (defun cider-eval-print-last-sexp (&optional pretty-print) "Evaluate the expression preceding point. @@ -1233,7 +1314,7 @@ With an optional PRETTY-PRINT prefix it pretty-prints the result." "Pretty print FORM in popup buffer." (let* ((buffer (current-buffer)) (result-buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 'ancillary)) - (handler (cider-popup-eval-handler result-buffer))) + (handler (cider-popup-eval-handler result-buffer form buffer))) (with-current-buffer buffer (cider-interactive-eval (when (stringp form) form) handler @@ -1273,6 +1354,17 @@ buffer, else display in a popup buffer." 'help-echo "Breakpoint. Reevaluate this form to remove it." :type 'cider-fragile)))) +(defun cider-eval-dwim (&optional debug-it) + "If no region is active, call `cider-eval-defun-at-point' with DEBUG-IT. +If a region is active, run `cider-eval-region'. + +Always binds `clojure-toplevel-inside-comment-form' to t." + (interactive "P") + (let ((clojure-toplevel-inside-comment-form t)) + (if (use-region-p) + (cider-eval-region (region-beginning) (region-end)) + (cider-eval-defun-at-point debug-it)))) + (defun cider-eval-defun-at-point (&optional debug-it) "Evaluate the current toplevel form, and print result in the minibuffer. With DEBUG-IT prefix argument, also debug the entire form as with the @@ -1280,7 +1372,7 @@ command `cider-debug-defun-at-point'." (interactive "P") (let ((inline-debug (eq 16 (car-safe debug-it)))) (when debug-it - (when (derived-mode-p 'clojurescript-mode) + (when (cider-clojurescript-major-mode-p) (when (y-or-n-p (concat "The debugger doesn't support ClojureScript yet, and we need help with that." " \nWould you like to read the Feature Request?")) (browse-url "https://github.com/clojure-emacs/cider/issues/1416")) @@ -1316,7 +1408,7 @@ buffer. It constructs an expression to eval in the following manner: - It balances this bit of code by closing all open expressions; - It evaluates the resulting code using `cider-interactive-eval'." (interactive "P") - (let* ((beg-of-defun (save-excursion (beginning-of-defun) (point))) + (let* ((beg-of-defun (save-excursion (beginning-of-defun-raw) (point))) (code (buffer-substring-no-properties beg-of-defun (point))) (code (cider--insert-closing-delimiters code))) (cider-interactive-eval code @@ -1369,7 +1461,7 @@ buffer, else display in a popup buffer." "Evaluate the current buffer's namespace form. When UNDEF-ALL is non-nil, unmap all symbols and aliases first." (interactive "P") - (when-let ((ns (clojure-find-ns))) + (when-let ((ns (cider-get-ns-name))) (save-excursion (goto-char (match-beginning 0)) (when undef-all @@ -1455,6 +1547,7 @@ passing arguments." (define-key map (kbd "w") #'cider-eval-last-sexp-and-replace) (define-key map (kbd "r") #'cider-eval-region) (define-key map (kbd "n") #'cider-eval-ns-form) + (define-key map (kbd "s") #'cider-eval-dwim) (define-key map (kbd "d") #'cider-eval-defun-at-point) (define-key map (kbd "e") #'cider-eval-last-sexp) (define-key map (kbd "q") #'cider-tap-last-sexp) @@ -1473,6 +1566,7 @@ passing arguments." (define-key map (kbd "C-w") #'cider-eval-last-sexp-and-replace) (define-key map (kbd "C-r") #'cider-eval-region) (define-key map (kbd "C-n") #'cider-eval-ns-form) + (define-key map (kbd "C-s") #'cider-eval-dwim) (define-key map (kbd "C-d") #'cider-eval-defun-at-point) (define-key map (kbd "C-e") #'cider-eval-last-sexp) (define-key map (kbd "C-q") #'cider-tap-last-sexp) @@ -1561,9 +1655,15 @@ all ns aliases and var mappings from the namespace before reloading it." Useful when the running nREPL on remote host. When UNDEF-ALL is non-nil or called with \\[universal-argument], removes all ns aliases and var mappings from the namespaces being reloaded" - (interactive "DLoad files beneath directory: \nP") - (mapcar (lambda (file) (cider-load-file file undef-all)) - (directory-files-recursively directory "\\.clj[cs]?$"))) + (interactive "DRecursively load files in directory: \nP") + (let* ((files (directory-files-recursively directory "\\.clj[cs]?$")) + (reporter (make-progress-reporter "Loading files" 0 (length files)))) + (seq-do-indexed (lambda (file idx) + (let ((inhibit-message t)) + (cider-load-file file undef-all)) + (progress-reporter-update reporter (1+ idx) file)) + files) + (progress-reporter-done reporter))) (defalias 'cider-eval-file #'cider-load-file "A convenience alias as some people are confused by the load-* names.") diff --git a/elpa/cider-20230707.640/cider-find.el b/elpa/cider-20241203.1607/cider-find.el similarity index 70% rename from elpa/cider-20230707.640/cider-find.el rename to elpa/cider-20241203.1607/cider-find.el index 6e882ae3..0af706e2 100644 --- a/elpa/cider-20230707.640/cider-find.el +++ b/elpa/cider-20241203.1607/cider-find.el @@ -1,6 +1,6 @@ ;;; cider-find.el --- Functionality for finding things -*- lexical-binding: t -*- -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Bozhidar Batsov ;; Artur Malabarba @@ -192,13 +192,71 @@ the results to be displayed in a different window." (ns (completing-read "Find namespace: " namespaces))) (cider--find-ns ns (cider--open-other-window-p arg))))) +(defun cider--find-keyword-in-buffer (buffer kw) + "Returns the point where `KW' is found in `BUFFER'. +Returns nil of no matching keyword is found. +Occurrences of `KW' as (or within) strings, comments, #_ forms, symbols, etc +are disregarded." + (with-current-buffer buffer + (save-excursion + (goto-char (point-min)) + (font-lock-ensure) ;; make the forthcoming `text-properties-at` call useful + (let ((found nil) + (continue t) + (current-point (point))) + (while continue + (setq found (and (search-forward-regexp kw nil 'noerror) + (member 'clojure-keyword-face (text-properties-at (1- (point)))))) + (setq continue (and (not found) + ;; if we haven't moved, there's nothing left to search: + (not (equal current-point (point))))) + (setq current-point (point))) + (when found + current-point))))) + +(defun cider--find-keyword-loc (kw) + "Given `KW', returns an nrepl-dict with url, dest, dest-point. + +Returns the dict in all cases. `dest-point' indicates success: +integer on successful finds, nil otherwise." + (let* ((simple-ns-qualifier (and + (string-match "^:\\(.+\\)/.+$" kw) + (match-string 1 kw))) + (auto-resolved-ns-qualifier (and + (string-match "^::\\(.+\\)/.+$" kw) + (match-string 1 kw))) + (kw-ns (or (and auto-resolved-ns-qualifier + (or (cider-resolve-alias (cider-current-ns) auto-resolved-ns-qualifier) + (user-error "Could not resolve alias: %S" auto-resolved-ns-qualifier))) + (and (string-match "^::" kw) + (cider-current-ns :no-default)) + simple-ns-qualifier + (user-error "Not a ns-qualified keyword: %S" kw))) + (kw-name (replace-regexp-in-string "^:+\\(.+/\\)?" "" kw)) + (beginning-of-symbol "\\_<") + (end-of-symbol "\\_>") ;; important: if searching for foo, we don't want to match foobar (a larger symbol) + (kw-to-find (concat beginning-of-symbol + "\\(" + (concat "::" kw-name) + "\\|" + (concat ":" kw-ns "/" kw-name) + "\\)" + end-of-symbol))) + (let* ((url (when kw-ns + (cider-sync-request:ns-path kw-ns t))) + (dest (when url + (cider-find-file url))) + (dest-point (when dest + (cider--find-keyword-in-buffer dest kw-to-find)))) + (nrepl-dict "url" url "dest" dest "dest-point" dest-point)))) + ;;;###autoload (defun cider-find-keyword (&optional arg) - "Find the namespace of the keyword at point and its first occurrence there. + "Find the namespace of the keyword at point and its primary occurrence there. For instance - if the keyword at point is \":cider.demo/keyword\", this command -would find the namespace \"cider.demo\" and afterwards find the first mention -of \"::keyword\" there. +would find the namespace \"cider.demo\" and afterwards find the primary (most relevant or first) +mention of \"::keyword\" there. Prompt according to prefix ARG and `cider-prompt-for-symbol'. A single or double prefix argument inverts the meaning of @@ -213,91 +271,15 @@ thing at point." (format "Keyword (default %s): " kw-at-point) nil nil kw-at-point) kw-at-point))) - (ns-qualifier (and - (string-match "^:+\\(.+\\)/.+$" kw) - (match-string 1 kw))) - (kw-ns (if ns-qualifier - (cider-resolve-alias (cider-current-ns) ns-qualifier) - (cider-current-ns))) - (kw-to-find (concat "::" (replace-regexp-in-string "^:+\\(.+/\\)?" "" kw)))) - - (when (and ns-qualifier (string= kw-ns (cider-current-ns))) - (error "Could not resolve alias `%s' in `%s'" ns-qualifier (cider-current-ns))) - (cider--find-ns kw-ns arg) - (search-forward-regexp kw-to-find nil 'noerror))) - -;;; xref integration -;; -;; xref.el was introduced in Emacs 25.1. -;; CIDER's xref backend was added in CIDER 1.2. -(defun cider--xref-backend () - "Used for xref integration." - ;; Check if `cider-nrepl` middleware is loaded. Allows fallback to other xref - ;; backends, if cider-nrepl is not loaded. - (when (cider-nrepl-op-supported-p "ns-path" nil 'skip-ensure) - 'cider)) - -(cl-defmethod xref-backend-identifier-at-point ((_backend (eql cider))) - "Return the relevant identifier at point." - (cider-symbol-at-point 'look-back)) - -(defun cider--var-to-xref-location (var) - "Get location of definition of VAR." - (when-let* ((info (cider-var-info var)) - (line (nrepl-dict-get info "line")) - (file (nrepl-dict-get info "file")) - (buf (cider--find-buffer-for-file file))) - (xref-make-buffer-location - buf - (with-current-buffer buf - (save-excursion - (goto-char 0) - (forward-line (1- line)) - (back-to-indentation) - (point)))))) - -(cl-defmethod xref-backend-definitions ((_backend (eql cider)) var) - "Find definitions of VAR." - (cider-ensure-connected) - (cider-ensure-op-supported "ns-path") - (when-let* ((loc (cider--var-to-xref-location var))) - (list (xref-make var loc)))) - -(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql cider))) - "Return the completion table for identifiers." - (cider-ensure-connected) - (when-let* ((ns (cider-current-ns)) - (results (cider-sync-request:ns-vars ns))) - results)) - -(cl-defmethod xref-backend-references ((_backend (eql cider)) var) - "Find references of VAR." - (cider-ensure-connected) - (cider-ensure-op-supported "fn-refs") - (when-let* ((ns (cider-current-ns)) - (results (cider-sync-request:fn-refs ns var))) - (mapcar (lambda (info) - (let* ((filename (nrepl-dict-get info "file")) - (column (nrepl-dict-get info "column")) - (line (nrepl-dict-get info "line")) - (loc (xref-make-file-location filename line column))) - (xref-make filename loc))) - results))) - -(cl-defmethod xref-backend-apropos ((_backend (eql cider)) pattern) - "Find all symbols that match regexp PATTERN." - (cider-ensure-connected) - (cider-ensure-op-supported "apropos") - (when-let* ((ns (cider-current-ns)) - (results (cider-sync-request:apropos pattern ns t t completion-ignore-case))) - (mapcar (lambda (info) - (let* ((symbol (nrepl-dict-get info "name")) - (loc (cider--var-to-xref-location symbol)) - (type (nrepl-dict-get info "type")) - (doc (nrepl-dict-get info "doc"))) - (xref-make (format "[%s] %s\n %s" (propertize symbol 'face 'bold) (capitalize type) doc) - loc))) - results))) + (before (buffer-list)) + (result (cider--find-keyword-loc kw))) + (nrepl-dbind-response result (dest dest-point) + (if dest-point + (cider-jump-to dest dest-point arg) + (progn + (unless (memq dest before) + (kill-buffer dest)) + (user-error "Couldn't find a definition for %S" kw)))))) (provide 'cider-find) ;;; cider-find.el ends here diff --git a/elpa/cider-20230707.640/cider-format.el b/elpa/cider-20241203.1607/cider-format.el similarity index 98% rename from elpa/cider-20230707.640/cider-format.el rename to elpa/cider-20241203.1607/cider-format.el index eeb3562c..2673430f 100644 --- a/elpa/cider-20230707.640/cider-format.el +++ b/elpa/cider-20241203.1607/cider-format.el @@ -1,6 +1,6 @@ ;;; cider-format.el --- Code and EDN formatting functionality -*- lexical-binding: t -*- -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Bozhidar Batsov ;; Artur Malabarba diff --git a/elpa/cider-20241203.1607/cider-inspector.el b/elpa/cider-20241203.1607/cider-inspector.el new file mode 100644 index 00000000..17567b55 --- /dev/null +++ b/elpa/cider-20241203.1607/cider-inspector.el @@ -0,0 +1,836 @@ +;;; cider-inspector.el --- Object inspector -*- lexical-binding: t -*- + +;; Copyright © 2013-2024 Vital Reactor, LLC +;; Copyright © 2014-2024 Bozhidar Batsov and CIDER contributors + +;; Author: Ian Eslick +;; Bozhidar Batsov + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Clojure object inspector inspired by SLIME. + +;;; Code: + +(require 'cl-lib) +(require 'easymenu) +(require 'seq) +(require 'cider-eval) + +;; =================================== +;; Inspector Key Map and Derived Mode +;; =================================== + +(defconst cider-inspector-buffer "*cider-inspect*") + +;;; Customization +(defgroup cider-inspector nil + "Presentation and behavior of the CIDER value inspector." + :prefix "cider-inspector-" + :group 'cider + :package-version '(cider . "0.10.0")) + +(defcustom cider-inspector-page-size 32 + "Default page size in paginated inspector view. +The page size can be also changed interactively within the inspector." + :type '(integer :tag "Page size" 32) + :package-version '(cider . "0.10.0")) + +(defcustom cider-inspector-max-atom-length 150 + "Default max length of nested atoms before they are truncated. +'Atom' here means any collection member that satisfies (complement coll?). +The max length can be also changed interactively within the inspector." + :type '(integer :tag "Max atom length" 150) + :package-version '(cider . "1.1.0")) + +(defcustom cider-inspector-max-coll-size 5 + "Default number of nested collection members to display before truncating. +The max size can be also changed interactively within the inspector." + :type '(integer :tag "Max collection size" 5) + :package-version '(cider . "1.1.0")) + +(defcustom cider-inspector-max-nested-depth 5 + "Default level of nesting for collections to display before truncating. +The max depth can be also changed interactively within the inspector." + :type '(integer :tag "Max nested collection depth" 5) + :package-version '(cider . "1.14.0")) + +(defvar cider-inspector-spacious-collections nil + "Controls whether the inspector renders values in collections spaciously.") + +(defcustom cider-inspector-fill-frame nil + "Controls whether the CIDER inspector window fills its frame." + :type 'boolean + :package-version '(cider . "0.15.0")) + +(defcustom cider-inspector-skip-uninteresting t + "Controls whether to skip over uninteresting values in the inspector. +Only applies to navigation with `cider-inspector-prev-inspectable-object' +and `cider-inspector-next-inspectable-object', values are still inspectable +by clicking or navigating to them by other means." + :type 'boolean + :package-version '(cider . "0.25.0")) + +(defcustom cider-inspector-auto-select-buffer t + "Determines if the inspector buffer should be auto selected." + :type 'boolean + :package-version '(cider . "0.27.0")) + +(defvar cider-inspector-uninteresting-regexp + (concat "nil" ; nils are not interesting + "\\|:" clojure--sym-regexp ; nor keywords + ;; FIXME: This range also matches ",", is it on purpose? + "\\|[+-.0-9]+") ; nor numbers. Note: BigInts, ratios etc. are interesting + "Regexp of uninteresting and skippable values.") + +(defun cider-inspector-open-thing-at-point () + "Opens the thing at point if found, without prompting." + (interactive) + (if-let ((url (thing-at-point 'url))) + (browse-url url) + (if-let ((filename (thing-at-point 'filename))) + (find-file filename)))) + +(defvar cider-inspector-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map cider-popup-buffer-mode-map) + (define-key map (kbd "RET") #'cider-inspector-operate-on-point) + (define-key map [mouse-1] #'cider-inspector-operate-on-click) + (define-key map "l" #'cider-inspector-pop) + (define-key map "g" #'cider-inspector-refresh) + (define-key map "o" #'cider-inspector-open-thing-at-point) + ;; Page-up/down + (define-key map [next] #'cider-inspector-next-page) + (define-key map [prior] #'cider-inspector-prev-page) + (define-key map " " #'cider-inspector-next-page) + (define-key map (kbd "M-SPC") #'cider-inspector-prev-page) + (define-key map (kbd "S-SPC") #'cider-inspector-prev-page) + (define-key map "s" #'cider-inspector-set-page-size) + (define-key map "a" #'cider-inspector-set-max-atom-length) + (define-key map "c" #'cider-inspector-set-max-coll-size) + (define-key map "C" #'cider-inspector-set-max-nested-depth) + (define-key map "v" #'cider-inspector-toggle-view-mode) + (define-key map "d" #'cider-inspector-def-current-val) + (define-key map "t" #'cider-inspector-tap-current-val) + (define-key map "1" #'cider-inspector-tap-at-point) + (define-key map [tab] #'cider-inspector-next-inspectable-object) + (define-key map "\C-i" #'cider-inspector-next-inspectable-object) + (define-key map "n" #'cider-inspector-next-inspectable-object) + (define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object) + (define-key map "p" #'cider-inspector-previous-inspectable-object) + (define-key map ":" #'cider-inspect-expr-from-inspector) + (define-key map "f" #'forward-char) + (define-key map "b" #'backward-char) + (define-key map "9" #'cider-inspector-previous-sibling) + (define-key map "0" #'cider-inspector-next-sibling) + ;; Emacs translates S-TAB to BACKTAB on X. + (define-key map [backtab] #'cider-inspector-previous-inspectable-object) + (easy-menu-define cider-inspector-mode-menu map + "Menu for CIDER's inspector." + `("CIDER Inspector" + ["Inspect" cider-inspector-operate-on-point] + ["Pop" cider-inspector-pop] + ["Refresh" cider-inspector-refresh] + "--" + ["Next Inspectable Object" cider-inspector-next-inspectable-object] + ["Previous Inspectable Object" cider-inspector-previous-inspectable-object] + "--" + ["Next Page" cider-inspector-next-page] + ["Previous Page" cider-inspector-prev-page] + ["Set Page Size" cider-inspector-set-page-size] + ["Set Max Atom Length" cider-inspector-set-max-atom-length] + ["Set Max Collection Size" cider-inspector-set-max-coll-size] + ["Define Var" cider-inspector-def-current-val] + "--" + ["Quit" cider-popup-buffer-quit-function] + )) + map)) + +(define-derived-mode cider-inspector-mode special-mode "Inspector" + "Major mode for inspecting Clojure data structures. + +\\{cider-inspector-mode-map}" + (set-syntax-table clojure-mode-syntax-table) + (setq-local electric-indent-chars nil) + (setq-local sesman-system 'CIDER) + (visual-line-mode 1)) + +;;;###autoload +(defun cider-inspect-last-sexp () + "Inspect the result of the the expression preceding point." + (interactive) + (cider-inspect-expr (cider-last-sexp) (cider-current-ns))) + +;;;###autoload +(defun cider-inspect-defun-at-point () + "Inspect the result of the \"top-level\" expression at point." + (interactive) + (cider-inspect-expr (cider-defun-at-point) (cider-current-ns))) + +;;;###autoload +(defun cider-inspect-last-result () + "Inspect the most recent eval result." + (interactive) + (cider-inspect-expr "*1" (cider-current-ns))) + +;;;###autoload +(defun cider-inspect (&optional arg) + "Inspect the result of the preceding sexp. + +With a prefix argument ARG it inspects the result of the \"top-level\" form. +With a second prefix argument it prompts for an expression to eval and inspect." + (interactive "p") + (pcase arg + (1 (cider-inspect-last-sexp)) + (4 (cider-inspect-defun-at-point)) + (16 (call-interactively #'cider-inspect-expr)))) + +(defvar cider-inspector-location-stack nil + "A stack used to save point locations in inspector buffers. +These locations are used to emulate `save-excursion' between +`cider-inspector-push' and `cider-inspector-pop' operations.") + +(defvar cider-inspector-page-location-stack nil + "A stack used to save point locations in inspector buffers. +These locations are used to emulate `save-excursion' between +`cider-inspector-next-page' and `cider-inspector-prev-page' operations.") + +(defvar cider-inspector-last-command nil + "Contains the value of the most recently used `cider-inspector-*' command. +This is used as an alternative to the built-in `last-command'. Whenever we +invoke any command through \\[execute-extended-command] and its variants, +the value of `last-command' is not set to the command it invokes.") + +(defvar cider-inspector--current-repl nil + "Contains the reference to the REPL where inspector was last invoked from. +This is needed for internal inspector buffer operations (push, +pop) to execute against the correct REPL session.") + +;; Operations +;;;###autoload +(defun cider-inspect-expr (expr ns) + "Evaluate EXPR in NS and inspect its value. +Interactively, EXPR is read from the minibuffer, and NS the +current buffer's namespace." + (interactive (list (cider-read-from-minibuffer "Inspect expression: " (cider-sexp-at-point)) + (cider-current-ns))) + (setq cider-inspector--current-repl (cider-current-repl)) + (let ((result (cider-sync-request:inspect-expr expr ns 'v2))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + +(defun cider-inspect-expr-from-inspector () + "Performs `cider-inspect-expr' in a way that is suitable from the Inspector itself. +In particular, it does not read `cider-sexp-at-point'." + (interactive) + (let* ((ns (cider-current-ns)) + (prompt (format "Inspect expression in %s" + (substring-no-properties (funcall cider-repl-prompt-function ns))))) + (cider-inspect-expr (cider-read-from-minibuffer prompt nil 'skip-colon) + ns))) + +(defun cider-inspector-pop () + "Pop the last value off the inspector stack and render it. +See `cider-sync-request:inspect-pop' and `cider-inspector--render-value'." + (interactive) + (setq cider-inspector-last-command 'cider-inspector-pop) + (let ((result (cider-sync-request:inspect-pop 'v2))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + +(defun cider-inspector-push (idx) + "Inspect the value at IDX in the inspector stack and render it. +See `cider-sync-request:inspect-push' and `cider-inspector--render-value'" + (interactive) + (let ((result (cider-sync-request:inspect-push idx 'v2))) + (when (nrepl-dict-get result "value") + (push (point) cider-inspector-location-stack) + (cider-inspector--render-value result 'v2) + (cider-inspector-next-inspectable-object 1)))) + +(defun cider-inspector-inspect-last-exception (index) + "Inspects the exception in the cause stack identified by INDEX." + (interactive) + (cl-assert (numberp index)) + (setq cider-inspector--current-repl (cider-current-repl)) + (let ((result (cider-sync-request:inspect-last-exception index 'v2))) + (when (nrepl-dict-get result "value") + (push (point) cider-inspector-location-stack) + (cider-inspector--render-value result 'v2) + (cider-inspector-next-inspectable-object 1)))) + +(defun cider-inspector-previous-sibling () + "Inspect the previous sibling value within a sequential parent. +See `cider-sync-request:inspect-previous-sibling' and `cider-inspector--render-value'" + (interactive) + (let ((result (cider-sync-request:inspect-previous-sibling 'v2))) + (when (nrepl-dict-get result "value") + (push (point) cider-inspector-location-stack) + (cider-inspector--render-value result 'v2) + (cider-inspector-next-inspectable-object 1)))) + +(defun cider-inspector-next-sibling () + "Inspect the next sibling value within a sequential parent. +See `cider-sync-request:inspect-next-sibling' and `cider-inspector--render-value'" + (interactive) + (let ((result (cider-sync-request:inspect-next-sibling 'v2))) + (when (nrepl-dict-get result "value") + (push (point) cider-inspector-location-stack) + (cider-inspector--render-value result 'v2) + (cider-inspector-next-inspectable-object 1)))) + +(defun cider-inspector--refresh-with-opts (&rest opts) + "Invokes `inspect-refresh' op with supplied extra OPTS. +Re-renders the currently inspected value." + (let ((result (cider-nrepl-send-sync-request `("op" "inspect-refresh" ,@opts) + cider-inspector--current-repl))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + +(defun cider-inspector-refresh () + "Re-render the currently inspected value. +See `cider-sync-request:inspect-refresh' and `cider-inspector--render-value'" + (interactive) + (cider-inspector--refresh-with-opts)) + +(defun cider-inspector-next-page () + "Jump to the next page when inspecting a paginated sequence/map. + +Does nothing if already on the last page." + (interactive) + (push (point) cider-inspector-page-location-stack) + (let ((result (cider-sync-request:inspect-next-page 'v2))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + +(defun cider-inspector-prev-page () + "Jump to the previous page when expecting a paginated sequence/map. + +Does nothing if already on the first page." + (interactive) + (setq cider-inspector-last-command 'cider-inspector-prev-page) + (let ((result (cider-sync-request:inspect-prev-page 'v2))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + +(defun cider-inspector-set-page-size (page-size) + "Set the page size in pagination mode to the specified PAGE-SIZE. + +Current page will be reset to zero." + (interactive (list (read-number "Page size: " cider-inspector-page-size))) + (cider-inspector--refresh-with-opts "page-size" page-size)) + +(defun cider-inspector-set-max-atom-length (max-length) + "Set the max length of nested atoms to MAX-LENGTH." + (interactive (list (read-number "Max atom length: " cider-inspector-max-atom-length))) + (cider-inspector--refresh-with-opts "max-atom-length" max-length)) + +(defun cider-inspector-set-max-coll-size (max-size) + "Set the number of nested collection members to display before truncating. +MAX-SIZE is the new value." + (interactive (list (read-number "Max collection size: " cider-inspector-max-coll-size))) + (cider-inspector--refresh-with-opts "max-coll-size" max-size)) + +(defun cider-inspector-set-max-nested-depth (max-nested-depth) + "Set the level of nesting for collections to display beflore truncating. +MAX-NESTED-DEPTH is the new value." + (interactive (list (read-number "Max nested depth: " cider-inspector-max-nested-depth))) + (cider-inspector--refresh-with-opts "max-nested-depth" max-nested-depth)) + +(defun cider-inspector-toggle-view-mode () + "Toggle the view mode of the inspector between normal and object view mode." + (interactive) + (let ((result (cider-nrepl-send-sync-request `("op" "inspect-toggle-view-mode") + cider-inspector--current-repl))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + +(defcustom cider-inspector-preferred-var-names nil + "The preferred var names to be suggested by `cider-inspector-def-current-val'. + +If you choose a different one while completing interactively, +it will be included (in the first position) the next time +you use `cider-inspector-def-current-val'." + :type '(repeat string) + :group 'cider + :package-version '(cider . "1.8.0")) + +(defun cider-inspector--read-var-name-from-user (ns) + "Reads a var name from the user, to be defined within NS. +Grows `cider-inspector-preferred-var-names' if the user chose a new name, +making that new name take precedence for subsequent usages." + (let ((v (completing-read (format "Name of the var to be defined in ns %s: " ns) + cider-inspector-preferred-var-names))) + (unless (member v cider-inspector-preferred-var-names) + (setq cider-inspector-preferred-var-names (cons v cider-inspector-preferred-var-names))) + v)) + +(defun cider-inspector-def-current-val (var-name ns) + "Defines a var with VAR-NAME in current namespace. + +Doesn't modify current page. When called interactively NS defaults to +current-namespace." + (interactive (let ((ns (cider-current-ns))) + (list (cider-inspector--read-var-name-from-user ns) + ns))) + (when-let* ((result (cider-sync-request:inspect-def-current-val ns var-name 'v2))) + (cider-inspector--render-value result 'v2) + (message "Defined current inspector value as #'%s/%s" ns var-name))) + +(defun cider-inspector-tap-current-val () + "Sends the current Inspector current value to `tap>'." + (interactive) + ;; NOTE: we don't set `cider-inspector--current-repl', because we mean to tap the current value of an existing Inspector, + ;; so whatever repl was used for it, should be used here. + (if cider-inspector--current-repl + (let ((response (cider-sync-request:inspect-tap-current-val))) + (nrepl-dbind-response response (value err) + (if value + (message "Successfully tapped the current Inspector value") + (error "Could not tap the current Inspector value: %s" err)))) + (user-error "No CIDER session found"))) + +(defun cider-inspector-tap-at-point () + "Sends the current Inspector current sub-value (per POINT) to `tap>'." + (interactive) + ;; NOTE: we don't set `cider-inspector--current-repl', because we mean to tap the current value of an existing Inspector, + ;; so whatever repl was used for it, should be used here. + (if cider-inspector--current-repl + (seq-let (property value) (cider-inspector-property-at-point) + (pcase property + (`cider-value-idx + (let* ((idx value) + (response (cider-sync-request:inspect-tap-indexed idx))) + (nrepl-dbind-response response (value err) + (if value + (message "Successfully tapped the Inspector item at point") + (error "Could not tap the Inspector item at point: %s" err))))) + (_ (error "No object at point")))) + (user-error "No CIDER session found"))) + +;; nREPL interactions +(defun cider-sync-request:inspect-pop (&optional v2) + "Move one level up in the inspector stack, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first '("op" "inspect-pop") + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-push (idx &optional v2) + "Inspect the inside value specified by IDX, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first `("op" "inspect-push" + "idx" ,idx) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-previous-sibling (&optional v2) + "Inspect the previous sibling value within a sequential parent, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first `("op" "inspect-previous-sibling") + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +;;;###autoload +(defun cider-sync-request:inspect-last-exception (index &optional v2) + "Inspects the exception in the cause stack identified by INDEX, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (cl-assert (numberp index)) + (let ((result (thread-first `("op" "inspect-last-exception" + "index" ,index) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-next-sibling (&optional v2) + "Inspect the next sibling value within a sequential parent, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first `("op" "inspect-next-sibling") + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-refresh (&optional v2) + "Re-render the currently inspected value, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first '("op" "inspect-refresh") + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-next-page (&optional v2) + "Jump to the next page in paginated collection view, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first '("op" "inspect-next-page") + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-prev-page (&optional v2) + "Jump to the previous page in paginated collection view, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first '("op" "inspect-prev-page") + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-set-page-size (page-size &optional v2) + "Set the page size in paginated view to PAGE-SIZE, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (declare (obsolete "use `inspect-refresh' op instead." "1.15.0")) + (let ((result (thread-first `("op" "inspect-set-page-size" + "page-size" ,page-size) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-set-max-atom-length (max-length &optional v2) + "Set the max length of nested atoms to MAX-LENGTH, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (declare (obsolete "use `inspect-refresh' op instead." "1.15.0")) + (let ((result (thread-first `("op" "inspect-set-max-atom-length" + "max-atom-length" ,max-length) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-set-max-coll-size (max-size &optional v2) + "Set the number of nested collection members to display before truncating. +MAX-SIZE is the new value, V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (declare (obsolete "use `inspect-refresh' op instead." "1.15.0")) + (let ((result (thread-first `("op" "inspect-set-max-coll-size" + "max-coll-size" ,max-size) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-set-max-nested-depth (max-nested-depth &optional v2) + "Set the level of nesting for collections to display before truncating. +MAX-NESTED-DEPTH is the new value, V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (declare (obsolete "use `inspect-refresh' op instead." "1.15.0")) + (let ((result (thread-first `("op" "inspect-set-max-nested-depth" + "max-nested-depth" ,max-nested-depth) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-def-current-val (ns var-name &optional v2) + "Defines a var with VAR-NAME in NS with the current inspector value, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first `("op" "inspect-def-current-value" + "ns" ,ns + "var-name" ,var-name) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(defun cider-sync-request:inspect-tap-current-val () + "Sends current inspector value to tap>." + (cider-nrepl-send-sync-request '("op" "inspect-tap-current-value") cider-inspector--current-repl)) + +(defun cider-sync-request:inspect-tap-indexed (idx) + "Sends current inspector sub-value to tap>, per IDX." + (cl-assert idx) + (cider-nrepl-send-sync-request `("op" "inspect-tap-indexed" + "idx" ,idx) + cider-inspector--current-repl)) + +(defun cider-sync-request:inspect-expr (expr ns &optional v2) + "Evaluate EXPR in context of NS and inspect its result. +Set the page size in paginated view to PAGE-SIZE, maximum length of atomic +collection members to MAX-ATOM-LENGTH, and maximum size of nested collections to +MAX-COLL-SIZE if non nil, +V2 indicates if the entire response should be returned +instead of just its \"value\" entry." + (let ((result (thread-first + (append (nrepl--eval-request expr ns) + `("inspect" "true" + ,@(when cider-inspector-page-size + `("page-size" ,cider-inspector-page-size)) + ,@(when cider-inspector-max-atom-length + `("max-atom-length" ,cider-inspector-max-atom-length)) + ,@(when cider-inspector-max-coll-size + `("max-coll-size" ,cider-inspector-max-coll-size)) + ,@(when cider-inspector-max-nested-depth + `("max-nested-depth" ,cider-inspector-max-nested-depth)) + "spacious" ,(if cider-inspector-spacious-collections + "true" "false"))) + (cider-nrepl-send-sync-request cider-inspector--current-repl)))) + (if v2 + result + (nrepl-dict-get result "value")))) + +(declare-function cider-set-buffer-ns "cider-mode") + +;; Render Inspector from Structured Values +(defun cider-inspector--render-value (dict-or-value &optional v2) + "Render DICT-OR-VALUE, depending on V2." + (let* ((value (if v2 + (nrepl-dict-get dict-or-value "value") + dict-or-value)) + (fragments (when v2 + (nrepl-dict-get dict-or-value "doc-fragments"))) + (block-tags (when v2 + (nrepl-dict-get dict-or-value "doc-block-tags-fragments"))) + (ns (cider-current-ns)) + (font-size (when-let* ((b (get-buffer cider-inspector-buffer)) + (variable 'text-scale-mode-amount) + (continue (local-variable-p variable b))) + ;; The font size is lost between inspector 'screens', + ;; because on each re-rendering, we wipe everything, including the mode. + ;; Enabling cider-inspector-mode is the specific step that loses the font size. + (buffer-local-value variable b))) + (truncate-lines-defined (when-let* ((b (get-buffer cider-inspector-buffer))) + (local-variable-p 'truncate-lines b))) + (truncate-lines-p (when-let* ((b (get-buffer cider-inspector-buffer)) + (continue truncate-lines-defined)) + (buffer-local-value 'truncate-lines b)))) + (cider-make-popup-buffer cider-inspector-buffer 'cider-inspector-mode 'ancillary) + (cider-inspector-render cider-inspector-buffer value + :font-size font-size + :truncate-lines-defined truncate-lines-defined + :truncate-lines-p truncate-lines-p + :fragments fragments + :block-tags block-tags) + (cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer) + (when cider-inspector-fill-frame (delete-other-windows)) + (ignore-errors (cider-inspector-next-inspectable-object 1)) + (with-current-buffer cider-inspector-buffer + (cider-set-buffer-ns ns) + (when (eq cider-inspector-last-command 'cider-inspector-pop) + (setq cider-inspector-last-command nil) + ;; Prevents error message being displayed when we try to pop + ;; from the top-level of a data structure + (when cider-inspector-location-stack + (goto-char (pop cider-inspector-location-stack)))) + + (when (eq cider-inspector-last-command 'cider-inspector-prev-page) + (setq cider-inspector-last-command nil) + ;; Prevents error message being displayed when we try to + ;; go to a prev-page from the first page + (when cider-inspector-page-location-stack + (goto-char (pop cider-inspector-page-location-stack))))))) + +(cl-defun cider-inspector-render (buffer str &key font-size truncate-lines-defined truncate-lines-p fragments block-tags) + "Render STR in BUFFER." + (with-current-buffer buffer + (cider-inspector-mode) + (when font-size + (text-scale-set font-size)) + (when truncate-lines-defined + (setq-local truncate-lines truncate-lines-p)) + (let ((inhibit-read-only t)) + (condition-case nil + (cider-inspector-render* (car (read-from-string str)) + fragments + block-tags) + (error (insert "\nInspector error for: " str)))) + (goto-char (point-min)))) + +(defvar cider-inspector-looking-at-java-p nil) + +(defun cider-inspector-render* (elements &optional fragments block-tags) + "Render ELEMENTS, and FRAGMENTS, BLOCK-TAGS if present." + (setq cider-inspector-looking-at-java-p nil) + (dolist (el elements) + (cider-inspector-render-el* el)) + (when fragments + (insert "\n\n") + (insert (cider--render-docstring (list "doc-fragments" fragments + "doc-block-tags-fragments" block-tags))))) + +(defconst cider--inspector-java-headers + ;; NOTE "--- Static fields:" "--- Instance fields:" are for objects, + ;; and don't deserve Java syntax highlighting (they can contain a Clojure value like `:foo/bar`, for instance) + '("--- Interfaces:" + "--- Fields:" ;; rendered only for Class objects (and not other objects) - see previous comment + "--- Constructors:" + "--- Methods:" + "--- Imports:")) + +(defun cider-inspector-render-el* (el) + "Render EL." + (let ((header-p (or (member el cider--inspector-java-headers) + (and (stringp el) + (string-prefix-p "--- " el))))) + ;; Headers reset the Java syntax coloring: + (when header-p + (setq cider-inspector-looking-at-java-p nil)) + + (cond ((symbolp el) (insert (symbol-name el))) + ((stringp el) (insert (if cider-inspector-looking-at-java-p + (cider-font-lock-as 'java-mode el) + (let ((trimmed-el (replace-regexp-in-string (regexp-quote "") + "" + el))) + (propertize trimmed-el 'font-lock-face (if header-p + 'font-lock-comment-face + 'font-lock-keyword-face)))))) + ((and (consp el) (eq (car el) :newline)) + (insert "\n")) + ((and (consp el) (eq (car el) :value)) + (cider-inspector-render-value (cadr el) (cl-caddr el))) + (t (message "Unrecognized inspector object: %s" el)))) + + ;; Java-related headers indicate that the next elements to be rendered + ;; should be syntax-colored as Java: + (when (member el cider--inspector-java-headers) + (setq cider-inspector-looking-at-java-p t))) + +(defun cider-inspector-render-value (value idx) + "Render VALUE at IDX." + (cider-propertize-region + (list 'cider-value-idx idx + 'mouse-face 'highlight) + (cider-inspector-render-el* (cider-font-lock-as-clojure value)))) + + +;; =================================================== +;; Inspector Navigation (lifted from SLIME inspector) +;; =================================================== + +(defun cider-find-inspectable-object (direction limit) + "Find the next/previous inspectable object. +DIRECTION can be either 'next or 'prev. +LIMIT is the maximum or minimum position in the current buffer. + +Return a list of two values: If an object could be found, the +starting position of the found object and T is returned; +otherwise LIMIT and NIL is returned." + (let ((finder (cl-ecase direction + (next 'next-single-property-change) + (prev 'previous-single-property-change)))) + (let ((prop nil) (curpos (point))) + (while (and (not prop) (not (= curpos limit))) + (let ((newpos (funcall finder curpos 'cider-value-idx nil limit))) + (setq prop (get-text-property newpos 'cider-value-idx)) + (setq curpos newpos))) + (list curpos (and prop t))))) + +(defun cider-inspector-next-inspectable-object (arg) + "Move point to the next inspectable object. +With optional ARG, move across that many objects. +If ARG is negative, move backwards." + (interactive "p") + (let ((maxpos (point-max)) (minpos (point-min)) + (previously-wrapped-p nil)) + ;; Forward. + (while (> arg 0) + (seq-let (pos foundp) (cider-find-inspectable-object 'next maxpos) + (if foundp + (progn (goto-char pos) + (unless (and cider-inspector-skip-uninteresting + (looking-at-p cider-inspector-uninteresting-regexp)) + (setq arg (1- arg)) + (setq previously-wrapped-p nil))) + (if (not previously-wrapped-p) ; cycle detection + (progn (goto-char minpos) (setq previously-wrapped-p t)) + (error "No inspectable objects"))))) + ;; Backward. + (while (< arg 0) + (seq-let (pos foundp) (cider-find-inspectable-object 'prev minpos) + ;; CIDER-OPEN-INSPECTOR inserts the title of an inspector page + ;; as a presentation at the beginning of the buffer; skip + ;; that. (Notice how this problem can not arise in ``Forward.'') + (if (and foundp (/= pos minpos)) + (progn (goto-char pos) + (unless (and cider-inspector-skip-uninteresting + (looking-at-p cider-inspector-uninteresting-regexp)) + (setq arg (1+ arg)) + (setq previously-wrapped-p nil))) + (if (not previously-wrapped-p) ; cycle detection + (progn (goto-char maxpos) (setq previously-wrapped-p t)) + (error "No inspectable objects"))))))) + +(defun cider-inspector-previous-inspectable-object (arg) + "Move point to the previous inspectable object. +With optional ARG, move across that many objects. +If ARG is negative, move forwards." + (interactive "p") + (cider-inspector-next-inspectable-object (- arg))) + +(defun cider-inspector-property-at-point () + "Return property at point." + (let* ((properties '(cider-value-idx cider-range-button + cider-action-number)) + (find-property + (lambda (point) + (cl-loop for property in properties + for value = (get-text-property point property) + when value + return (list property value))))) + (or (funcall find-property (point)) + (funcall find-property (max (point-min) (1- (point))))))) + +(defun cider-inspector-operate-on-point () + "Invoke the command for the text at point. +1. If point is on a value then recursively call the inspector on +that value. +2. If point is on an action then call that action. +3. If point is on a range-button fetch and insert the range." + (interactive) + (seq-let (property value) (cider-inspector-property-at-point) + (pcase property + (`cider-value-idx + (cider-inspector-push value)) + ;; TODO: range and action handlers + (_ (error "No object at point"))))) + +(defun cider-inspector-operate-on-click (event) + "Move to EVENT's position and operate the part." + (interactive "@e") + (let ((point (posn-point (event-end event)))) + (cond ((and point + (or (get-text-property point 'cider-value-idx))) + (goto-char point) + (cider-inspector-operate-on-point)) + (t + (error "No clickable part here"))))) + +(provide 'cider-inspector) + +;;; cider-inspector.el ends here diff --git a/elpa/cider-20230707.640/cider-jar.el b/elpa/cider-20241203.1607/cider-jar.el similarity index 99% rename from elpa/cider-20230707.640/cider-jar.el rename to elpa/cider-20241203.1607/cider-jar.el index 66746426..006ad7ec 100644 --- a/elpa/cider-20230707.640/cider-jar.el +++ b/elpa/cider-20241203.1607/cider-jar.el @@ -1,6 +1,6 @@ ;;; cider-jar.el --- Jar functionality for Clojure -*- lexical-binding: t -*- -;; Copyright © 2022 Arne Brasseur +;; Copyright © 2022-2024 Arne Brasseur ;; ;; Author: Arne Brasseur diff --git a/elpa/cider-20230707.640/cider-log.el b/elpa/cider-20241203.1607/cider-log.el similarity index 93% rename from elpa/cider-20230707.640/cider-log.el rename to elpa/cider-20241203.1607/cider-log.el index fbe0106b..4f01f41c 100644 --- a/elpa/cider-20230707.640/cider-log.el +++ b/elpa/cider-20241203.1607/cider-log.el @@ -1,6 +1,6 @@ ;;; cider-log.el --- Log inspection functionality for Clojure -*- lexical-binding: t -*- -;; Copyright © 2023 Bozhidar Batsov and CIDER contributors +;; Copyright © 2023-2024 Bozhidar Batsov and CIDER contributors ;; Author: r0man @@ -37,12 +37,31 @@ (require 'transient) (defcustom cider-log-framework-name nil - "The name of the current log framework." + "The name of the default log framework. + +You may want to set this in .dir-locals.el, +for a more streamlined setup. + +Example values: \"Logback\", \"Timbre\"." :group 'cider :package-version '(cider . "1.8.0") :safe #'stringp :type 'string) +(defcustom cider-log-frameworks-buffer "*cider-log-frameworks*" + "The name of the log frameworks popup buffer." + :group 'cider + :package-version '(cider . "1.17") + :safe #'stringp + :type 'string) + +(defcustom cider-log-auto-select-frameworks-buffer t + "Whether to auto-select the log frameworks popup buffer." + :group 'cider + :package-version '(cider . "1.17") + :safe #'booleanp + :type 'boolean) + (defcustom cider-log-appender-id "cider-log" "The name of the default log appender." :group 'cider @@ -85,13 +104,20 @@ :safe #'integerp :type 'integer) -(defcustom cider-log-use-logview (fboundp 'logview-mode) - "Whether to use `logview-mode' or not." +(defcustom cider-log-use-logview t + "Whether to use `logview-mode'. + +It will not be used if the package hasn't been installed." :group 'cider :package-version '(cider . "1.8.0") :safe #'booleanp :type 'boolean) +(defun cider-log-use-logview () + "Whether to use `logview-mode'." + (and (fboundp 'logview-mode) + cider-log-use-logview)) + (defvar logview-mode-map) (declare-function logview--guess-submode "logview" () t) (declare-function logview-initialized-p "logview" () t) @@ -556,6 +582,8 @@ The KEYS are used to lookup the values and are joined by SEPARATOR." (when-let (appender (cider-log-appender-reload framework appender)) (cider-log-appender-consumer appender consumer))) +(declare-function cider-log-mode "cider-log") + (defun cider-log--consumer-add (framework appender consumer buffer) "Add the CONSUMER to the APPENDER of FRAMEWORK and write events to BUFFER." (cider-request:log-add-consumer @@ -567,7 +595,14 @@ The KEYS are used to lookup the values and are joined by SEPARATOR." (setq-local cider-log-framework framework) (setq-local cider-log-appender appender) (setq cider-log-consumer cider/log-add-consumer) - (switch-to-buffer buffer))) + (switch-to-buffer buffer) + (when (and cider-log-use-logview + (not (fboundp 'logview-mode))) + (message "[CIDER Log Mode] Please install the Logview package for best results.") + (cider--display-interactive-eval-result "Please install the Logview package for best results." + 'error + (point) + 'cider-error-overlay-face)))) ((member "cider/log-event" status) (let* ((consumer (nrepl-dict "id" cider/log-consumer)) (buffers (cider-log-consumer-buffers consumer))) @@ -580,7 +615,8 @@ The KEYS are used to lookup the values and are joined by SEPARATOR." (seq-doseq (buffer buffers) (with-current-buffer buffer (cider-log--insert-events buffer (list cider/log-event)) - (when (and cider-log-use-logview (not (logview-initialized-p))) + (when (and (cider-log-use-logview) + (not (logview-initialized-p))) (let ((framework cider-log-framework) (appender cider-log-appender) (consumer cider-log-consumer)) @@ -792,6 +828,7 @@ The KEYS are used to lookup the values and are joined by SEPARATOR." "Return the log event at point." (get-text-property (point) :cider-log-event)) +;;;###autoload (autoload 'cider-log-info "cider-log-info" "Show the Cider log current log buffer, framework, appender and consumer." t) (defun cider-log-info () "Show the current log buffer, framework, appender and consumer." (interactive) @@ -811,7 +848,9 @@ The KEYS are used to lookup the values and are joined by SEPARATOR." (defvar cider-log-mode-map (let ((map (make-sparse-keymap)) - (parent (if cider-log-use-logview logview-mode-map special-mode-map))) + (parent (if (cider-log-use-logview) + logview-mode-map + special-mode-map))) (set-keymap-parent map parent) (define-key map (kbd "C-c M-l a") #'cider-log-appender) (define-key map (kbd "C-c M-l c") #'cider-log-consumer) @@ -848,7 +887,7 @@ the CIDER Inspector and the CIDER stacktrace mode. \\{cider-log-mode-map}") -(if cider-log-use-logview +(if (cider-log-use-logview) (define-derived-mode cider-log-mode logview-mode "Cider Log" cider-log--mode-doc (cider-log--setup-mode)) (define-derived-mode cider-log-mode special-mode "Cider Log" cider-log--mode-doc @@ -1007,6 +1046,26 @@ the CIDER Inspector and the CIDER stacktrace mode. ;; Framework actions +(transient-define-suffix cider-log-show-frameworks () + "Show the available log frameworks in a buffer." + :description "Show frameworks in a buffer" + (interactive) + (let ((frameworks (cider-sync-request:log-frameworks))) + (with-current-buffer (cider-popup-buffer cider-log-frameworks-buffer + cider-log-auto-select-frameworks-buffer) + (read-only-mode -1) + (insert (with-temp-buffer + (insert (propertize (cider-propertize "Cider Log Frameworks" 'ns) 'ns t) "\n\n") + (dolist (framework frameworks) + (insert (propertize (cider-propertize (cider-log-framework-name framework) 'ns) 'ns t) "\n\n") + (insert (format " Website ......... %s\n" (cider-log-framework-website-url framework))) + (insert (format " Javadocs ........ %s\n" (cider-log-framework-javadoc-url framework))) + (insert (format " Levels .......... %s\n" (string-join (cider-log-framework-level-names framework) ", "))) + (newline)) + (buffer-string))) + (read-only-mode 1) + (goto-char (point-min))))) + (transient-define-suffix cider-log-browse-javadocs (framework) "Browse the Javadoc of the log FRAMEWORK." :description "Browse Java documentation" @@ -1153,12 +1212,17 @@ the CIDER Inspector and the CIDER stacktrace mode. (let ((inhibit-read-only t)) (erase-buffer))))) +(defun cider-log--switch-to-buffer (buffer) + "Switch to the Cider log event BUFFER." + (when (get-buffer-create buffer) + (switch-to-buffer-other-window buffer) + (get-buffer buffer))) + (transient-define-suffix cider-log-switch-to-buffer (buffer) "Switch to the Cider log event BUFFER." :description "Switch to the log event buffer" (interactive (list cider-log-buffer)) - (when (get-buffer-create buffer) - (switch-to-buffer-other-window buffer))) + (cider-log--switch-to-buffer buffer)) (transient-define-suffix cider-log--do-search-events (framework appender filters) "Search the log events of FRAMEWORK and APPENDER which match FILTERS." @@ -1190,6 +1254,7 @@ the CIDER Inspector and the CIDER stacktrace mode. (transient-define-prefix cider-log-framework (framework) "Show the Cider log framework menu." [["Cider Log Framework\n\nActions:" + ("a" cider-log-show-frameworks) ("b" cider-log-set-buffer) ("j" cider-log-browse-javadocs) ("s" cider-log-set-framework) @@ -1384,12 +1449,34 @@ the CIDER Inspector and the CIDER stacktrace mode. (cider-log--ensure-initialized framework appender) (transient-setup 'cider-log-event)) +;;;###autoload +(defun cider-log-show () + "Ensures the *cider-log* buffer is visible, +setting up a framework, appender and consumer if necessary. + +Honors the `cider-log-framework-name' customization variable. + +This function is offered as an alternative to workflows +based on `transient-mode'." + (interactive) + (cider-current-repl nil 'ensure) + (let ((framework (cider-log--framework)) + (appender (cider-log--appender)) + (new-default-directory (buffer-local-value 'default-directory (current-buffer)))) + (with-current-buffer (cider-log--switch-to-buffer cider-log-buffer) + (setq-local default-directory new-default-directory) ;; for Sesman + (cider-log--ensure-initialized framework appender) + (unless cider-log-consumer + (apply #'cider-log--ensure-initialized (cider-log--consumer-interactive-list)) + (call-interactively 'cider-log--do-add-consumer))))) + ;; Main Transient Menu ;;;###autoload (autoload 'cider-log "cider-log" "Show the Cider log menu." t) (transient-define-prefix cider-log (framework appender) "Show the Cider log menu." [["Framework Actions" + ("fa" cider-log-show-frameworks) ("fs" cider-log-set-framework) ("fb" cider-log-set-buffer) ("fj" cider-log-browse-javadocs) diff --git a/elpa/cider-20230707.640/cider-macroexpansion.el b/elpa/cider-20241203.1607/cider-macroexpansion.el similarity index 88% rename from elpa/cider-20230707.640/cider-macroexpansion.el rename to elpa/cider-20241203.1607/cider-macroexpansion.el index 6e4c52a8..e445c433 100644 --- a/elpa/cider-20230707.640/cider-macroexpansion.el +++ b/elpa/cider-20241203.1607/cider-macroexpansion.el @@ -1,7 +1,7 @@ ;;; cider-macroexpansion.el --- Macro expansion support -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -63,16 +63,19 @@ Possible values are: The default for DISPLAY-NAMESPACES is taken from `cider-macroexpansion-display-namespaces'." (cider-ensure-op-supported "macroexpand") - (thread-first `("op" "macroexpand" - "expander" ,expander - "code" ,expr - "ns" ,(cider-current-ns) - "display-namespaces" ,(or display-namespaces - (symbol-name cider-macroexpansion-display-namespaces))) - (nconc (when cider-macroexpansion-print-metadata - '("print-meta" "true"))) - (cider-nrepl-send-sync-request) - (nrepl-dict-get "expansion"))) + (let ((result (thread-first `("op" "macroexpand" + "expander" ,expander + "code" ,expr + "ns" ,(cider-current-ns) + "display-namespaces" ,(or display-namespaces + (symbol-name cider-macroexpansion-display-namespaces))) + (nconc (when cider-macroexpansion-print-metadata + '("print-meta" "true"))) + (cider-nrepl-send-sync-request)))) + (nrepl-dbind-response result (expansion status) + (if (member "macroexpand-error" status) + (user-error "Macroexpansion failed. Check *cider-error* for more details") + expansion)))) (defun cider-macroexpand-undo (&optional arg) "Undo the last macroexpansion, using `undo-only'. diff --git a/elpa/cider-20230707.640/cider-mode.el b/elpa/cider-20241203.1607/cider-mode.el similarity index 95% rename from elpa/cider-20230707.640/cider-mode.el rename to elpa/cider-20241203.1607/cider-mode.el index bfedce90..780a77ca 100644 --- a/elpa/cider-20230707.640/cider-mode.el +++ b/elpa/cider-20241203.1607/cider-mode.el @@ -1,7 +1,7 @@ ;;; cider-mode.el --- Minor mode for REPL interactions -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -33,15 +33,16 @@ (require 'clojure-mode) (require 'cider-eval) -(require 'cider-log) (require 'cider-test) ; required only for the menu (require 'cider-eldoc) (require 'cider-resolve) (require 'cider-doc) ; required only for the menu (require 'cider-profile) ; required only for the menu (require 'cider-completion) +(require 'cider-completion-context) (require 'cider-inspector) (require 'cider-find) +(require 'cider-xref-backend) (require 'subr-x) (defcustom cider-mode-line-show-connection t @@ -204,7 +205,8 @@ With a prefix argument, prompt for function to run instead of -main." (define-key map (kbd "C-e") #'cider-insert-last-sexp-in-repl) (define-key map (kbd "C-d") #'cider-insert-defun-in-repl) (define-key map (kbd "C-r") #'cider-insert-region-in-repl) - (define-key map (kbd "C-n") #'cider-insert-ns-form-in-repl))) + (define-key map (kbd "C-n") #'cider-insert-ns-form-in-repl) + map)) (defcustom cider-switch-to-repl-on-insert t "Whether to switch to the REPL when inserting a form into the REPL." @@ -336,6 +338,7 @@ If invoked with a prefix ARG eval the expression after inserting it." ["Eval last sexp and pretty-print to REPL" cider-pprint-eval-last-sexp-to-repl] ["Eval last sexp and pretty-print to comment" cider-pprint-eval-last-sexp-to-comment] "--" + ["Eval selected region if active, otherwise top-level sexp" cider-eval-dwim] ["Eval selected region" cider-eval-region] ["Eval ns form" cider-eval-ns-form] "--" @@ -530,9 +533,11 @@ higher precedence." (define-key map (kbd "C-c C-? C-d") #'cider-xref-fn-deps-select) (define-key map (kbd "C-c C-q") #'cider-quit) (define-key map (kbd "C-c M-r") #'cider-restart) + ;; NOTE: all cider-log* vars are autoloaded. Please do not add a require. (define-key map (kbd "C-c M-l a") #'cider-log-appender) (define-key map (kbd "C-c M-l c") #'cider-log-consumer) (define-key map (kbd "C-c M-l e") #'cider-log-event) + (define-key map (kbd "C-c M-l s") #'cider-log-show) (define-key map (kbd "C-c M-l f") #'cider-log-framework) (define-key map (kbd "C-c M-l i") #'cider-log-info) (define-key map (kbd "C-c M-l l") #'cider-log) @@ -545,14 +550,16 @@ higher precedence." (cider--menu-add-help-strings (symbol-value variable)))) map)) -;; This menu works as an easy entry-point into CIDER. Even if cider.el isn't -;; loaded yet, this will be shown in Clojure buffers next to the "Clojure" -;; menu. ;;;###autoload -(with-eval-after-load 'clojure-mode - (easy-menu-define cider-clojure-mode-menu-open clojure-mode-map +(defun cider--setup-menu-for-clojure-major-mode (mode-map) + "Setup a Cider menu for a Clojure major mode's MODE-MAP. + +This menu works as an easy entry-point into CIDER. Even if cider.el isn't +loaded yet, this will be shown in Clojure buffers next to the Clojure menu." + (easy-menu-define cider-clojure-mode-menu-open mode-map "Menu for Clojure mode. - This is displayed in `clojure-mode' buffers, if `cider-mode' is not active." + This is displayed in `clojure-mode' and `clojure-ts-mode' buffers, + if `cider-mode' is not active." `("CIDER" :visible (not cider-mode) ["Start a Clojure REPL" cider-jack-in-clj :help "Starts an nREPL server and connects a Clojure REPL to it."] @@ -567,6 +574,16 @@ higher precedence." "--" ["View user manual" cider-view-manual]))) +;;;###autoload +(with-eval-after-load 'clojure-mode + (cider--setup-menu-for-clojure-major-mode clojure-mode-map)) + +;;;###autoload +(with-eval-after-load 'clojure-ts-mode + (cider--setup-menu-for-clojure-major-mode + (with-suppressed-warnings ((free-vars clojure-ts-mode-map)) + clojure-ts-mode-map))) + ;;; Dynamic indentation (defcustom cider-dynamic-indentation t "Whether CIDER should aid Clojure(Script) indentation. @@ -617,7 +634,9 @@ that should be font-locked: `var': Any non-local var gets the `font-lock-variable-name-face'. `deprecated' (default): Any deprecated var gets the `cider-deprecated-face' face. - `core' (default): Any symbol from clojure.core (face depends on type). + `core' (default): Any symbol from clojure.core/cljs.core. The selected face will depend on type. + Note that while rendering `core', all types of vars (`macro', `function', `var', `deprecated') + will be honored, regardless of the user's customization value. The value can also be t, which means to font-lock as much as possible." :type '(choice (set :tag "Fine-tune font-locking" @@ -771,6 +790,8 @@ with the given LIMIT." macros functions vars instrumented traced) (cl-labels ((handle-plist (plist) + ;; Note that (memq 'function cider-font-lock-dynamically) and similar statements are evaluated differently + ;; for `core' - they're always truthy for `core' (see related core-handling code some lines below): (let ((do-function (memq 'function cider-font-lock-dynamically)) (do-var (memq 'var cider-font-lock-dynamically)) (do-macro (memq 'macro cider-font-lock-dynamically)) @@ -788,7 +809,7 @@ with the given LIMIT." ;; we catch that case too. ;; FIXME: This matches values too, not just keys. (when (seq-find (lambda (k) (and (stringp k) - (string-match (rx "clojure.tools.trace/traced" eos) k))) + (string-match (rx "orchard.trace/traced" eos) k))) meta) (push sym traced)) (when (and do-deprecated (nrepl-dict-get meta "deprecated")) @@ -802,6 +823,7 @@ with the given LIMIT." (push sym functions)) ((and do-var (not is-function) (not is-macro)) (push sym vars))))))))) + ;; For core members, we override `cider-font-lock-dynamically', since all core members should get the same treatment: (when (memq 'core cider-font-lock-dynamically) (let ((cider-font-lock-dynamically '(function var macro core deprecated))) (handle-plist core-plist))) @@ -951,7 +973,7 @@ before point." ;; If the inside of a `ns' form changed, reparse it from the start. (when (and (not (bobp)) (get-text-property (1- (point)) 'cider-block-dynamic-font-lock)) - (ignore-errors (beginning-of-defun))) + (ignore-errors (beginning-of-defun-raw))) (save-excursion ;; Move up until we reach a sexp that encloses the entire region (or ;; a top-level sexp), and set that as the new BEG. @@ -980,7 +1002,7 @@ before point." "Return a string of what would be displayed by `cider-docview-render'. SYM and INFO is passed to `cider-docview-render'" (with-temp-buffer - (cider-docview-render (current-buffer) sym info) + (cider-docview-render (current-buffer) sym info :compact :for-tooltip) ;; :compact because we don't want huge tooltips - especially for Java (goto-char (point-max)) (forward-line -1) (replace-regexp-in-string @@ -1016,7 +1038,7 @@ See \(info \"(elisp) Special Properties\")" (let* ((locals (nrepl-dict-get cider--debug-mode-response "locals")) (local-val (cadr (assoc sym locals)))) (format " with value:\n%s" local-val)))) - (let* ((info (cider-sync-request:info sym)) + (let* ((info (cider-sync-request:info sym nil nil (cider-completion-get-context t))) (candidates (nrepl-dict-get info "candidates"))) (if candidates (concat "There were ambiguities resolving this symbol:\n\n" @@ -1040,7 +1062,12 @@ property." ;;; Minor-mode definition -(defvar x-gtk-use-system-tooltips) + +(if (and (> emacs-major-version 28) + (not (boundp 'x-gtk-use-system-tooltips))) + ;; The x-gtk prefix has been dropped in Emacs 29 + (defvaralias 'x-gtk-use-system-tooltips 'use-system-tooltips) + (defvar x-gtk-use-system-tooltips)) ;;;###autoload (define-minor-mode cider-mode diff --git a/elpa/cider-20230707.640/cider-ns.el b/elpa/cider-20241203.1607/cider-ns.el similarity index 70% rename from elpa/cider-20230707.640/cider-ns.el rename to elpa/cider-20241203.1607/cider-ns.el index ee31bce5..70e06d0b 100644 --- a/elpa/cider-20230707.640/cider-ns.el +++ b/elpa/cider-20241203.1607/cider-ns.el @@ -1,6 +1,6 @@ ;;; cider-ns.el --- Namespace manipulation functionality -*- lexical-binding: t -*- -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Bozhidar Batsov ;; Artur Malabarba @@ -65,6 +65,7 @@ (require 'cider-eval) (require 'cider-popup) (require 'cider-stacktrace) +(require 'cider-util) (defcustom cider-ns-save-files-on-refresh 'prompt "Controls whether to prompt to save files before refreshing. @@ -77,7 +78,7 @@ If t, save the files without confirmation." :group 'cider :package-version '(cider . "0.15.0")) -(defcustom cider-ns-save-files-on-refresh-modes '(clojure-mode) +(defcustom cider-ns-save-files-on-refresh-modes '(clojure-mode clojure-ts-mode) "Controls which files might be saved before refreshing. If a list of modes, any buffers visiting files on the classpath whose major mode is derived from any of the modes might be saved. @@ -117,9 +118,53 @@ namespace-qualified function of zero arity." :group 'cider :package-version '(cider . "0.10.0")) +(defcustom cider-ns-code-reload-tool 'tools.namespace + "Which tool to use for ns refresh. +Current options: tools.namespace and clj-reload." + :group 'cider + :type '(choice (const :tag "tools.namespace https://github.com/clojure/tools.namespace" tools.namespace) + (const :tag "clj-reload https://github.com/tonsky/clj-reload" clj-reload)) + :package-version '(cider . "1.14.0")) + +(defun cider-ns--present-error (error) + "Render the `ERROR' stacktrace, +and jump to the adequate file/line location, +presenting the error message as an overlay." + (let* ((buf) + (jump-args (seq-some (lambda (cause-dict) ;; a dict representing an exception cause + (nrepl-dbind-response cause-dict (file-url line column) + (when (and file-url + ;; jars are unlikely sources of user errors, so we favor the next `cause-dict': + (not (string-prefix-p "jar:" file-url)) + line) + (setq buf (cider--find-buffer-for-file file-url)) + (list buf (cons line column))))) + error))) + (when jump-args + (apply #'cider-jump-to jump-args) + (when-let ((message (seq-some (lambda (cause-dict) + (nrepl-dbind-response cause-dict (message) + message)) + ;; `reverse' the causes as the first one typically is a CompilerException, which the second one is the actual exception: + (reverse error)))) + (with-current-buffer buf + (let ((cider-result-use-clojure-font-lock nil) + (trimmed-err (funcall cider-inline-error-message-function message))) + (cider--display-interactive-eval-result trimmed-err + 'error + (save-excursion + (end-of-defun) + (point)) + 'cider-error-overlay-face))))) + (cider--render-stacktrace-causes error) + ;; Select the window displaying the 'culprit' buffer so that the user can immediately fix it, + ;; as most times the displayed stacktrace doesn't need much inspection: + (when buf + (select-window (get-buffer-window buf))))) + (defun cider-ns-refresh--handle-response (response log-buffer) "Refresh LOG-BUFFER with RESPONSE." - (nrepl-dbind-response response (out err reloading status error error-ns after before) + (nrepl-dbind-response response (out err reloading progress status error error-ns after before) (cl-flet* ((log (message &optional face) (cider-emit-into-popup-buffer log-buffer message face t)) @@ -147,6 +192,9 @@ namespace-qualified function of zero arity." (reloading (log-echo (format "Reloading %s\n" reloading) 'font-lock-string-face)) + (progress + (log-echo progress 'font-lock-string-face)) + ((member "reloading" (nrepl-dict-keys response)) (log-echo "Nothing to reload\n" 'font-lock-string-face)) @@ -167,8 +215,9 @@ namespace-qualified function of zero arity." (with-current-buffer cider-ns-refresh-log-buffer (goto-char (point-max)))) - (when (member "error" status) - (cider--render-stacktrace-causes error)))) + (when (and (member "error" status) + error) + (cider-ns--present-error error)))) (defun cider-ns-refresh--save-modified-buffers () "Ensure any relevant modified buffers are saved before refreshing. @@ -185,6 +234,19 @@ Its behavior is controlled by `cider-ns-save-files-on-refresh' and (file-in-directory-p buffer-file-name dir)) dirs))))))) +(defun cider-ns--reload-op (op-name) + "Return the reload operation to use. +Based on OP-NAME and the value of cider-ns-code-reload-tool defcustom." + (list "op" + (if (eq cider-ns-code-reload-tool 'tools.namespace) + (cond ((string= op-name "reload") "refresh") + ((string= op-name "reload-all") "refresh-all") + ((string= op-name "reload-clear") "refresh-clear")) + + (cond ((string= op-name "reload") "cider.clj-reload/reload") + ((string= op-name "reload-all") "cider.clj-reload/reload-all") + ((string= op-name "reload-clear") "cider.clj-reload/reload-clear"))))) + ;;;###autoload (defun cider-ns-reload (&optional prompt) "Send a (require 'ns :reload) to the REPL. @@ -195,9 +257,9 @@ org.clojure/tools.namespace. See Commentary of this file for a longer list of differences. From the Clojure doc: \":reload forces loading of all the identified libs even if they are already loaded\"." (interactive "P") - (let ((ns (if prompt - (string-remove-prefix "'" (read-from-minibuffer "Namespace: " (clojure-find-ns))) - (clojure-find-ns)))) + (when-let ((ns (if prompt + (string-remove-prefix "'" (read-from-minibuffer "Namespace: " (cider-get-ns-name))) + (cider-get-ns-name)))) (cider-interactive-eval (format "(require '%s :reload)" ns)))) ;;;###autoload @@ -211,17 +273,18 @@ of differences. From the Clojure doc: \":reload-all implies :reload and also forces loading of all libs that the identified libs directly or indirectly load via require\"." (interactive "P") - (let ((ns (if prompt - (string-remove-prefix "'" (read-from-minibuffer "Namespace: " (clojure-find-ns))) - (clojure-find-ns)))) + (when-let ((ns (if prompt + (string-remove-prefix "'" (read-from-minibuffer "Namespace: " (cider-get-ns-name))) + (cider-get-ns-name)))) (cider-interactive-eval (format "(require '%s :reload-all)" ns)))) ;;;###autoload (defun cider-ns-refresh (&optional mode) - "Reload modified and unloaded namespaces on the classpath. + "Reload modified and unloaded namespaces, using the Reloaded Workflow. +Uses the configured 'refresh dirs' \(defaults to the classpath dirs). With a single prefix argument, or if MODE is `refresh-all', reload all -namespaces on the classpath unconditionally. +namespaces on the classpath dirs unconditionally. With a double prefix argument, or if MODE is `clear', clear the state of the namespace tracker before reloading. This is useful for recovering from @@ -236,9 +299,10 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and (interactive "p") (cider-ensure-connected) (cider-ensure-op-supported "refresh") + (cider-ensure-op-supported "cider.clj-reload/reload") (cider-ns-refresh--save-modified-buffers) (let ((clear? (member mode '(clear 16))) - (refresh-all? (member mode '(refresh-all 4))) + (all? (member mode '(refresh-all 4))) (inhibit-refresh-fns (member mode '(inhibit-fns -1)))) (cider-map-repls :clj (lambda (conn) @@ -253,11 +317,11 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and nil t)) (when clear? - (cider-nrepl-send-sync-request '("op" "refresh-clear") conn)) + (cider-nrepl-send-sync-request (cider-ns--reload-op "reload-clear") conn)) (cider-nrepl-send-request (thread-last (map-merge 'list - `(("op" ,(if refresh-all? "refresh-all" "refresh"))) + `(,(cider-ns--reload-op (if all? "reload-all" "reload"))) (cider--nrepl-print-request-map fill-column) (when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn) `(("before" ,cider-ns-refresh-before-fn))) diff --git a/elpa/cider-20230707.640/cider-overlays.el b/elpa/cider-20241203.1607/cider-overlays.el similarity index 92% rename from elpa/cider-20230707.640/cider-overlays.el rename to elpa/cider-20241203.1607/cider-overlays.el index c9f565a4..511f89a1 100644 --- a/elpa/cider-20230707.640/cider-overlays.el +++ b/elpa/cider-20241203.1607/cider-overlays.el @@ -1,6 +1,6 @@ ;;; cider-overlays.el --- Managing CIDER overlays -*- lexical-binding: t; -*- -;; Copyright © 2015-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2015-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; Author: Artur Malabarba @@ -70,8 +70,10 @@ font-locking it." (defcustom cider-use-overlays 'both "Whether to display evaluation results with overlays. If t, use overlays determined by `cider-result-overlay-position'. +If `errors-only', use overlays determined by `cider-result-overlay-position', +but only for error messages - other messages will be displayed on the echo area. If nil, display on the echo area. -If both, display on both places. +If `both', display on both places. Only applies to evaluation commands. To configure the debugger overlays, see `cider-debug-use-overlays'." @@ -290,9 +292,10 @@ overlay." ;;; Displaying eval result -(defun cider--display-interactive-eval-result (value &optional point overlay-face) +(defun cider--display-interactive-eval-result (value value-type &optional point overlay-face) "Display the result VALUE of an interactive eval operation. VALUE is syntax-highlighted and displayed in the echo area. +VALUE-TYPE is one of: `value', `error'. OVERLAY-FACE is the face applied to the overlay, which defaults to `cider-result-overlay-face' if nil. If POINT and `cider-use-overlays' are non-nil, it is also displayed in an @@ -300,18 +303,29 @@ overlay at the end of the line containing POINT. Note that, while POINT can be a number, it's preferable to be a marker, as that will better handle some corner cases where the original buffer is not focused." - (let* ((font-value (if cider-result-use-clojure-font-lock + (cl-assert (symbolp value-type)) ;; We assert because for avoiding confusion with the optional args. + (let* ((value (string-trim-right value)) + (font-value (if cider-result-use-clojure-font-lock (cider-font-lock-as-clojure value) value)) - (font-value (string-trim-right font-value)) - (used-overlay (when (and point cider-use-overlays) + (used-overlay (when (and point + cider-use-overlays + (if (equal 'error value-type) + t + (not (equal 'errors-only cider-use-overlays)))) (cider--make-result-overlay font-value :where point :duration cider-eval-result-duration - :prepend-face (or overlay-face 'cider-result-overlay-face))))) + :prepend-face (or overlay-face 'cider-result-overlay-face)))) + (msg (format "%s%s" cider-eval-result-prefix font-value)) + (max-msg-length (* (floor (* (frame-height) max-mini-window-height)) + (frame-width))) + (msg (if (> (string-width msg) max-msg-length) + (format "%s..." (substring msg 0 (- max-msg-length 3))) + msg))) (message "%s" - (propertize (format "%s%s" cider-eval-result-prefix font-value) + (propertize msg ;; The following hides the message from the echo-area, but ;; displays it in the Messages buffer. We only hide the message ;; if the user wants to AND if the overlay succeeded. diff --git a/elpa/cider-20241203.1607/cider-pkg.el b/elpa/cider-20241203.1607/cider-pkg.el new file mode 100644 index 00000000..31d48dbf --- /dev/null +++ b/elpa/cider-20241203.1607/cider-pkg.el @@ -0,0 +1,22 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "cider" "20241203.1607" + "Clojure Interactive Development Environment that Rocks." + '((emacs "26") + (clojure-mode "5.19") + (parseedn "1.2.1") + (queue "0.2") + (spinner "1.7") + (seq "2.22") + (sesman "0.3.2") + (transient "0.4.1")) + :url "https://github.com/clojure-emacs/cider" + :commit "588c5790f0c09f5c09076885e11a73eaef70c262" + :revdesc "588c5790f0c0" + :keywords '("languages" "clojure" "cider") + :authors '(("Tim King" . "kingtim@gmail.com") + ("Phil Hagelberg" . "technomancy@gmail.com") + ("Bozhidar Batsov" . "bozhidar@batsov.dev") + ("Artur Malabarba" . "bruce.connor.am@gmail.com") + ("Hugo Duncan" . "hugo@hugoduncan.org") + ("Steve Purcell" . "steve@sanityinc.com")) + :maintainers '(("Bozhidar Batsov" . "bozhidar@batsov.dev"))) diff --git a/elpa/cider-20230707.640/cider-popup.el b/elpa/cider-20241203.1607/cider-popup.el similarity index 60% rename from elpa/cider-20230707.640/cider-popup.el rename to elpa/cider-20241203.1607/cider-popup.el index a7fb26d6..0f0e43e0 100644 --- a/elpa/cider-20230707.640/cider-popup.el +++ b/elpa/cider-20241203.1607/cider-popup.el @@ -1,6 +1,6 @@ ;;; cider-popup.el --- Creating and quitting popup buffers -*- lexical-binding: t; -*- -;; Copyright © 2015-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2015-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; Author: Artur Malabarba @@ -46,29 +46,54 @@ If major MODE is non-nil, enable it for the popup buffer. If ANCILLARY is non-nil, the buffer is added to `cider-ancillary-buffers' and automatically removed when killed." (thread-first (cider-make-popup-buffer name mode ancillary) + (buffer-name) (cider-popup-buffer-display select))) -(defun cider-popup-buffer-display (buffer &optional select) - "Display BUFFER. -If SELECT is non-nil, select the BUFFER." - (let ((window (get-buffer-window buffer 'visible))) - (when window - (with-current-buffer buffer - (set-window-point window (point)))) - ;; If the buffer we are popping up is already displayed in the selected - ;; window, the below `inhibit-same-window' logic will cause it to be - ;; displayed twice - so we early out in this case. Note that we must check - ;; `selected-window', as async request handlers are executed in the context - ;; of the current connection buffer (i.e. `current-buffer' is dynamically - ;; bound to that). - (unless (eq window (selected-window)) - ;; Non nil `inhibit-same-window' ensures that current window is not covered - ;; Non nil `inhibit-switch-frame' ensures that the other frame is not selected - ;; if that's where the buffer is being shown. - (funcall (if select #'pop-to-buffer #'display-buffer) - buffer `(nil . ((inhibit-same-window . ,pop-up-windows) - (reusable-frames . visible)))))) - buffer) +(defun cider-popup-buffer-display (buffer-name &optional select) + "Display the buffer identified by BUFFER-NAME. +If SELECT is non-nil, select the buffer. + +You can customize how the window will be chosen/created +by adding BUFFER-NAME to the `special-display-buffer-names' list." + (let ((buffer-name (if (bufferp buffer-name) ;; ensure buffer-name is a string + (buffer-name buffer-name) + buffer-name))) + ;; if `buffer-name' belongs to `special-display-buffer-names', + ;; delegate to that mechanism the displaying of the buffer, + ;; otherwise the displaying would happen twice (ance through `special-display-buffer-names', + ;; another time through `cider-popup-buffer-display'): + (if (and (boundp 'special-display-buffer-names) + (seq-find (lambda (entry) + ;; entry can be either a list or a string + (equal (if (listp entry) (car entry) entry) buffer-name)) + special-display-buffer-names)) + (progn + (display-buffer buffer-name) + (when select + (when-let ((window (get-buffer-window buffer-name))) + (select-window window)))) + (let ((window (get-buffer-window buffer-name 'visible))) + (when window + (with-current-buffer buffer-name + (set-window-point window (point)))) + ;; If the buffer we are popping up is already displayed in the selected + ;; window, the below `inhibit-same-window' logic will cause it to be + ;; displayed twice - so we early out in this case. Note that we must check + ;; `selected-window', as async request handlers are executed in the context + ;; of the current connection buffer (i.e. `current-buffer' is dynamically + ;; bound to that). + (unless (eq window (selected-window)) + ;; Non nil `inhibit-same-window' ensures that current window is not covered + ;; Non nil `inhibit-switch-frame' ensures that the other frame is not selected + ;; if that's where the buffer is being shown. + (funcall (if select #'pop-to-buffer #'display-buffer) + buffer-name `(nil . ((inhibit-same-window . + ;; A non-nil value prevents the same window from being used for display: + ,pop-up-windows) + (reusable-frames . + ;; choose any visible frame + visible))))))) + (get-buffer buffer-name))) (defun cider-popup-buffer-quit (&optional kill) "Quit the current (temp) window. diff --git a/elpa/cider-20230707.640/cider-profile.el b/elpa/cider-20241203.1607/cider-profile.el similarity index 99% rename from elpa/cider-20230707.640/cider-profile.el rename to elpa/cider-20241203.1607/cider-profile.el index e2dd6fc6..792d4b54 100644 --- a/elpa/cider-20230707.640/cider-profile.el +++ b/elpa/cider-20241203.1607/cider-profile.el @@ -1,6 +1,6 @@ ;;; cider-profile.el --- CIDER support for profiling -*- lexical-binding: t; -*- -;; Copyright © 2014-2023 Edwin Watkeys and CIDER contributors +;; Copyright © 2014-2024 Edwin Watkeys and CIDER contributors ;; Author: Edwin Watkeys ;; Juan E. Maya diff --git a/elpa/cider-20230707.640/cider-repl-history.el b/elpa/cider-20241203.1607/cider-repl-history.el similarity index 99% rename from elpa/cider-20230707.640/cider-repl-history.el rename to elpa/cider-20241203.1607/cider-repl-history.el index e5044bf6..ec19298a 100644 --- a/elpa/cider-20230707.640/cider-repl-history.el +++ b/elpa/cider-20241203.1607/cider-repl-history.el @@ -1,6 +1,6 @@ ;;; cider-repl-history.el --- REPL input history browser -*- lexical-binding: t; -*- -;; Copyright (c) 2017-2023 John Valente and browse-kill-ring authors +;; Copyright (c) 2017-2024 John Valente and browse-kill-ring authors ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/elpa/cider-20230707.640/cider-repl.el b/elpa/cider-20241203.1607/cider-repl.el similarity index 86% rename from elpa/cider-20230707.640/cider-repl.el rename to elpa/cider-20241203.1607/cider-repl.el index 3245690f..9fd17c4f 100644 --- a/elpa/cider-20230707.640/cider-repl.el +++ b/elpa/cider-20241203.1607/cider-repl.el @@ -1,7 +1,7 @@ ;;; cider-repl.el --- CIDER REPL mode interactions -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -236,24 +236,36 @@ This cache is stored in the connection buffer.") "Handle server state contained in RESPONSE." (with-demoted-errors "Error in `cider-repl--state-handler': %s" (when (member "state" (nrepl-dict-get response "status")) - (nrepl-dbind-response response (repl-type changed-namespaces) - (when (and repl-type cider-repl-auto-detect-type) + (nrepl-dbind-response response (repl-type changed-namespaces session) + (when (and repl-type + cider-repl-auto-detect-type + ;; tooling sessions always run on the JVM so they are not a valid criterion: + (not (equal session nrepl-tooling-session))) (cider-set-repl-type repl-type)) (when (eq (cider-maybe-intern repl-type) 'cljs) (setq cider-repl-cljs-upgrade-pending nil)) (unless (nrepl-dict-empty-p changed-namespaces) (setq cider-repl-ns-cache (nrepl-dict-merge cider-repl-ns-cache changed-namespaces)) - (dolist (b (buffer-list)) - (with-current-buffer b - ;; Metadata changed, so signatures may have changed too. - (setq cider-eldoc-last-symbol nil) - (when (or cider-mode (derived-mode-p 'cider-repl-mode)) - (when-let* ((ns-dict (or (nrepl-dict-get changed-namespaces (cider-current-ns)) - (let ((ns-dict (cider-resolve--get-in (cider-current-ns)))) - (when (seq-find (lambda (ns) (nrepl-dict-get changed-namespaces ns)) - (nrepl-dict-get ns-dict "aliases")) - ns-dict))))) - (cider-refresh-dynamic-font-lock ns-dict)))))))))) + (let ((this-repl (current-buffer))) + (dolist (b (buffer-list)) + (with-current-buffer b + (when (or cider-mode (derived-mode-p 'cider-repl-mode)) + ;; We only cider-refresh-dynamic-font-lock (and set `cider-eldoc-last-symbol') + ;; for Clojure buffers directly related to this repl + ;; (specifically, we omit 'friendly' sessions because a given buffer may be friendly to multiple repls, + ;; so we don't want a buffer to mix up font locking rules from different repls). + ;; Note that `sesman--linked-sessions' only queries for the directly linked sessions. + ;; That has the additional advantage of running very/predictably fast, since it won't run our + ;; `cider--sesman-friendly-session-p' logic, which can be slow for its non-cached path. + (when (member this-repl (car (sesman--linked-sessions 'CIDER))) + ;; Metadata changed, so signatures may have changed too. + (setq cider-eldoc-last-symbol nil) + (when-let* ((ns-dict (or (nrepl-dict-get changed-namespaces (cider-current-ns)) + (let ((ns-dict (cider-resolve--get-in (cider-current-ns)))) + (when (seq-find (lambda (ns) (nrepl-dict-get changed-namespaces ns)) + (nrepl-dict-get ns-dict "aliases")) + ns-dict))))) + (cider-refresh-dynamic-font-lock ns-dict)))))))))))) (defun cider-repl-require-repl-utils () "Require standard REPL util functions into the current REPL." @@ -537,7 +549,7 @@ If given a negative value of ARG, move to the beginning of defun." (if (and (not (cider-repl--at-prompt-start-p)) (cider-repl--in-input-area-p)) (goto-char cider-repl-input-start-mark) - (beginning-of-defun))) + (beginning-of-defun-raw))) (defun cider-repl-end-of-defun () "Move to end of defun." @@ -983,6 +995,67 @@ t, as the content-type response is (currently) an alternative to the value response. However for handlers which themselves issue subsequent nREPL ops, it may be convenient to prevent inserting a prompt.") +(defun cider--maybe-get-state-cljs () + "Invokes `cider/get-state' when it's possible to do so." + (when-let ((conn (cider-current-repl 'cljs))) + (when (nrepl-op-supported-p "cider/get-state" conn) + (nrepl-send-request '("op" "cider/get-state") + (lambda (_response) + ;; No action is necessary: this request results in `cider-repl--state-handler` being called. + ) + conn)))) + +(defun cider--maybe-get-state-for-shadow-cljs (buffer &optional err) + "Refresh the changed namespaces metadata given BUFFER and ERR (stderr string). + +This is particularly necessary for shadow-cljs because: + +* it has a particular nREPL implementation; and +* one may have saved files (which triggers recompilation, + and therefore the need for recomputing changed namespaces) + without sending a nREPL message (this can particularly happen + if the file was edited outside Emacs)." + (with-current-buffer buffer + (when (and (eq cider-repl-type 'cljs) + (eq cider-cljs-repl-type 'shadow) + (not cider-repl-cljs-upgrade-pending) + (if err + (string-match-p "Build completed\\." err) + t)) + (cider--maybe-get-state-cljs)))) + +(defun cider--maybe-get-state-for-figwheel-main (buffer out) + "Refresh the changed namespaces metadata given BUFFER and OUT (stdout string)." + (with-current-buffer buffer + (when (and (eq cider-repl-type 'cljs) + (eq cider-cljs-repl-type 'figwheel-main) + (not cider-repl-cljs-upgrade-pending) + (string-match-p "Successfully compiled build" out)) + (cider--maybe-get-state-cljs)))) + +(defun cider--shadow-cljs-handle-stderr (buffer err) + "Refresh the changed namespaces metadata given BUFFER and ERR." + (cider--maybe-get-state-for-shadow-cljs buffer err)) + +(defun cider--shadow-cljs-handle-done (buffer) + "Refresh the changed namespaces metadata given BUFFER." + (cider--maybe-get-state-for-shadow-cljs buffer)) + +(defvar cider--repl-stdout-functions (list #'cider--maybe-get-state-for-figwheel-main) + "Functions to be invoked each time new stdout is received on a repl buffer. + +Good for, for instance, monitoring specific strings that may be logged, +and responding to them.") + +(defvar cider--repl-stderr-functions (list #'cider--shadow-cljs-handle-stderr) + "Functions to be invoked each time new stderr is received on a repl buffer. + +Good for, for instance, monitoring specific strings that may be logged, +and responding to them.") + +(defvar cider--repl-done-functions (list #'cider--shadow-cljs-handle-done) + "Functions to be invoked each time a given REPL interaction is complete.") + (defun cider-repl-handler (buffer) "Make an nREPL evaluation handler for the REPL BUFFER." (let ((show-prompt t)) @@ -991,14 +1064,20 @@ nREPL ops, it may be convenient to prevent inserting a prompt.") (lambda (buffer value) (cider-repl-emit-result buffer value t)) (lambda (buffer out) + (dolist (f cider--repl-stdout-functions) + (funcall f buffer out)) (cider-repl-emit-stdout buffer out)) (lambda (buffer err) + (dolist (f cider--repl-stderr-functions) + (funcall f buffer err)) (cider-repl-emit-stderr buffer err)) (lambda (buffer) (when show-prompt (cider-repl-emit-prompt buffer)) (when cider-repl-buffer-size-limit - (cider-repl-maybe-trim-buffer buffer))) + (cider-repl-maybe-trim-buffer buffer)) + (dolist (f cider--repl-done-functions) + (funcall f buffer))) nrepl-err-handler (lambda (buffer value content-type) (if-let* ((content-attrs (cadr content-type)) @@ -1251,8 +1330,15 @@ command will prompt for the name of the namespace to switch to." ;; That's why we eval them separately instead of combining them with `do'. (when cider-repl-require-ns-on-set (cider-sync-tooling-eval (format "(require '%s)" ns) nil connection)) - (cider-tooling-eval (format "(in-ns '%s)" ns) - (cider-repl-switch-ns-handler connection))))) + (let ((f (if (equal 'cljs + (with-current-buffer connection + cider-repl-type)) + ;; For cljs, don't use cider-tooling-eval, because Piggieback will later change the ns (issue #3503): + #'cider-nrepl-request:eval + ;; When possible, favor cider-tooling-eval because it preserves *1, etc (commit 5f705b): + #'cider-tooling-eval))) + (funcall f (format "(in-ns '%s)" ns) + (cider-repl-switch-ns-handler connection)))))) ;;; Location References @@ -1324,21 +1410,20 @@ regexes from `cider-locref-regexp-alist' to infer locations at point." (nrepl-dict-get (cider-sync-request:info var) "file"))) (when-let* ((file (plist-get loc :file))) ;; 2) file detected by the regexp - (or - (if (file-name-absolute-p file) - file - ;; when not absolute, expand within the current project - (when-let* ((proj (clojure-project-dir))) - (let ((path (expand-file-name file proj))) - (when (file-exists-p path) - path)))) - ;; 3) infer ns from the abbreviated path (common in - ;; reflection warnings) - (let ((ns (cider-path-to-ns file))) - (cider-sync-request:ns-path ns))))))) + (let ((file-from-regexp (if (file-name-absolute-p file) + file + ;; when not absolute, expand within the current project + (when-let* ((proj (clojure-project-dir))) + (expand-file-name file proj))))) + (or (when (file-readable-p file-from-regexp) + file-from-regexp) + ;; 3) infer ns from the abbreviated path + ;; (common in reflection warnings) + (let ((ns (cider-path-to-ns file))) + (cider-sync-request:ns-path ns)))))))) (if file (cider--jump-to-loc-from-info (nrepl-dict "file" file "line" line) t) - (error "No source location for %s" var))) + (error "No source location for %s - you may need to adjust `cider-locref-regexp-alist' to match your logging format" var))) (user-error "No location reference at point"))) (defvar cider-locref-hoover-overlay @@ -1607,7 +1692,6 @@ constructs." (declare-function cider-version "cider") (declare-function cider-test-run-loaded-tests "cider-test") (declare-function cider-test-run-project-tests "cider-test") -(declare-function cider-sideloader-start "cider-eval") (cider-repl-add-shortcut "clear-output" #'cider-repl-clear-output) (cider-repl-add-shortcut "clear" #'cider-repl-clear-buffer) (cider-repl-add-shortcut "clear-banners" #'cider-repl-clear-banners) @@ -1621,7 +1705,6 @@ constructs." (cider-repl-add-shortcut "classpath" #'cider-classpath) (cider-repl-add-shortcut "history" #'cider-repl-history) (cider-repl-add-shortcut "trace-ns" #'cider-toggle-trace-ns) -(cider-repl-add-shortcut "sideloader-start" #'cider-sideloader-start) (cider-repl-add-shortcut "undef" #'cider-undef) (cider-repl-add-shortcut "refresh" #'cider-ns-refresh) (cider-repl-add-shortcut "reload" #'cider-ns-reload) @@ -1680,6 +1763,104 @@ constructs." (mapconcat #'identity (cider-repl--available-shortcuts) ", ")))) (error "No command selected"))))) +(defun cider--sesman-friendly-session-p (session &optional debug) + "Check if SESSION is a friendly session, DEBUG optionally. + +The checking is done as follows: + +* If the current buffer's name equals to the value of `cider-test-report-buffer', + only accept the given session's repl if it equals `cider-test--current-repl' +* Consider if the buffer belongs to `cider-ancillary-buffers' +* Consider the buffer's filename, strip any Docker/TRAMP details from it +* Check if that filename belongs to the classpath, + or to the classpath roots (e.g. the project root dir) +* As a fallback, check if the buffer's ns form + matches any of the loaded namespaces." + (setcdr session (seq-filter #'buffer-live-p (cdr session))) + (when-let ((repl (cadr session))) + (cond + ((equal (buffer-name) + cider-test-report-buffer) + (or (not cider-test--current-repl) + (not (buffer-live-p cider-test--current-repl)) + (equal repl + cider-test--current-repl))) + + ((member (buffer-name) cider-ancillary-buffers) + t) + + (t + (when-let* ((proc (get-buffer-process repl)) + (file (file-truename (or (buffer-file-name) default-directory)))) + ;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj + (when (string-match-p "#uzip" file) + (let ((avfs-path (directory-file-name (expand-file-name (or (getenv "AVFSBASE") "~/.avfs/"))))) + (setq file (replace-regexp-in-string avfs-path "" file t t)))) + (when-let ((tp (cider-tramp-prefix (current-buffer)))) + (setq file (string-remove-prefix tp file))) + (when (process-live-p proc) + (let* ((classpath (or (process-get proc :cached-classpath) + (let ((cp (with-current-buffer repl + (cider-classpath-entries)))) + (process-put proc :cached-classpath cp) + cp))) + (ns-list (when (nrepl-op-supported-p "ns-list" repl) + (or (process-get proc :all-namespaces) + (let ((ns-list (with-current-buffer repl + (cider-sync-request:ns-list)))) + (process-put proc :all-namespaces ns-list) + ns-list)))) + (classpath-roots (or (process-get proc :cached-classpath-roots) + (let ((cp (thread-last classpath + (seq-filter (lambda (path) (not (string-match-p "\\.jar$" path)))) + (mapcar #'file-name-directory) + (seq-remove #'null) + (seq-uniq)))) + (process-put proc :cached-classpath-roots cp) + cp)))) + (or (seq-find (lambda (path) (string-prefix-p path file)) + classpath) + (seq-find (lambda (path) (string-prefix-p path file)) + classpath-roots) + (when-let* ((cider-path-translations (cider--all-path-translations)) + (translated (cider--translate-path file 'to-nrepl :return-all))) + (seq-find (lambda (translated-path) + (or (seq-find (lambda (path) + (string-prefix-p path translated-path)) + classpath) + (seq-find (lambda (path) + (string-prefix-p path translated-path)) + classpath-roots))) + translated)) + (when-let ((ns (condition-case nil + (substring-no-properties (cider-current-ns :no-default + ;; important - don't query the repl, + ;; avoiding a recursive invocation of `cider--sesman-friendly-session-p`: + :no-repl-check)) + (error nil)))) + ;; if the ns form matches with a ns of all runtime namespaces, we can consider the buffer to match + ;; (this is a bit lax, but also quite useful) + (with-current-buffer repl + (or (when cider-repl-ns-cache ;; may be nil on repl startup + (member ns (nrepl-dict-keys cider-repl-ns-cache))) + (member ns ns-list)))) + (when debug + (list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots)))))))))) + +(defun cider-debug-sesman-friendly-session-p () + "`message's debugging information relative to friendly sessions. + +This is useful for when one sees 'No linked CIDER sessions' +in an unexpected place." + (interactive) + (message (prin1-to-string (mapcar (lambda (session) + (cider--sesman-friendly-session-p session t)) + (sesman--all-system-sessions 'CIDER))))) + +(cl-defmethod sesman-friendly-session-p ((_system (eql CIDER)) session) + "Check if SESSION is a friendly session." + (cider--sesman-friendly-session-p session)) + ;;;;; CIDER REPL mode (defvar cider-repl-mode-hook nil @@ -1871,7 +2052,10 @@ constructs." ;; apply dir-local variables to REPL buffers (hack-dir-local-variables-non-file-buffer) (when cider-repl-history-file - (cider-repl-history-load cider-repl-history-file) + (condition-case nil + (cider-repl-history-load cider-repl-history-file) + (error + (message "Malformed cider-repl-history-file: %s" cider-repl-history-file))) (add-hook 'kill-buffer-hook #'cider-repl-history-just-save t t) (add-hook 'kill-emacs-hook #'cider-repl-history-just-save)) (add-hook 'completion-at-point-functions #'cider-complete-at-point nil t) diff --git a/elpa/cider-20230707.640/cider-resolve.el b/elpa/cider-20241203.1607/cider-resolve.el similarity index 98% rename from elpa/cider-20230707.640/cider-resolve.el rename to elpa/cider-20241203.1607/cider-resolve.el index 783ddbf0..eaa49d63 100644 --- a/elpa/cider-20230707.640/cider-resolve.el +++ b/elpa/cider-20241203.1607/cider-resolve.el @@ -1,6 +1,6 @@ ;;; cider-resolve.el --- Resolve clojure symbols according to current nREPL connection -*- lexical-binding: t; -*- -;; Copyright © 2015-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2015-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; Author: Artur Malabarba diff --git a/elpa/cider-20230707.640/cider-scratch.el b/elpa/cider-20241203.1607/cider-scratch.el similarity index 96% rename from elpa/cider-20230707.640/cider-scratch.el rename to elpa/cider-20241203.1607/cider-scratch.el index 6366abb7..07de719c 100644 --- a/elpa/cider-20230707.640/cider-scratch.el +++ b/elpa/cider-20241203.1607/cider-scratch.el @@ -1,6 +1,6 @@ ;;; cider-scratch.el --- *scratch* buffer for Clojure -*- lexical-binding: t -*- -;; Copyright © 2014-2023 Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 Bozhidar Batsov and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -48,6 +48,7 @@ (set-keymap-parent map clojure-mode-map) (define-key map (kbd "C-j") #'cider-eval-print-last-sexp) (define-key map [remap paredit-newline] #'cider-eval-print-last-sexp) + (define-key map [remap paredit-C-j] #'cider-eval-print-last-sexp) (easy-menu-define cider-clojure-interaction-mode-menu map "Menu for Clojure Interaction mode" '("Clojure Interaction" diff --git a/elpa/cider-20230707.640/cider-selector.el b/elpa/cider-20241203.1607/cider-selector.el similarity index 91% rename from elpa/cider-20230707.640/cider-selector.el rename to elpa/cider-20241203.1607/cider-selector.el index afe0b567..ec4a6503 100644 --- a/elpa/cider-20230707.640/cider-selector.el +++ b/elpa/cider-20241203.1607/cider-selector.el @@ -1,7 +1,7 @@ ;;; cider-selector.el --- Buffer selection command inspired by SLIME's selector -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -49,23 +49,26 @@ DESCRIPTION is a one-line description of what the key selects.") Not meant to be set by users. It's used internally by `cider-selector'.") -(defun cider-selector--recently-visited-buffer (mode &optional consider-visible-p) - "Return the most recently visited buffer, deriving its `major-mode' from MODE. +(defun cider-selector--recently-visited-buffer (modes &optional consider-visible-p) + "Return the most recently visited buffer, deriving its `major-mode' from MODES. +MODES may be a symbol for a single mode, or a list of mode symbols. CONSIDER-VISIBLE-P will allow handling of visible windows as well. First pass only considers buffers that are not already visible. Second pass will attempt one of visible ones for scenarios where the window is visible, but not focused." (cl-loop for buffer in (buffer-list) when (and (with-current-buffer buffer - (derived-mode-p mode)) + (apply #'derived-mode-p (if (listp modes) + modes + (list modes)))) ;; names starting with space are considered hidden by Emacs (not (string-match-p "^ " (buffer-name buffer))) (or consider-visible-p (null (get-buffer-window buffer 'visible)))) return buffer finally (if consider-visible-p - (error "Can't find unshown buffer in %S" mode) - (cider-selector--recently-visited-buffer mode t)))) + (error "Can't find unshown buffer in %S" modes) + (cider-selector--recently-visited-buffer modes t)))) ;;;###autoload (defun cider-selector (&optional other-window) @@ -134,7 +137,7 @@ is chosen. The returned buffer is selected with (def-cider-selector-method ?c "Most recently visited clojure-mode buffer." - (cider-selector--recently-visited-buffer 'clojure-mode)) + (cider-selector--recently-visited-buffer '(clojure-mode clojure-ts-mode))) (def-cider-selector-method ?e "Most recently visited emacs-lisp-mode buffer." diff --git a/elpa/cider-20230707.640/cider-stacktrace.el b/elpa/cider-20241203.1607/cider-stacktrace.el similarity index 94% rename from elpa/cider-20230707.640/cider-stacktrace.el rename to elpa/cider-20241203.1607/cider-stacktrace.el index 75db9c15..93019389 100644 --- a/elpa/cider-20230707.640/cider-stacktrace.el +++ b/elpa/cider-20241203.1607/cider-stacktrace.el @@ -1,6 +1,6 @@ ;;; cider-stacktrace.el --- Stacktrace navigator -*- lexical-binding: t -*- -;; Copyright © 2014-2023 Jeff Valk, Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 Jeff Valk, Bozhidar Batsov and CIDER contributors ;; Author: Jeff Valk @@ -56,6 +56,12 @@ If nil, messages will not be wrapped. If truthy but non-numeric, :type 'list :package-version '(cider . "0.6.0")) +(defcustom cider-stacktrace-navigate-to-other-window t + "If truthy, navigating from a stack frame will use other window. +Pick nil if you prefer the same window as *cider-error*." + :type 'boolean + :package-version '(cider . "1.8.0")) + (make-obsolete 'cider-stacktrace-print-length 'cider-stacktrace-print-options "0.20") (make-obsolete 'cider-stacktrace-print-level 'cider-stacktrace-print-options "0.20") (make-obsolete-variable 'cider-stacktrace-print-options 'cider-print-options "0.21") @@ -490,7 +496,14 @@ When it reaches 3, it wraps to 0." (cider-stacktrace-toggle 'repl)) (defun cider-stacktrace-toggle-tooling () - "Toggle display of Tooling stack frames (compiler, nREPL middleware, etc)." + "Toggle display of tooling stack frames. + +These include: + + * Clojure compiler and runtime internals + * may be `.clj' or `.java' files. + * nREPL internals + * CIDER internals." (interactive) (cider-stacktrace-toggle 'tooling)) @@ -547,7 +560,7 @@ Achieved by destructively manipulating `cider-stacktrace-suppressed-errors'." (button-get button 'file))) ;; give priority to `info` files as `info` returns full paths. (info (nrepl-dict-put info "file" file))) - (cider--jump-to-loc-from-info info t) + (cider--jump-to-loc-from-info info cider-stacktrace-navigate-to-other-window) (forward-line line-shift) (back-to-indentation))) @@ -630,7 +643,9 @@ others." "Emit toggle buttons for each of the ERROR-TYPES leading this stacktrace BUFFER." (with-current-buffer buffer (when error-types - (insert " This is an unexpected CIDER middleware error.\n Please submit a bug report via `") + (insert " This is a CIDER middleware error. + It may be a due to a bug, or perhaps simply to bad user input. + If you believe it's a bug, please submit an issue report via `") (insert-text-button "M-x cider-report-bug" 'follow-link t 'action (lambda (_button) (cider-report-bug)) @@ -784,8 +799,34 @@ the NAME. The whole group is prefixed by string INDENT." (cider-stacktrace--insert-named-group indent2 "extras: \n") (cider-stacktrace-emit-indented extra (concat indent2 " ") nil t))))))) -(defun cider-stacktrace-render-cause (buffer cause num note) - "Emit into BUFFER the CAUSE NUM, exception class, message, data, and NOTE." +(declare-function cider-inspector-inspect-last-exception "cider-inspector") + +(defun cider-stacktrace--inspect-class (event) + "Mouse handler for EVENT." + (interactive "e") + (let* ((pos (posn-point (event-end event))) + (window (posn-window (event-end event))) + (buffer (window-buffer window)) + (inspect-index (with-current-buffer buffer + (get-text-property pos 'inspect-index)))) + (cider-inspector-inspect-last-exception inspect-index))) + +(defun cider-stacktrace--inspect-class-kbd () + "Keyboard handler." + (interactive) + (when-let ((inspect-index (get-text-property (point) 'inspect-index))) + (cider-inspector-inspect-last-exception inspect-index))) + +(defvar cider-stacktrace-exception-map + (let ((map (make-sparse-keymap))) + (define-key map [mouse-1] #'cider-stacktrace--inspect-class) + (define-key map (kbd "p") #'cider-stacktrace--inspect-class-kbd) + (define-key map (kbd "i") #'cider-stacktrace--inspect-class-kbd) + map)) + +(defun cider-stacktrace-render-cause (buffer cause num note &optional inspect-index) + "Emit into BUFFER the CAUSE NUM, exception class, message, data, and NOTE, +make INSPECT-INDEX actionable if present." (with-current-buffer buffer (nrepl-dbind-response cause (class message data spec stacktrace) (let ((indent " ") @@ -793,10 +834,17 @@ the NAME. The whole group is prefixed by string INDENT." (message-face 'cider-stacktrace-error-message-face)) (cider-propertize-region `(cause ,num) ;; Detail level 0: exception class - (cider-propertize-region '(detail 0) + (cider-propertize-region `(detail + 0 + + inspect-index + ,inspect-index + + keymap + ,cider-stacktrace-exception-map) (insert (format "%d. " num) (propertize note 'font-lock-face 'font-lock-comment-face) " " - (propertize class 'font-lock-face class-face) + (propertize class 'font-lock-face class-face 'mouse-face 'highlight) "\n")) ;; Detail level 1: message + ex-data (cider-propertize-region '(detail 1) @@ -870,10 +918,11 @@ through the `cider-stacktrace-suppressed-errors' variable." (cider-stacktrace-render-suppression-toggle buffer error-types) (insert "\n\n")) ;; Stacktrace exceptions & frames - (let ((num (length causes))) + (let* ((causes-length (length causes)) + (num causes-length)) (dolist (cause causes) - (let ((note (if (= num (length causes)) "Unhandled" "Caused by"))) - (cider-stacktrace-render-cause buffer cause num note) + (let ((note (if (= num causes-length) "Unhandled" "Caused by"))) + (cider-stacktrace-render-cause buffer cause num note (- causes-length num)) (setq num (1- num)))))) (cider-stacktrace-initialize causes) (font-lock-refresh-defaults))) diff --git a/elpa/cider-20230707.640/cider-test.el b/elpa/cider-20241203.1607/cider-test.el similarity index 79% rename from elpa/cider-20230707.640/cider-test.el rename to elpa/cider-20241203.1607/cider-test.el index 50ff75f2..b67021ce 100644 --- a/elpa/cider-20230707.640/cider-test.el +++ b/elpa/cider-20241203.1607/cider-test.el @@ -1,6 +1,6 @@ ;;; cider-test.el --- Test result viewer -*- lexical-binding: t -*- -;; Copyright © 2014-2023 Jeff Valk, Bozhidar Batsov and CIDER contributors +;; Copyright © 2014-2024 Jeff Valk, Bozhidar Batsov and CIDER contributors ;; Author: Jeff Valk @@ -41,6 +41,7 @@ (require 'cider-popup) (require 'cider-stacktrace) (require 'cider-overlays) +(require 'cider-util) ;;; Variables @@ -59,13 +60,12 @@ :type 'boolean :package-version '(cider . "0.9.0")) -(defcustom cider-test-defining-forms '("deftest" "defspec") - "Forms that define individual tests. -CIDER considers the \"top-level\" form around point to define a test if -the form starts with one of these forms. -Add to this list to have CIDER recognize additional test defining macros." - :type '(repeat string) - :package-version '(cider . "0.15.0")) +(make-obsolete 'cider-test-defining-forms nil "1.8.0") + +(defvar cider-test--current-repl nil + "Contains the reference to the REPL where the tests were last invoked from. +This is needed for *cider-test-report* navigation +to work against the correct REPL session.") (defvar cider-test-last-summary nil "The summary of the last run test.") @@ -117,7 +117,6 @@ Add to this list to have CIDER recognize additional test defining macros." "When theme is changed, update `cider-test-items-background-color'." (setq cider-test-items-background-color (cider-scale-background-color))) - ;;; Report mode & key bindings ;; ;; The primary mode of interacting with test results is the report buffer, which @@ -135,6 +134,7 @@ Add to this list to have CIDER recognize additional test defining macros." (define-key map (kbd "C-l") #'cider-test-run-loaded-tests) (define-key map (kbd "C-p") #'cider-test-run-project-tests) (define-key map (kbd "C-b") #'cider-test-show-report) + (define-key map (kbd "C-f") #'cider-test-toggle-fail-fast) ;; Single-key bindings defined last for display in menu (define-key map (kbd "r") #'cider-test-rerun-failed-tests) (define-key map (kbd "t") #'cider-test-run-test) @@ -144,6 +144,7 @@ Add to this list to have CIDER recognize additional test defining macros." (define-key map (kbd "l") #'cider-test-run-loaded-tests) (define-key map (kbd "p") #'cider-test-run-project-tests) (define-key map (kbd "b") #'cider-test-show-report) + (define-key map (kbd "f") #'cider-test-toggle-fail-fast) map)) (defconst cider-test-menu @@ -288,7 +289,8 @@ prompt and whether to use a new window. Similar to `cider-find-var'." cider-auto-select-error-buffer #'cider-stacktrace-mode 'ancillary) - (reverse causes)))))))))) + (reverse causes))))))) + cider-test--current-repl))) (defun cider-test-stacktrace () "Display stacktrace for the erring test at point." @@ -361,6 +363,16 @@ With the actual value, the outermost '(not ...)' s-expression is removed." ;;; Report rendering +(defcustom cider-test-fail-fast t + "Controls whether to stop a test run on failure/error." + :type 'boolean + :package-version '(cider . "1.8.0")) + +(defun cider-test-toggle-fail-fast () + "Toggles `cider-test-fail-fast' t <-> nil for the current buffer." + (interactive) + (setq-local cider-test-fail-fast (not cider-test-fail-fast))) + (defun cider-test-type-face (type) "Return the font lock face for the test result TYPE." (pcase type @@ -374,11 +386,16 @@ With the actual value, the outermost '(not ...)' s-expression is removed." (let ((face (cider-test-type-face type))) `(:foreground ,(face-attribute face :background)))) -(defun cider-test-render-summary (buffer summary) - "Emit into BUFFER the report SUMMARY statistics." +(defun cider-test-render-summary (buffer summary &optional elapsed-time) + "Emit into BUFFER the report SUMMARY statistics. + +If ELAPSED-TIME is provided it will be included in the summary." (with-current-buffer buffer (nrepl-dbind-response summary (ns var test pass fail error) - (insert (format "Tested %d namespaces\n" ns)) + (let ((ms (nrepl-dict-get elapsed-time "ms"))) + (insert (format "Tested %d namespaces%s\n" ns (if ms + (format " in %s ms" ms) + "")))) (insert (format "Ran %d assertions, in %d test functions\n" test var)) (unless (zerop fail) (cider-insert (format "%d failures" fail) 'cider-test-failure-face t)) @@ -386,8 +403,22 @@ With the actual value, the outermost '(not ...)' s-expression is removed." (cider-insert (format "%d errors" error) 'cider-test-error-face t)) (when (zerop (+ fail error)) (cider-insert (format "%d passed" pass) 'cider-test-success-face t)) + (when cider-test-fail-fast + (cider-insert "cider-test-fail-fast: " 'font-lock-comment-face nil) + (cider-insert "t" 'font-lock-constant-face t)) (insert "\n\n")))) +(defun cider-test--string-contains-newline (input-string) + "Returns whether INPUT-STRING contains an escaped newline." + (when (stringp input-string) + (and (string-match-p "\\\\n" input-string) + t))) + +(defvar cider-test-var-keymap + (let ((map (make-sparse-keymap))) + (define-key map [mouse-1] #'cider-test-jump) + map)) + (defun cider-test-render-assertion (buffer test) "Emit into BUFFER report detail for the TEST assertion." (with-current-buffer buffer @@ -409,18 +440,25 @@ With the actual value, the outermost '(not ...)' s-expression is removed." (type-face (cider-test-type-simple-face type)) (bg `(:background ,cider-test-items-background-color :extend t))) (cider-insert (capitalize type) type-face nil " in ") - (cider-insert var 'font-lock-function-name-face t) + (cider-propertize-region `(keymap ,cider-test-var-keymap) + (cider-insert (propertize var 'mouse-face 'highlight) + 'font-lock-function-name-face t)) (when context (cider-insert context 'font-lock-doc-face t)) (when message (cider-insert message 'font-lock-string-face t)) (when expected (insert-label "expected") (insert-rect expected) - (insert "\n")) + ;; Only place a newline between expected and actual when the values are deemed 'dense', + ;; otherwise favor compact output: + (when (or (cider-test--string-contains-newline expected) + (cider-test--string-contains-newline actual)) + (insert "\n"))) (if diffs (dolist (d diffs) (cl-destructuring-bind (actual (removed added)) d (insert-label "actual") (insert-rect actual) + (insert "\n") (insert-label "diff") (insert "- ") (insert-rect removed) @@ -450,16 +488,32 @@ With the actual value, the outermost '(not ...)' s-expression is removed." test)) tests)) -(defun cider-test-render-report (buffer summary results) +(defun cider-test-render-report (buffer summary results &optional elapsed-time ns-elapsed-time var-elapsed-time) "Emit into BUFFER the report for the SUMMARY, and test RESULTS." (with-current-buffer buffer (let ((inhibit-read-only t)) (cider-test-report-mode) (cider-insert "Test Summary" 'bold t) (dolist (ns (nrepl-dict-keys results)) - (insert (cider-propertize ns 'ns) "\n")) + (insert (cider-propertize ns 'ns) + (or (let ((ms (nrepl-dict-get (nrepl-dict-get ns-elapsed-time ns) + "ms"))) + (propertize (format " %s ms" ms) 'face 'font-lock-comment-face)) + "") + "\n") + (when var-elapsed-time + (when-let ((pairs (nrepl-dict-get var-elapsed-time ns))) + (nrepl-dict-map (lambda (var meta) + (insert " " ;; indentation - we're showing a var within a ns + (cider-propertize var 'font-lock-function-name-face) + (or (when-let* ((elapsed (nrepl-dict-get meta "elapsed-time")) + (ms (nrepl-dict-get elapsed "ms"))) + (propertize (format " %s ms" ms) 'face 'font-lock-comment-face)) + "") + "\n")) + pairs)))) (cider-insert "\n") - (cider-test-render-summary buffer summary) + (cider-test-render-summary buffer summary elapsed-time) (nrepl-dbind-response summary (fail error) (unless (zerop (+ fail error)) (cider-insert "Results" 'bold t "\n") @@ -506,14 +560,18 @@ The optional arg TEST denotes an individual test name." 'ns) (unless (stringp ns) " namespaces"))))) -(defun cider-test-echo-summary (summary results) - "Echo SUMMARY statistics for a test run returning RESULTS." +(defun cider-test-echo-summary (summary results &optional elapsed-time) + "Echo SUMMARY statistics for a test run returning RESULTS in ELAPSED-TIME." (nrepl-dbind-response summary (ns test var fail error) (if (nrepl-dict-empty-p results) (message (concat (propertize "No assertions (or no tests) were run." 'face 'cider-test-error-face) "Did you forget to use `is' in your tests?")) + (let* ((ms (nrepl-dict-get elapsed-time "ms")) + (ms (if ms + (propertize (format " in %s ms" ms ) 'face 'font-lock-comment-face) + "."))) (message (propertize - "%sRan %d assertions, in %d test functions. %d failures, %d errors." + "%sRan %d assertions, in %d test functions. %d failures, %d errors%s" 'face (cond ((not (zerop error)) 'cider-test-error-face) ((not (zerop fail)) 'cider-test-failure-face) (t 'cider-test-success-face))) @@ -521,7 +579,7 @@ The optional arg TEST denotes an individual test name." (cider-propertize (car (nrepl-dict-keys results)) 'ns) (propertize (format "%d namespaces" ns) 'face 'default)) (propertize ": " 'face 'default)) - test var fail error)))) + test var fail error ms))))) ;;; Test definition highlighting ;; @@ -667,10 +725,12 @@ running them." ;; we generate a different message when running individual tests (cider-test-echo-running ns (car tests)) (cider-test-echo-running ns))) - (let ((request `("op" ,(cond ((stringp ns) "test") - ((eq :project ns) "test-all") - ((eq :loaded ns) "test-all") - ((eq :non-passing ns) "retest"))))) + (setq cider-test--current-repl conn) + (let* ((retest? (eq :non-passing ns)) + (request `("op" ,(cond ((stringp ns) "test") + ((eq :project ns) "test-all") + ((eq :loaded ns) "test-all") + (retest? "retest"))))) ;; we add optional parts of the request only when relevant (when (and (listp include-selectors) include-selectors) (setq request (append request `("include" ,include-selectors)))) @@ -682,10 +742,13 @@ running them." (setq request (append request `("tests" ,tests)))) (when (or (stringp ns) (eq :project ns)) (setq request (append request `("load?" ,"true")))) + (when (and cider-test-fail-fast + (not retest?)) + (setq request (append request `("fail-fast" ,"true")))) (cider-nrepl-send-request request (lambda (response) - (nrepl-dbind-response response (summary results status out err) + (nrepl-dbind-response response (summary results status out err elapsed-time ns-elapsed-time var-elapsed-time) (cond ((member "namespace-not-found" status) (unless silent (message "No test namespace: %s" (cider-propertize ns 'ns)))) @@ -696,22 +759,33 @@ running them." (setq cider-test-last-summary summary) (setq cider-test-last-results results) (cider-test-highlight-problems results) - (cider-test-echo-summary summary results) + (cider-test-echo-summary summary results elapsed-time) (if (or (not (zerop (+ error fail))) cider-test-show-report-on-success) - (cider-test-render-report - (cider-popup-buffer - cider-test-report-buffer - cider-auto-select-test-report-buffer) - summary - results) + (let ((b (cider-popup-buffer + cider-test-report-buffer + cider-auto-select-test-report-buffer))) + (with-current-buffer b + ;; Change the default-directory so that it doesn't affect `sesman--linked-sessions` logic: + (setq-local default-directory + (with-current-buffer "*Messages*" default-directory))) + (cider-test-render-report + b + summary + results + elapsed-time + ns-elapsed-time + var-elapsed-time)) (when (get-buffer cider-test-report-buffer) (with-current-buffer cider-test-report-buffer (let ((inhibit-read-only t)) (erase-buffer))) (cider-test-render-report cider-test-report-buffer - summary results)))))))) + summary + results + elapsed-time + ns-elapsed-time)))))))) conn)))))) (defun cider-test-rerun-failed-tests () @@ -779,30 +853,61 @@ See `cider-test-rerun-test'." (setq cider-test-last-test-ns ns cider-test-last-test-var var)) +(defun cider--test-var-p (ns var) + "Determines if the VAR in NS is a test." + (if (cider-nrepl-op-supported-p "cider/get-state") + (cider-resolve--get-in ns "interns" var "test") + (equal "true" + (nrepl-dict-get (cider-sync-tooling-eval + (format "(clojure.core/-> %s var clojure.core/meta (clojure.core/contains? :test))" + var) + ns) + "value")))) + +(defun cider--extract-test-var-at-point () + "Find ns and var for the test at point. +The test ns/var exist as text properties on report items and on highlighted +failed/erred test definitions. + +When not found, a test definition at point +or in a corresponding test namespace is searched." + (let* ((ns-from-text-property (get-text-property (point) 'ns)) + (var-from-text-property (when ns-from-text-property + ;; we're in a `cider-test-report-mode' buffer + ;; or on a highlighted failed/erred test definition + (get-text-property (point) 'var)))) + (or (when (and var-from-text-property + ;; Slightly redundant check. However querying `cider-resolve--get-in` is cheap: + (cider--test-var-p ns-from-text-property var-from-text-property)) + (list ns-from-text-property var-from-text-property)) + (when-let* ((n (cider-get-ns-name)) + (v (cadr (clojure-find-def)))) + (or (when (cider--test-var-p n v) + (list n v)) + (let ((derived-ns (funcall cider-test-infer-test-ns n)) + (derived-var (concat v "-test"))) + ;; deftest foo-test: + (or (when (cider--test-var-p derived-ns derived-var) + (list derived-ns derived-var)) + ;; deftest foo (less usual, but quite frequent): + (when (cider--test-var-p derived-ns v) + (list derived-ns v))))))))) + (defun cider-test-run-test () "Run the test at point. The test ns/var exist as text properties on report items and on highlighted -failed/erred test definitions. When not found, a test definition at point -is searched." +failed/erred test definitions. + +When not found, a test definition at point +or in a corresponding test namespace is searched." (interactive) - (let ((ns (get-text-property (point) 'ns)) - (var (get-text-property (point) 'var))) - (if (and ns var) - ;; we're in a `cider-test-report-mode' buffer - ;; or on a highlighted failed/erred test definition - (progn - (cider-test-update-last-test ns var) - (cider-test-execute ns (list var))) - ;; we're in a `clojure-mode' buffer - (let* ((ns (clojure-find-ns)) - (def (clojure-find-def)) ; it's a list of the form (deftest something) - (deftype (car def)) - (var (cadr def))) - (if (and ns (member deftype cider-test-defining-forms)) - (progn - (cider-test-update-last-test ns (list var)) - (cider-test-execute ns (list var))) - (message "No test at point")))))) + (let* ((found (cider--extract-test-var-at-point)) + (found-ns (car found)) + (found-var (cadr found))) + (if (not found-var) + (message "No test found at point") + (cider-test-update-last-test found-ns (list found-var)) + (cider-test-execute found-ns (list found-var))))) (defun cider-test-rerun-test () "Re-run the test that was previously ran." diff --git a/elpa/cider-20230707.640/cider-tracing.el b/elpa/cider-20241203.1607/cider-tracing.el similarity index 98% rename from elpa/cider-20230707.640/cider-tracing.el rename to elpa/cider-20241203.1607/cider-tracing.el index f7a312e6..f466fc8f 100644 --- a/elpa/cider-20230707.640/cider-tracing.el +++ b/elpa/cider-20241203.1607/cider-tracing.el @@ -1,6 +1,6 @@ ;;; cider-tracing.el --- Executing tracing functionality -*- lexical-binding: t -*- -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Bozhidar Batsov ;; Artur Malabarba diff --git a/elpa/cider-20230707.640/cider-util.el b/elpa/cider-20241203.1607/cider-util.el similarity index 95% rename from elpa/cider-20230707.640/cider-util.el rename to elpa/cider-20241203.1607/cider-util.el index 315eca3e..8316af96 100644 --- a/elpa/cider-20230707.640/cider-util.el +++ b/elpa/cider-20241203.1607/cider-util.el @@ -1,7 +1,7 @@ ;; cider-util.el --- Common utility functions that don't belong anywhere else -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -57,10 +57,24 @@ Setting this to nil removes the fontification restriction." (maphash (lambda (k _v) (setq keys (cons k keys))) hashtable) keys)) +(defun cider-clojure-major-mode-p () + "Return non-nil if current buffer is managed by a Clojure major mode." + (derived-mode-p 'clojure-mode 'clojure-ts-mode)) + +(defun cider-clojurescript-major-mode-p () + "Return non-nil if current buffer is managed by a ClojureScript major mode." + (derived-mode-p 'clojurescript-mode 'clojure-ts-clojurescript-mode)) + +(defun cider-clojurec-major-mode-p () + "Return non-nil if current buffer is managed by a ClojureC major mode." + (derived-mode-p 'clojurec-mode 'clojure-ts-clojurec-mode)) + (defun cider-util--clojure-buffers () "Return a list of all existing `clojure-mode' buffers." (seq-filter - (lambda (buffer) (with-current-buffer buffer (derived-mode-p 'clojure-mode))) + (lambda (buffer) + (with-current-buffer buffer + (cider-clojure-major-mode-p))) (buffer-list))) (defun cider-current-dir () @@ -71,12 +85,12 @@ Setting this to nil removes the fontification restriction." (defun cider-in-string-p () "Return non-nil if point is in a string." - (let ((beg (save-excursion (beginning-of-defun) (point)))) + (let ((beg (save-excursion (beginning-of-defun-raw) (point)))) (nth 3 (parse-partial-sexp beg (point))))) (defun cider-in-comment-p () "Return non-nil if point is in a comment." - (let ((beg (save-excursion (beginning-of-defun) (point)))) + (let ((beg (save-excursion (beginning-of-defun-raw) (point)))) (nth 4 (parse-partial-sexp beg (point))))) (defun cider--tooling-file-p (file-name) @@ -91,7 +105,7 @@ which nREPL uses for temporary evaluation file names." If BUFFER is provided act on that buffer instead." (with-current-buffer (or buffer (current-buffer)) - (or (derived-mode-p 'clojurec-mode)))) + (or (cider-clojurec-major-mode-p)))) ;;; Thing at point @@ -109,14 +123,22 @@ If BOUNDS is non-nil, return a list of its starting and ending position instead." (save-excursion (save-match-data - (end-of-defun) + (if (derived-mode-p 'cider-repl-mode) + (goto-char (point-max)) ;; in repls, end-of-defun won't work, so we perform the closest reasonable thing + (end-of-defun)) (let ((end (point))) (clojure-backward-logical-sexp 1) (cider--text-or-limits bounds (point) end))))) +(defun cider-get-ns-name () + "Calls `clojure-find-ns', suppressing any errors. +Therefore, possibly returns nil, +so please handle that value from any callsites." + (clojure-find-ns :supress-errors)) + (defun cider-ns-form () "Retrieve the ns form." - (when (clojure-find-ns) + (when (cider-get-ns-name) (save-excursion (goto-char (match-beginning 0)) (cider-defun-at-point)))) @@ -726,6 +748,7 @@ through a stack of help buffers. Variables `help-back-label' and "Press <\\[cider-apropos]> to look for a symbol by some search string." "Press <\\[cider-apropos-documentation]> to look for a symbol that has some string in its docstring." "Press <\\[cider-eval-defun-at-point]> to eval the top-level form at point." + "Press <\\[cider-eval-dwim]> to eval to run cider-eval-region if a region is active, and cider-eval-defun-at-point otherwise." "Press <\\[cider-eval-defun-up-to-point]> to eval the top-level form up to the point." "Press <\\[cider-eval-sexp-up-to-point]> to eval the current form up to the point." "Press <\\[cider-eval-sexp-at-point]> to eval the current form around the point." diff --git a/elpa/cider-20241203.1607/cider-xref-backend.el b/elpa/cider-20241203.1607/cider-xref-backend.el new file mode 100644 index 00000000..4b3ca4b0 --- /dev/null +++ b/elpa/cider-20241203.1607/cider-xref-backend.el @@ -0,0 +1,166 @@ +;;; cider-xref-backend.el --- CIDER's backend for Emacs' xref functionality -*- lexical-binding: t -*- + +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; +;; Author: Bozhidar Batsov +;; Artur Malabarba + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; CIDER's backend for Emacs' xref functionality. + +;;; Code: + +(require 'cider-client) +(require 'cider-common) +(require 'cider-doc) ;; for cider--abbreviate-file-protocol +(require 'cider-resolve) + +(require 'seq) +(require 'thingatpt) + +;;; xref integration +;; +;; xref.el was introduced in Emacs 25.1. +;; CIDER's xref backend was added in CIDER 1.2. +(defun cider--xref-backend () + "Used for xref integration." + ;; Check if `cider-nrepl` middleware is loaded. Allows fallback to other xref + ;; backends, if cider-nrepl is not loaded. + (when (or + ;; the main requirement: + (cider-nrepl-op-supported-p "ns-path" nil 'skip-ensure) + ;; the fallback, used for bare nrepl or babashka integrations: + (cider-nrepl-op-supported-p "lookup" nil 'skip-ensure)) + 'cider)) + +(cl-defmethod xref-backend-identifier-at-point ((_backend (eql cider))) + "Return the relevant identifier at point." + (cider-symbol-at-point 'look-back)) + +(defun cider--xref-extract-file (dict) + "Extracts the best possible file path from DICT." + (or (nrepl-dict-get dict "file-url") ;; This is the primary choice, it has a protocol and indicates an absolute path + ;; fall back in case it was absent or we're running an older cider-nrepl: + (nrepl-dict-get dict "file"))) + +(defun cider--xref-extract-friendly-file-name (dict) + "Extracts the best possible friendly file name from DICT. +These are used for presentation purposes." + (let* ((s (or (nrepl-dict-get dict "file") ;; these are shorter and relative, which look better in UIs. + (nrepl-dict-get dict "file-url"))) + (s (cider--abbreviate-file-protocol s)) + (line (nrepl-dict-get dict "line")) + (column (nrepl-dict-get dict "column"))) + (concat s + (when line + ":") + (when line + (prin1-to-string line)) + (when (and line column) + ":") + (when column + (prin1-to-string column))))) + +(defun cider--var-to-xref-location (var) + "Get location of definition of VAR." + (when-let* ((info (cider-var-info var)) + (line (nrepl-dict-get info "line")) + (file (cider--xref-extract-file info)) + (buf (cider--find-buffer-for-file file))) + (xref-make-buffer-location + buf + (with-current-buffer buf + (save-excursion + (goto-char 0) + (forward-line (1- line)) + (back-to-indentation) + (point)))))) + +(cl-defmethod xref-backend-definitions ((_backend (eql cider)) var) + "Find definitions of VAR." + (cider-ensure-connected) + (when-let* ((loc (cider--var-to-xref-location var))) + (list (xref-make var loc)))) + +(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql cider))) + "Return the completion table for identifiers." + (cider-ensure-connected) + (when-let* ((ns (cider-current-ns)) + (results (cider-sync-request:ns-vars ns))) + results)) + +(cl-defmethod xref-backend-references ((_backend (eql cider)) var) + "Find references of VAR." + (cider-ensure-connected) + (cider-ensure-op-supported "fn-refs") + (when-let* ((ns (cider-current-ns)) + (results (cider-sync-request:fn-refs ns var)) + (previously-existing-buffers (buffer-list))) + (thread-last results + (mapcar (lambda (info) + (let* ((filename (cider--xref-extract-file info)) + (column (nrepl-dict-get info "column")) + (line (nrepl-dict-get info "line")) + (friendly-name (cider--xref-extract-friendly-file-name info)) + ;; translate .jar urls and such: + (buf (cider--find-buffer-for-file filename)) + (bfn (and buf (buffer-file-name buf))) + (loc (when buf + ;; favor `xref-make-file-location' when possible, since that way, we can close their buffers. + (if bfn + (xref-make-file-location bfn line (or column 0)) + (xref-make-buffer-location buf (with-current-buffer buf + (save-excursion + (goto-char 0) + (forward-line line) + (move-to-column (or column 0)) + (point))))))) + (should-be-closed (and + buf + ;; if a buffer did not exist before, + ;; then it is a side-effect of invoking `cider--find-buffer-for-file'. + (not (member buf previously-existing-buffers)) + bfn + ;; only buffers with a normally reachable filename are safe to close. + ;; buffers not backed by such files may include .jars, TRAMP files, etc. + ;; Sadly this means we will still 'leak' some open buffers, but it's what we can do atm. + (file-exists-p bfn)))) + (when should-be-closed + (kill-buffer buf)) + (when loc + (xref-make friendly-name loc))))) + (seq-filter #'identity)))) + +(cl-defmethod xref-backend-apropos ((_backend (eql cider)) pattern) + "Find all symbols that match regexp PATTERN." + (cider-ensure-connected) + (cider-ensure-op-supported "apropos") + (when-let* ((ns (cider-current-ns)) + (results (cider-sync-request:apropos pattern ns t t completion-ignore-case))) + (mapcar (lambda (info) + (let* ((symbol (nrepl-dict-get info "name")) + (loc (cider--var-to-xref-location symbol)) + (type (nrepl-dict-get info "type")) + (doc (nrepl-dict-get info "doc"))) + (xref-make (format "[%s] %s\n %s" (propertize symbol 'face 'bold) (capitalize type) doc) + loc))) + results))) + +(provide 'cider-xref-backend) +;;; cider-xref-backend.el ends here diff --git a/elpa/cider-20230707.640/cider-xref.el b/elpa/cider-20241203.1607/cider-xref.el similarity index 88% rename from elpa/cider-20230707.640/cider-xref.el rename to elpa/cider-20241203.1607/cider-xref.el index b25f9091..453d1ef4 100644 --- a/elpa/cider-20230707.640/cider-xref.el +++ b/elpa/cider-20241203.1607/cider-xref.el @@ -1,6 +1,6 @@ ;;; cider-xref.el --- Xref functionality for Clojure -*- lexical-binding: t -*- -;; Copyright © 2019-2023 Bozhidar Batsov and CIDER contributors +;; Copyright © 2019-2024 Bozhidar Batsov and CIDER contributors ;; ;; Author: Bozhidar Batsov @@ -66,33 +66,35 @@ the symbol found by the xref search as argument." 'action #'cider-xref-doc 'help-echo "Display doc") (insert-text-button var-name 'type 'apropos-symbol)) - (insert "\n ") - (insert-text-button "Function" 'type 'apropos-function) - (insert ": ") - (let ((beg (point))) - (insert (nrepl-dict-get result "doc")) - (fill-region beg (point))) + (when-let ((doc (nrepl-dict-get result "doc"))) + (when (not (string-equal "(not documented)" doc)) + (insert "\n ") + (let ((beg (point))) + (insert (propertize doc 'font-lock-face 'font-lock-doc-face)) + (fill-region beg (point))))) (insert "\n") - (if-let* ((file (nrepl-dict-get result "file")) + (if-let* ((file-url (cider--xref-extract-file result)) + (friendly-file (cider--xref-extract-friendly-file-name result)) (line (nrepl-dict-get result "line"))) (progn - (insert (propertize var-name + (insert " " + (propertize var-name 'font-lock-face 'font-lock-function-name-face) " is defined in ") - (insert-text-button (cider--abbreviate-file-protocol file) + (insert-text-button friendly-file 'follow-link t 'action (lambda (_x) - (cider-xref-source file line var-name))) + (cider-xref-source file-url line var-name))) (insert ".")) (insert "Definition location unavailable.")) (insert "\n"))) -(defun cider-xref-source (file line name) - "Find source for FILE, LINE and NAME." +(defun cider-xref-source (file-url line name) + "Find source for FILE-URL, LINE and NAME." (interactive) - (if file - (if-let* ((buffer (and (not (cider--tooling-file-p file)) - (cider-find-file file)))) + (if file-url + (if-let* ((buffer (and (not (cider--tooling-file-p file-url)) + (cider-find-file file-url)))) (cider-jump-to buffer (if line (cons line nil) name) diff --git a/elpa/cider-20230707.640/cider.el b/elpa/cider-20241203.1607/cider.el similarity index 75% rename from elpa/cider-20230707.640/cider.el rename to elpa/cider-20241203.1607/cider.el index 12d0bdba..f9e9bdbc 100644 --- a/elpa/cider-20230707.640/cider.el +++ b/elpa/cider-20241203.1607/cider.el @@ -1,7 +1,7 @@ ;;; cider.el --- Clojure Interactive Development Environment that Rocks -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -10,9 +10,10 @@ ;; Hugo Duncan ;; Steve Purcell ;; Maintainer: Bozhidar Batsov -;; URL: http://www.github.com/clojure-emacs/cider -;; Version: 1.8.0-snapshot -;; Package-Requires: ((emacs "26") (clojure-mode "5.16.0") (parseedn "1.0.6") (queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2") (transient "0.4.1")) +;; URL: https://www.github.com/clojure-emacs/cider +;; Package-Version: 20241203.1607 +;; Package-Revision: 588c5790f0c0 +;; Package-Requires: ((emacs "26") (clojure-mode "5.19") (parseedn "1.2.1") (queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2") (transient "0.4.1")) ;; Keywords: languages, clojure, cider ;; This program is free software: you can redistribute it and/or modify @@ -93,10 +94,10 @@ (require 'sesman) (require 'package) -(defconst cider-version "1.8.0-snapshot" +(defconst cider-version "1.16.1" "The current version of CIDER.") -(defconst cider-codename "Geneva" +(defconst cider-codename "Kherson" "Codename used to denote stable releases.") (defcustom cider-lein-command @@ -141,7 +142,7 @@ (null (executable-find "clojure"))) "powershell" "clojure") - "The command used to execute clojure with tools.deps (requires Clojure 1.9+). + "The command used to execute clojure with tools.deps. Don't use clj here, as it doesn't work when spawned from Emacs due to it using rlwrap. If on Windows and no \"clojure\" executable is found we default to \"powershell\"." @@ -173,6 +174,18 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." :safe #'stringp :package-version '(cider . "1.1")) +(defcustom cider-clojure-cli-global-aliases + nil + "Global aliases to include when jacking in with the clojure CLI. +This value should be a string of the form \":foo:bar\", and +will be prepended to the value of `cider-clojure-cli-aliases'. +Alias names should be of the form \":foo:bar\". +Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases +then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." + :type 'string + :safe #'stringp + :package-version '(cider . "1.14")) + (defcustom cider-shadow-cljs-command "npx shadow-cljs" "The command used to execute shadow-cljs. @@ -259,6 +272,23 @@ By default we favor the project-specific shadow-cljs over the system-wide." :safe #'stringp :package-version '(cider . "1.6.0")) +(defcustom cider-basilisp-command + "basilisp" + "The command used to execute Basilisp. + + If Basilisp is installed in a virtual environment, update this to the + full path of the Basilisp executable within that virtual environment." + :type 'string + :safe #'stringp + :package-version '(cider . "1.14.0")) + +(defcustom cider-basilisp-parameters + "nrepl-server" + "Params passed to Basilisp to start an nREPL server via `cider-jack-in'." + :type 'string + :safe #'stringp + :package-version '(cider . "1.14.0")) + (make-obsolete-variable 'cider-lein-global-options 'cider-lein-parameters "1.8.0") (make-obsolete-variable 'cider-boot-global-options 'cider-boot-parameters "1.8.0") (make-obsolete-variable 'cider-clojure-cli-global-options 'cider-clojure-cli-parameters "1.8.0") @@ -282,7 +312,8 @@ to Leiningen." (const shadow-cljs) (const gradle) (const babashka) - (const nbb)) + (const nbb) + (const basilisp)) :safe #'symbolp :package-version '(cider . "0.9.0")) @@ -302,6 +333,7 @@ command when there is no ambiguity." (const gradle) (const babashka) (const nbb) + (const basilisp) (const :tag "Always ask" nil)) :safe #'symbolp :package-version '(cider . "0.13.0")) @@ -343,20 +375,28 @@ The repl dependendcies are most likely to be nREPL middlewares." :safe #'booleanp :version '(cider . "0.11.0")) +(defcustom cider-enable-nrepl-jvmti-agent nil + "When t, add `-Djdk.attach.allowAttachSelf' to the command line arguments. +This allows nREPL JVMTI agent to be loaded. It is needed for evaluation +interruption to properly work on Java 21 and above." + :type 'boolean + :safe #'booleanp + :version '(cider . "1.15.0")) + (defcustom cider-offer-to-open-cljs-app-in-browser t "When nil, do not offer to open ClojureScript apps in a browser on connect." :type 'boolean :safe #'booleanp :version '(cider . "0.15.0")) -(defvar cider-ps-running-nrepls-command "ps u | grep leiningen" +(defvar cider-ps-running-lein-nrepls-command "ps u | grep leiningen" "Process snapshot command used in `cider-locate-running-nrepl-ports'.") -(defvar cider-ps-running-nrepl-path-regexp-list +(defvar cider-ps-running-lein-nrepl-path-regexp-list '("\\(?:leiningen.original.pwd=\\)\\(.+?\\) -D" "\\(?:-classpath +:?\\(.+?\\)/self-installs\\)") "Regexp list to get project paths. -Extract project paths from output of `cider-ps-running-nrepls-command'. +Extract project paths from output of `cider-ps-running-lein-nrepls-command'. Sub-match 1 must be the project path.") (defvar cider-host-history nil @@ -366,7 +406,8 @@ Sub-match 1 must be the project path.") '((clojure-cli (:prefix-arg 1 :cmd (:jack-in-type clj :project-type clojure-cli :edit-project-dir t))) (lein (:prefix-arg 2 :cmd (:jack-in-type clj :project-type lein :edit-project-dir t))) (babashka (:prefix-arg 3 :cmd (:jack-in-type clj :project-type babashka :edit-project-dir t))) - (nbb (:prefix-arg 4 :cmd (:jack-in-type cljs :project-type nbb :cljs-repl-type nbb :edit-project-dir t)))) + (nbb (:prefix-arg 4 :cmd (:jack-in-type cljs :project-type nbb :cljs-repl-type nbb :edit-project-dir t))) + (basilisp (:prefix-arg 5 :cmd (:jack-in-type clj :project-type basilisp :edit-project-dir t)))) "The list of project tools that are supported by the universal jack in command. Each item in the list consists of the tool name and its plist options. @@ -398,15 +439,54 @@ The plist supports the following keys ('shadow-cljs cider-shadow-cljs-command) ('gradle cider-gradle-command) ('nbb cider-nbb-command) + ('basilisp cider-basilisp-command) (_ (user-error "Unsupported project type `%S'" project-type)))) +(defcustom cider-enrich-classpath nil + "If t, use enrich-classpath for adding sources/javadocs to the classpath. + +enrich-classpath is a Clojure CLI shim, and Leiningen plugin. + +This classpath expansion is done in a clean manner, +without interfering with classloaders." + :type 'boolean + :package-version '(cider . "1.2.0") + :safe #'booleanp) + +(defun cider--get-enrich-classpath-lein-script () + "Returns the location of enrich-classpath's lein.sh wrapper script." + (when-let ((cider-location (locate-library "cider.el" t))) + (concat (file-name-directory cider-location) + "lein.sh"))) + +(defun cider--get-enrich-classpath-clojure-cli-script () + "Returns the location of enrich-classpath's clojure.sh wrapper script." + (when-let ((cider-location (locate-library "cider.el" t))) + (concat (file-name-directory cider-location) + "clojure.sh"))) + (defun cider-jack-in-resolve-command (project-type) "Determine the resolved file path to `cider-jack-in-command'. Throws an error if PROJECT-TYPE is unknown." (pcase project-type - ('lein (cider--resolve-command cider-lein-command)) + ('lein (let ((r (cider--resolve-command cider-lein-command))) + (if (and cider-enrich-classpath + (not (eq system-type 'windows-nt)) + (executable-find (cider--get-enrich-classpath-lein-script))) + (concat "bash " ;; don't assume lein.sh is executable - MELPA might change that + (cider--get-enrich-classpath-lein-script) + " " + r) + r))) ('boot (cider--resolve-command cider-boot-command)) - ('clojure-cli (cider--resolve-command cider-clojure-cli-command)) + ('clojure-cli (if (and cider-enrich-classpath + (not (eq system-type 'windows-nt)) + (executable-find (cider--get-enrich-classpath-clojure-cli-script))) + (concat "bash " ;; don't assume clojure.sh is executable - MELPA might change that + (cider--get-enrich-classpath-clojure-cli-script) + " " + (cider--resolve-command cider-clojure-cli-command)) + (cider--resolve-command cider-clojure-cli-command))) ('babashka (cider--resolve-command cider-babashka-command)) ;; here we have to account for the possibility that the command is either ;; "npx shadow-cljs" or just "shadow-cljs" @@ -424,6 +504,7 @@ Throws an error if PROJECT-TYPE is unknown." ;; relative path like "./gradlew" use locate file instead of checking ;; the exec-path ('gradle (cider--resolve-project-command cider-gradle-command)) + ('basilisp (cider--resolve-command cider-basilisp-command)) (_ (user-error "Unsupported project type `%S'" project-type)))) (defun cider-jack-in-global-options (project-type) @@ -436,6 +517,7 @@ Throws an error if PROJECT-TYPE is unknown." ('shadow-cljs cider-shadow-cljs-global-options) ('gradle cider-gradle-global-options) ('nbb cider-nbb-global-options) + ('basilisp nil) (_ (user-error "Unsupported project type `%S'" project-type)))) (defun cider-jack-in-params (project-type) @@ -452,6 +534,7 @@ Throws an error if PROJECT-TYPE is unknown." ('shadow-cljs cider-shadow-cljs-parameters) ('gradle cider-gradle-parameters) ('nbb cider-nbb-parameters) + ('basilisp cider-basilisp-parameters) (_ (user-error "Unsupported project type `%S'" project-type)))) @@ -460,7 +543,7 @@ Throws an error if PROJECT-TYPE is unknown." "List of dependencies where elements are lists of artifact name and version.") (put 'cider-jack-in-dependencies 'risky-local-variable t) -(defcustom cider-injected-nrepl-version "1.0.0" +(defcustom cider-injected-nrepl-version "1.3.0" "The version of nREPL injected on jack-in. We inject the newest known version of nREPL just in case your version of Boot or Leiningen is bundling an older one." @@ -472,7 +555,7 @@ your version of Boot or Leiningen is bundling an older one." "List of dependencies where elements are lists of artifact name and version. Added to `cider-jack-in-dependencies' when doing `cider-jack-in-cljs'.") (put 'cider-jack-in-cljs-dependencies 'risky-local-variable t) -(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.5.2") +(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.5.3") (defvar cider-jack-in-dependencies-exclusions nil "List of exclusions for jack in dependencies. @@ -483,13 +566,15 @@ the artifact.") (defconst cider-clojure-artifact-id "org.clojure/clojure" "Artifact identifier for Clojure.") -(defconst cider-minimum-clojure-version "1.8.0" +(defconst cider-minimum-clojure-version "1.10.0" "Minimum supported version of Clojure.") -(defconst cider-latest-clojure-version "1.10.1" - "Latest supported version of Clojure.") +(defconst cider-latest-clojure-version "1.11.3" + "Latest (newest) version of Clojure. + +Used when `cider-jack-in-auto-inject-clojure' is set to `latest'.") -(defconst cider-required-middleware-version "0.32.0-alpha1" +(defconst cider-required-middleware-version "0.50.3" "The CIDER nREPL version that's known to work properly with CIDER.") (defcustom cider-injected-middleware-version cider-required-middleware-version @@ -499,16 +584,6 @@ Should be newer than the required version for optimal results." :package-version '(cider . "1.2.0") :safe #'stringp) -(defcustom cider-enrich-classpath nil - "Whether to use git.io/JiJVX for adding sources and javadocs to the classpath. - -This is done in a clean manner, without interfering with classloaders. - -Only available for Leiningen projects at the moment." - :type 'boolean - :package-version '(cider . "1.2.0") - :safe #'booleanp) - (defcustom cider-jack-in-auto-inject-clojure nil "Version of clojure to auto-inject into REPL. If nil, do not inject Clojure into the REPL. If `latest', inject @@ -570,19 +645,18 @@ returned by this function does not include keyword arguments." (let ((plugins (if cider-enrich-classpath (append cider-jack-in-lein-plugins `(("cider/cider-nrepl" ,cider-injected-middleware-version) - ("mx.cider/enrich-classpath" "1.9.0"))) + ("mx.cider/lein-enrich-classpath" "1.19.3"))) (append cider-jack-in-lein-plugins `(("cider/cider-nrepl" ,cider-injected-middleware-version)))))) - (thread-last - plugins - (seq-filter - (lambda (spec) - (if-let* ((pred (plist-get (seq-drop spec 2) :predicate))) - (funcall pred spec) - t))) - (mapcar - (lambda (spec) - (seq-take spec 2)))))) + (thread-last plugins + (seq-filter + (lambda (spec) + (if-let* ((pred (plist-get (seq-drop spec 2) :predicate))) + (funcall pred spec) + t))) + (mapcar + (lambda (spec) + (seq-take spec 2)))))) (defvar cider-jack-in-nrepl-middlewares nil "List of Clojure variable names. @@ -606,19 +680,18 @@ Added to `cider-jack-in-nrepl-middlewares' (which see) when doing "Return a normalized list of middleware variable names. See `cider-jack-in-nrepl-middlewares' for the format, except that the list returned by this function only contains strings." - (thread-last - cider-jack-in-nrepl-middlewares - (seq-filter - (lambda (spec) - (or (not (listp spec)) - (if-let* ((pred (plist-get (cdr spec) :predicate))) - (funcall pred spec) - t)))) - (mapcar - (lambda (spec) - (if (listp spec) - (car spec) - spec))))) + (thread-last cider-jack-in-nrepl-middlewares + (seq-filter + (lambda (spec) + (or (not (listp spec)) + (if-let* ((pred (plist-get (cdr spec) :predicate))) + (funcall pred spec) + t)))) + (mapcar + (lambda (spec) + (if (listp spec) + (car spec) + spec))))) (defun cider--list-as-boot-artifact (list) "Return a boot artifact string described by the elements of LIST. @@ -696,6 +769,8 @@ group:artifact:version notation and MIDDLEWARES are prepared as arguments to Clojurephant's ClojureNRepl task." (concat global-opts (unless (seq-empty-p global-opts) " ") + (when cider-enable-nrepl-jvmti-agent + "-Pjdk.attach.allowAttachSelf ") (cider--gradle-jack-in-property (append (cider--jack-in-required-dependencies) dependencies)) " " params @@ -715,6 +790,18 @@ of EXCLUSIONS can be provided as well. The returned string is quoted for passing as argument to an inferior shell." (shell-quote-argument (format "[%s %S%s]" (car list) (cadr list) (cider--lein-artifact-exclusions exclusions)))) +(defun cider--extract-lein-profiles (lein-params) + "Extracts a list of ('with-profile ...' and a repl command from LEIN-PARAMS). + +If no `with-profile' call was found, +returns an empty string as the first member." + (or (when-let* ((pattern "\\(with-profiles?\\s-+\\S-+\\)") + (match-start (string-match pattern lein-params)) + (match-end (match-end 0))) + (list (concat (substring lein-params match-start match-end) " ") + (string-trim (substring lein-params match-end)))) + (list "" lein-params))) + (defun cider-lein-jack-in-dependencies (global-opts params dependencies dependencies-exclusions lein-plugins &optional lein-middlewares) "Create lein jack-in dependencies. Does so by concatenating GLOBAL-OPTS, DEPENDENCIES, with DEPENDENCIES-EXCLUSIONS @@ -735,10 +822,21 @@ removed, LEIN-PLUGINS, LEIN-MIDDLEWARES and finally PARAMS." (seq-map (lambda (middleware) (concat "update-in :middleware conj " middleware)) - lein-middlewares)) + lein-middlewares) + (when cider-enable-nrepl-jvmti-agent + `(,(concat "update-in :jvm-opts conj '\"-Djdk.attach.allowAttachSelf\"'")))) " -- ") " -- " - params)) + (if (not cider-enrich-classpath) + params + ;; enrich-classpath must be applied after the `with-profile` call, if present, + ;; so that it can also process the classpath that is typically expanded by the presence of a set of profiles: + (let* ((profiles-and-repl-call (cider--extract-lein-profiles params)) + (profiles (car profiles-and-repl-call)) + (repl-call (nth 1 profiles-and-repl-call))) + (concat profiles + "update-in :middleware conj cider.enrich-classpath.plugin-v2/middleware -- " + repl-call))))) (defun cider--dedupe-deps (deps) "Removes the duplicates in DEPS." @@ -763,49 +861,68 @@ rules to quote it." (defun cider--powershell-encode-command (cmd-params) "Base64 encode the powershell command and jack-in CMD-PARAMS for clojure-cli." (let* ((quoted-params cmd-params) - (command (format "clojure %s" quoted-params)) + ;; Also ensure compatibility with pwsh 7.3 quoting rules + ;; + ;; https://stackoverflow.com/a/59036879 + (command (format "$PSNativeCommandArgumentPassing = 'Legacy'; clojure %s" quoted-params)) (utf-16le-command (encode-coding-string command 'utf-16le))) (format "-encodedCommand %s" (base64-encode-string utf-16le-command t)))) + +(defun cider--combined-aliases () + "Creates the combined ailases as stringe separated by ':'." + (let ((final-cider-clojure-cli-aliases + (cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases) + (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases)) + (cider-clojure-cli-global-aliases cider-clojure-cli-global-aliases) + (t cider-clojure-cli-aliases)))) + (if final-cider-clojure-cli-aliases + ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases + ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last + (let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" final-cider-clojure-cli-aliases)))) + (if (string-prefix-p ":" aliases) + aliases + (concat ":" aliases))) + ""))) + (defun cider-clojure-cli-jack-in-dependencies (global-options params dependencies &optional command) "Create Clojure tools.deps jack-in dependencies. Does so by concatenating DEPENDENCIES, PARAMS and GLOBAL-OPTIONS into a suitable `clojure` invocation and quoting, also accounting for COMMAND if provided. The main is placed in an inline alias :cider/nrepl so that if your aliases contain any mains, the cider/nrepl one will be the one used." - (let* ((all-deps (thread-last - dependencies - (append (cider--jack-in-required-dependencies)) - ;; Duplicates are never OK since they would result in - ;; `java.lang.IllegalArgumentException: Duplicate key [...]`: - (cider--dedupe-deps) - (seq-map (lambda (dep) - (if (listp (cadr dep)) - (format "%s {%s}" - (car dep) - (seq-reduce - (lambda (acc v) - (concat acc (format " :%s \"%s\" " (car v) (cdr v)))) - (cadr dep) - "")) - (format "%s {:mvn/version \"%s\"}" (car dep) (cadr dep))))))) + (let* ((all-deps (thread-last dependencies + (append (cider--jack-in-required-dependencies)) + ;; Duplicates are never OK since they would result in + ;; `java.lang.IllegalArgumentException: Duplicate key [...]`: + (cider--dedupe-deps) + (seq-map (lambda (dep) + (if (listp (cadr dep)) + (format "%s {%s}" + (car dep) + (seq-reduce + (lambda (acc v) + (concat acc (format " :%s \"%s\" " (car v) (cdr v)))) + (cadr dep) + "")) + (format "%s {:mvn/version \"%s\"}" (car dep) (cadr dep))))))) (middleware (mapconcat (apply-partially #'format "%s") (cider-jack-in-normalized-nrepl-middlewares) ",")) (main-opts (format "\"-m\" \"nrepl.cmdline\" \"--middleware\" \"[%s]\"" middleware)) - (deps (format "{:deps {%s} :aliases {:cider/nrepl {:main-opts [%s]}}}" - (string-join all-deps " ") main-opts)) + (deps (format "{:deps {%s} :aliases {:cider/nrepl {%s:main-opts [%s]}}}" + (string-join all-deps " ") + (if cider-enable-nrepl-jvmti-agent + ":jvm-opts [\"-Djdk.attach.allowAttachSelf\"], " + "") + main-opts)) (deps-quoted (cider--shell-quote-argument deps command))) (format "%s-Sdeps %s -M%s:cider/nrepl%s" ;; TODO: global-options are deprecated and should be removed in CIDER 2.0 (if global-options (format "%s " global-options) "") deps-quoted - (if cider-clojure-cli-aliases - ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases - ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last - (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" cider-clojure-cli-aliases)) - "") + (cider--combined-aliases) (if params (format " %s" params) "")))) (defun cider-shadow-cljs-jack-in-dependencies (global-opts params dependencies) @@ -853,10 +970,7 @@ middleware and dependencies." (append `(("nrepl/nrepl" ,cider-injected-nrepl-version)) cider-jack-in-dependencies)) cider-jack-in-dependencies-exclusions (cider-jack-in-normalized-lein-plugins) - (if cider-enrich-classpath - (append cider-jack-in-lein-middlewares - '("cider.enrich-classpath/middleware")) - cider-jack-in-lein-middlewares))) + cider-jack-in-lein-middlewares)) ('boot (cider-boot-jack-in-dependencies global-opts params @@ -888,6 +1002,7 @@ middleware and dependencies." global-opts (unless (seq-empty-p global-opts) " ") params)) + ('basilisp params) (_ (error "Unsupported project type `%S'" project-type)))) @@ -994,11 +1109,17 @@ The default options of `browser-repl' and `node-repl' are also included." (defun cider--shadow-get-builds () "Extract build names from the shadow-cljs.edn config file in the project root." (let ((shadow-edn (concat (clojure-project-dir) "shadow-cljs.edn"))) - (when (file-exists-p shadow-edn) + (when (file-readable-p shadow-edn) (with-temp-buffer (insert-file-contents shadow-edn) - (let ((hash (car (parseedn-read '((shadow/env . identity)))))) - (cider--shadow-parse-builds hash)))))) + (condition-case err + (let ((hash (car (parseedn-read '((shadow/env . identity) + (env . identity)))))) + (cider--shadow-parse-builds hash)) + (error + (user-error "Found an error while reading %s with message: %s" + shadow-edn + (error-message-string err)))))))) (defun cider-shadow-select-cljs-init-form () "Generate the init form for a shadow-cljs select-only REPL. @@ -1151,7 +1272,7 @@ It's intended to be used in your Emacs config." (defcustom cider-default-cljs-repl nil "The default ClojureScript REPL to start. This affects commands like `cider-jack-in-cljs'. Generally it's -intended to be set via .dir-locals.el for individual projects, as its +intended to be set via .dir-locals.el for individual projects, as it's relatively unlikely you'd like to use the same type of REPL in each project you're working on." :type '(choice (const :tag "Figwheel" figwheel) @@ -1164,14 +1285,11 @@ you're working on." (const :tag "Shadow w/o Server" shadow-select) (const :tag "Krell" krell) (const :tag "Nbb" nbb) + (const :tag "Basilisp" basilisp) (const :tag "Custom" custom)) :safe #'symbolp :package-version '(cider . "0.17.0")) -(make-obsolete-variable 'cider-cljs-lein-repl 'cider-default-cljs-repl "0.17") -(make-obsolete-variable 'cider-cljs-boot-repl 'cider-default-cljs-repl "0.17") -(make-obsolete-variable 'cider-cljs-gradle-repl 'cider-default-cljs-repl "0.17") - (defvar cider--select-cljs-repl-history nil) (defun cider-select-cljs-repl (&optional default) "Select the ClojureScript REPL to use with `cider-jack-in-cljs'. @@ -1247,12 +1365,15 @@ nil." (define-key map (kbd "j s") #'cider-jack-in-cljs) (define-key map (kbd "j m") #'cider-jack-in-clj&cljs) (define-key map (kbd "j u") #'cider-jack-in-universal) + (define-key map (kbd "j n") #'cider-start-nrepl-server) (define-key map (kbd "C-j j") #'cider-jack-in-clj) (define-key map (kbd "C-j s") #'cider-jack-in-cljs) (define-key map (kbd "C-j m") #'cider-jack-in-clj&cljs) + (define-key map (kbd "C-j n") #'cider-start-nrepl-server) (define-key map (kbd "C-j C-j") #'cider-jack-in-clj) (define-key map (kbd "C-j C-s") #'cider-jack-in-cljs) (define-key map (kbd "C-j C-m") #'cider-jack-in-clj&cljs) + (define-key map (kbd "C-j C-n") #'cider-start-nrepl-server) (define-key map (kbd "c j") #'cider-connect-clj) (define-key map (kbd "c s") #'cider-connect-cljs) (define-key map (kbd "c m") #'cider-connect-clj&cljs) @@ -1271,6 +1392,26 @@ nil." map) "CIDER jack-in and connect keymap.") +(defun cider--start-nrepl-server (params &optional on-port-callback) + "Start an nREPL server. +PARAMS is a plist optionally containing :project-dir and :jack-in-cmd. +ON-PORT-CALLBACK (optional) is a function of one argument (server buffer) +which is called by the process filter once the port of the connection has +been determined." + (nrepl-start-server-process + (plist-get params :project-dir) + (plist-get params :jack-in-cmd) + on-port-callback)) + +(defun cider--update-params (params) + "Fill-in the passed in PARAMS plist needed to start an nREPL server. +Updates :project-dir and :jack-in-cmd. +Also checks whether a matching session already exists." + (thread-first params + (cider--update-project-dir) + (cider--check-existing-session) + (cider--update-jack-in-cmd))) + ;;;###autoload (defun cider-jack-in-clj (params) "Start an nREPL server for the current project and connect to it. @@ -1278,35 +1419,40 @@ PARAMS is a plist optionally containing :project-dir and :jack-in-cmd. With the prefix argument, allow editing of the jack in command; with a double prefix prompt for all these parameters." (interactive "P") - (let ((params (thread-first - params - (cider--update-project-dir) - (cider--check-existing-session) - (cider--update-jack-in-cmd)))) - (nrepl-start-server-process - (plist-get params :project-dir) - (plist-get params :jack-in-cmd) + (let ((params (cider--update-params params))) + (cider--start-nrepl-server + params (lambda (server-buffer) (cider-connect-sibling-clj params server-buffer))))) +(defun cider-start-nrepl-server (params) + "Start an nREPL server for the current project, but don't connect to it. +PARAMS is a plist optionally containing :project-dir and :jack-in-cmd. +With the prefix argument, allow editing of the start server command; with a +double prefix prompt for all these parameters." + (interactive "P") + (cider--start-nrepl-server (cider--update-params params))) + ;;;###autoload (defun cider-jack-in-cljs (params) "Start an nREPL server for the current project and connect to it. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument, +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). + +With the prefix argument, allow editing of the jack in command; with a double prefix prompt for all these parameters." (interactive "P") - (let ((cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies)) + (let ((cider-enrich-classpath nil) ;; ensure it's disabled for cljs projects, for now + (cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies)) (cider-jack-in-lein-plugins (append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins)) (cider-jack-in-nrepl-middlewares (append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares)) (orig-buffer (current-buffer))) ;; cider--update-jack-in-cmd relies indirectly on the above dynamic vars - (let ((params (thread-first - params - (cider--update-project-dir) - (cider--check-existing-session) - (cider--update-jack-in-cmd)))) + (let ((params (thread-first params + (cider--update-project-dir) + (cider--check-existing-session) + (cider--update-jack-in-cmd)))) (nrepl-start-server-process (plist-get params :project-dir) (plist-get params :jack-in-cmd) @@ -1318,24 +1464,27 @@ these parameters." (defun cider-jack-in-clj&cljs (&optional params soft-cljs-start) "Start an nREPL server and connect with clj and cljs REPLs. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument, -allow for editing of the jack in command; with a double prefix prompt for -all these parameters. When SOFT-CLJS-START is non-nil, start cljs REPL +:cljs-repl-type (e.g. 'shadow, 'node, 'fighweel, etc). + +With the prefix argument, allow for editing of the jack in command; +with a double prefix prompt for all these parameters. + +When SOFT-CLJS-START is non-nil, start cljs REPL only when the ClojureScript dependencies are met." (interactive "P") - (let ((cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies)) + (let ((cider-enrich-classpath nil) ;; ensure it's disabled for cljs projects, for now + (cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies)) (cider-jack-in-lein-plugins (append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins)) (cider-jack-in-nrepl-middlewares (append cider-jack-in-nrepl-middlewares cider-jack-in-cljs-nrepl-middlewares)) (orig-buffer (current-buffer))) ;; cider--update-jack-in-cmd relies indirectly on the above dynamic vars - (let ((params (thread-first - params - (cider--update-project-dir) - (cider--check-existing-session) - (cider--update-jack-in-cmd) - (cider--update-cljs-type) - ;; already asked, don't ask on sibling connect - (plist-put :do-prompt nil)))) + (let ((params (thread-first params + (cider--update-project-dir) + (cider--check-existing-session) + (cider--update-jack-in-cmd) + (cider--update-cljs-type) + ;; already asked, don't ask on sibling connect + (plist-put :do-prompt nil)))) (nrepl-start-server-process (plist-get params :project-dir) (plist-get params :jack-in-cmd) @@ -1360,35 +1509,37 @@ server is created." (other-params (cider--gather-connect-params nil other-repl)) (ses-name (unless (nrepl-server-p other-repl) (sesman-session-name-for-object 'CIDER other-repl)))) - (thread-first - params - (cider--update-do-prompt) - (append other-params) - (plist-put :repl-init-function nil) - (plist-put :repl-type 'clj) - (plist-put :session-name ses-name))))) + (thread-first params + (cider--update-do-prompt) + (append other-params) + (plist-put :repl-init-function nil) + (plist-put :repl-type 'clj) + (plist-put :session-name ses-name))))) ;;;###autoload (defun cider-connect-sibling-cljs (params &optional other-repl) "Create a ClojureScript REPL with the same server as OTHER-REPL. -PARAMS is a plist optionally containing :cljs-repl-type (e.g. Node, -Figwheel, etc). All other parameters are inferred from the OTHER-REPL. +PARAMS is a plist optionally containing :cljs-repl-type (e.g. 'node, +'figwheel, 'shadow, etc). + +All other parameters are inferred from the OTHER-REPL. OTHER-REPL defaults to `cider-current-repl' but in programs can also be a server buffer, in which case a new session for that server is created." (interactive "P") (let* ((other-repl (or other-repl (cider-current-repl 'any 'ensure))) (other-params (cider--gather-connect-params nil other-repl)) + ;; type-related params from the JVM conn are undesired for a cljs conn: + (other-params (thread-first other-params (map-delete :repl-type) (map-delete :cljs-repl-type))) (ses-name (unless (nrepl-server-p other-repl) (sesman-session-name-for-object 'CIDER other-repl)))) (cider-nrepl-connect - (thread-first - params - (cider--update-do-prompt) - (append other-params) - (cider--update-cljs-type) - (cider--update-cljs-init-function) - (plist-put :session-name ses-name) - (plist-put :repl-type 'cljs))))) + (thread-first params + (cider--update-do-prompt) + (append other-params) + (cider--update-cljs-type) + (cider--update-cljs-init-function) + (plist-put :session-name ses-name) + (plist-put :repl-type 'cljs))))) ;;;###autoload (defun cider-connect-clj (&optional params) @@ -1397,50 +1548,52 @@ PARAMS is a plist optionally containing :host, :port and :project-dir. On prefix argument, prompt for all the parameters." (interactive "P") (cider-nrepl-connect - (thread-first - params - (cider--update-project-dir) - (cider--update-host-port) - (cider--check-existing-session) - (plist-put :repl-init-function nil) - (plist-put :session-name nil) - (plist-put :repl-type 'clj)))) + (thread-first params + (cider--update-project-dir) + (cider--update-host-port) + (cider--check-existing-session) + (plist-put :repl-init-function nil) + (plist-put :session-name nil) + (plist-put :repl-type 'clj)))) ;;;###autoload (defun cider-connect-cljs (&optional params) "Initialize a ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and -:cljs-repl-type (e.g. Node, Figwheel, etc). On prefix, prompt for all the +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). + +On prefix, prompt for all the parameters regardless of their supplied or default values." (interactive "P") (cider-nrepl-connect - (thread-first - params - (cider--update-project-dir) - (cider--update-host-port) - (cider--check-existing-session) - (cider--update-cljs-type) - (cider--update-cljs-init-function) - (plist-put :session-name nil) - (plist-put :repl-type 'cljs)))) + (thread-first params + (cider--update-project-dir) + (cider--update-host-port) + (cider--check-existing-session) + (cider--update-cljs-type) + (cider--update-cljs-init-function) + (plist-put :session-name nil) + (plist-put :repl-type 'cljs)))) ;;;###autoload (defun cider-connect-clj&cljs (params &optional soft-cljs-start) "Initialize a Clojure and ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and -:cljs-repl-type (e.g. Node, Figwheel, etc). When SOFT-CLJS-START is +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). When SOFT-CLJS-START is non-nil, don't start if ClojureScript requirements are not met." (interactive "P") - (let* ((params (thread-first - params - (cider--update-project-dir) - (cider--update-host-port) - (cider--check-existing-session) - (cider--update-cljs-type))) - (clj-repl (cider-connect-clj params))) - (if soft-cljs-start - (when (cider--check-cljs (plist-get params :cljs-repl-type) 'no-error) - (cider-connect-sibling-cljs params clj-repl)) + (let* ((params (thread-first params + (cider--update-project-dir) + (cider--update-host-port) + (cider--check-existing-session) + (cider--update-cljs-type))) + (clj-params (thread-first params + copy-sequence + (map-delete :cljs-repl-type))) + (clj-repl (cider-connect-clj clj-params))) + (when (if soft-cljs-start + (cider--check-cljs (plist-get params :cljs-repl-type) 'no-error) + t) (cider-connect-sibling-cljs params clj-repl)))) (defvar cider-connection-init-commands @@ -1506,10 +1659,9 @@ Params is a plist with the following keys (non-exhaustive) (setq-local buffer-file-name nil)) (let ((default-directory proj-dir)) (hack-dir-local-variables-non-file-buffer) - (thread-first - params - (plist-put :project-dir proj-dir) - (plist-put :--context-buffer (current-buffer))))))))) + (thread-first params + (plist-put :project-dir proj-dir) + (plist-put :--context-buffer (current-buffer))))))))) (defun cider--update-cljs-type (params) "Update :cljs-repl-type in PARAMS." @@ -1536,6 +1688,13 @@ Params is a plist with the following keys (non-exhaustive) (defvar cider--jack-in-cmd-history nil "History list for user-specified jack-in commands.") +(defun cider--format-cmd (command-resolved command cmd-params) + "Format COMMAND-RESOLVED or COMMAND followed by CMD-PARAMS." + (format "%s %s" command-resolved + (if (cider--jack-in-cmd-powershell-p command) + (cider--powershell-encode-command cmd-params) + cmd-params))) + (defun cider--update-jack-in-cmd (params) "Update :jack-in-cmd key in PARAMS. @@ -1575,14 +1734,12 @@ PARAMS is a plist with the following keys (non-exhaustive list) (eq cider-allow-jack-in-without-project 'warn) (or params-project-type (y-or-n-p "Are you sure you want to run `cider-jack-in' without a Clojure project? ")))) - (let ((cmd (format "%s %s" command-resolved - (if (cider--jack-in-cmd-powershell-p command) - (cider--powershell-encode-command cmd-params) - cmd-params)))) - (plist-put params :jack-in-cmd (if (or cider-edit-jack-in-command - (plist-get params :edit-jack-in-command)) - (read-string "jack-in command: " cmd 'cider--jack-in-cmd-history) - cmd)))) + (let* ((cmd (cider--format-cmd command-resolved command cmd-params)) + (edited-command (if (or cider-edit-jack-in-command + (plist-get params :edit-jack-in-command)) + (read-string "jack-in command: " cmd 'cider--jack-in-cmd-history) + cmd))) + (plist-put params :jack-in-cmd edited-command))) (user-error "`cider-jack-in' is not allowed without a Clojure project")))) (user-error "The %s executable isn't on your `exec-path'" command)))))) @@ -1600,10 +1757,9 @@ PARAMS is a plist with the following keys (non-exhaustive list) (cider-select-endpoint))))) (if (equal "local-unix-domain-socket" (car endpoint)) (plist-put params :socket-file (cdr endpoint)) - (thread-first - params - (plist-put :host (car endpoint)) - (plist-put :port (cdr endpoint))))))) + (thread-first params + (plist-put :host (car endpoint)) + (plist-put :port (cdr endpoint))))))) (defun cider--update-cljs-init-function (params) "Update repl type and any init PARAMS for cljs connections. @@ -1624,23 +1780,20 @@ over to cljs. (if (null repl-init-form) (plist-put params :cider-repl-cljs-upgrade-pending nil) - (thread-first - params - (plist-put :cider-repl-cljs-upgrade-pending t) - (plist-put :repl-init-function - (lambda () - (cider--check-cljs cljs-type) - ;; FIXME: ideally this should be done in the state handler - (setq-local cider-cljs-repl-type cljs-type) - (cider-nrepl-send-request - (list "op" "eval" - "ns" (cider-current-ns) - "code" repl-init-form) - (cider-repl-handler (current-buffer))) - (when (and (buffer-live-p nrepl-server-buffer) - cider-offer-to-open-cljs-app-in-browser) - (cider--offer-to-open-app-in-browser nrepl-server-buffer)))) - (plist-put :repl-init-form repl-init-form)))))) + (thread-first params + (plist-put :cider-repl-cljs-upgrade-pending t) + (plist-put :repl-init-function + (lambda () + (cider--check-cljs cljs-type) + (cider-nrepl-send-request + (list "op" "eval" + "ns" (cider-current-ns) + "code" repl-init-form) + (cider-repl-handler (current-buffer))) + (when (and (buffer-live-p nrepl-server-buffer) + cider-offer-to-open-cljs-app-in-browser) + (cider--offer-to-open-app-in-browser nrepl-server-buffer)))) + (plist-put :repl-init-form repl-init-form)))))) (defun cider--check-existing-session (params) "Ask for confirmation if a session with similar PARAMS already exists. @@ -1785,30 +1938,135 @@ of remote SSH hosts." (or (eq ?s filetype) (eq ?d filetype)))))) +(defun cider--path->path-port-pairs (path) + "Given PATH, returns all the possible pairs." + (thread-last path + cider--file-path + nrepl-extract-ports + (mapcar (lambda (port) + (list path port))) + ;; remove nils that may have been returned due to permission errors: + (seq-filter #'identity))) + +(defun cider--invoke-running-nrepl-path (f) + "Invokes F safely. + +Necessary since we run some OS-specific commands that may fail." + (condition-case nil + (let* ((x (funcall f))) + (mapcar (lambda (v) + (if (and (listp v) + (not (file-exists-p (car v)))) + nil + v)) + x)) + (error nil))) + (defun cider-locate-running-nrepl-ports (&optional dir) "Locate ports of running nREPL servers. When DIR is non-nil also look for nREPL port files in DIR. Return a list of list of the form (project-dir port)." - (let* ((paths (cider--running-nrepl-paths)) - (proj-ports (apply #'append - (mapcar (lambda (d) - (mapcar (lambda (p) (list (file-name-nondirectory (directory-file-name d)) p)) - (and d (nrepl-extract-ports (cider--file-path d))))) - (cons (clojure-project-dir dir) paths))))) - (seq-uniq (delq nil proj-ports)))) + (let* ((pairs (cider--running-nrepl-paths)) + (pairs (if-let (c (and dir (clojure-project-dir dir))) + (append (cider--path->path-port-pairs c) pairs) + pairs))) + (thread-last pairs + (delq nil) + (mapcar (lambda (x) + (list (file-name-nondirectory (directory-file-name (car x))) + (nth 1 x)))) + (seq-uniq)))) + +(defun cider--running-lein-nrepl-paths () + "Retrieve project paths of running lein nREPL servers. +Use `cider-ps-running-lein-nrepls-command' and +`cider-ps-running-lein-nrepl-path-regexp-list'." + (unless (eq system-type 'windows-nt) + (let (paths) + (with-temp-buffer + (insert (shell-command-to-string cider-ps-running-lein-nrepls-command)) + (dolist (regexp cider-ps-running-lein-nrepl-path-regexp-list) + (goto-char 1) + (while (re-search-forward regexp nil t) + (setq paths (cons (match-string 1) paths))))) + (seq-mapcat (lambda (path) + (cider--path->path-port-pairs path)) + paths)))) + +(defun cider--running-non-lein-nrepl-paths () + "Retrieve (directory, port) pairs of running nREPL servers other than Lein ones." + (unless (eq system-type 'windows-nt) + (let* ((bb-indicator "--nrepl-server") + (non-lein-nrepl-pids + (thread-last (split-string + (shell-command-to-string + ;; some of the `ps u` lines we intend to catch: + ;; 15411 0.0 0.0 37915744 16084 s000 S+ 3:02PM 0:00.02 bb --nrepl-server + ;; 13835 0.1 11.2 37159036 7528432 s009 S+ 2:47PM 6:41.29 java -cp src -m nrepl.cmdline + (format "ps u | grep -E 'java|%s' | grep -E 'nrepl.cmdline|%s' | grep -v -E 'leiningen|grep'" + bb-indicator + bb-indicator)) + "\n") + (mapcar (lambda (s) + (nth 1 (split-string s " ")))) + (seq-filter #'identity)))) + (when non-lein-nrepl-pids + (thread-last non-lein-nrepl-pids + (mapcar (lambda (pid) + (let* ( + ;; -a: This flag is used to combine conditions with AND instead of OR + ;; -d: Lists only the file descriptors that match the given + ;; -n: Inhibits the conversion of network numbers to host names. + ;; -Fn: output file entry information as separate lines, with 'n' designating network info. + ;; -p: specifies the . + (directory (thread-last (split-string (shell-command-to-string (concat "lsof -a -d cwd -n -Fn -p " pid)) + "\n") + (seq-map (lambda (s) + (when (string-prefix-p "n" s) + (replace-regexp-in-string "^n" "" s)))) + (seq-filter #'identity) + car)) + ;; -a: This flag is used to combine conditions with AND instead of OR + ;; -n: Inhibits the conversion of network numbers to host names. + ;; -P: (important!) Ensure ports are shown as numbers, even if they have a well-known name. + ;; -Fn: output file entry information as separate lines, with 'n' designating network info. + ;; -i: this option selects the listing of all network files. + ;; -p: specifies the . + (port (thread-last (split-string (shell-command-to-string (concat "lsof -n -P -Fn -i -a -p " pid)) + "\n") + (seq-map (lambda (s) + (when (string-prefix-p "n" s) + (replace-regexp-in-string ".*:" "" s)))) + (seq-filter #'identity) + (seq-filter (lambda (s) + (condition-case nil + (numberp (read s)) + (error nil)))) + car))) + (list directory port)))) + (seq-filter #'cadr)))))) + +(defun cider--running-local-nrepl-paths () + "Retrieve project paths of running nREPL servers. +Do it by looping over the open REPL buffers." + (thread-last (buffer-list) + (seq-filter + (lambda (b) + (string-prefix-p "*cider-repl" (buffer-name b)))) + (seq-map + (lambda (b) + (with-current-buffer b + (when-let ((dir (plist-get (cider--gather-connect-params) :project-dir)) + (port (plist-get (cider--gather-connect-params) :port))) + (list dir (prin1-to-string port)))))) + (seq-filter #'identity))) (defun cider--running-nrepl-paths () "Retrieve project paths of running nREPL servers. -Use `cider-ps-running-nrepls-command' and -`cider-ps-running-nrepl-path-regexp-list'." - (let (paths) - (with-temp-buffer - (insert (shell-command-to-string cider-ps-running-nrepls-command)) - (dolist (regexp cider-ps-running-nrepl-path-regexp-list) - (goto-char 1) - (while (re-search-forward regexp nil t) - (setq paths (cons (match-string 1) paths))))) - (seq-uniq paths))) +Search for lein or java processes including nrepl.command nREPL." + (append (cider--invoke-running-nrepl-path #'cider--running-lein-nrepl-paths) + (cider--invoke-running-nrepl-path #'cider--running-local-nrepl-paths) + (cider--invoke-running-nrepl-path #'cider--running-non-lein-nrepl-paths))) (defun cider--identify-buildtools-present (&optional project-dir) "Identify build systems present by their build files in PROJECT-DIR. @@ -1821,7 +2079,8 @@ PROJECT-DIR defaults to current project." (shadow-cljs . "shadow-cljs.edn") (gradle . "build.gradle") (gradle . "build.gradle.kts") - (nbb . "nbb.edn")))) + (nbb . "nbb.edn") + (basilisp . "basilisp.edn")))) (delq nil (mapcar (lambda (candidate) (when (file-exists-p (cdr candidate)) @@ -1941,17 +2200,29 @@ alternative to the default is `cider-random-tip'." (add-hook 'cider-connected-hook #'cider--maybe-inspire-on-connect) ;;;###autoload -(with-eval-after-load 'clojure-mode - (define-key clojure-mode-map (kbd "C-c M-x") #'cider) - (define-key clojure-mode-map (kbd "C-c M-j") #'cider-jack-in-clj) - (define-key clojure-mode-map (kbd "C-c M-J") #'cider-jack-in-cljs) - (define-key clojure-mode-map (kbd "C-c M-c") #'cider-connect-clj) - (define-key clojure-mode-map (kbd "C-c M-C") #'cider-connect-cljs) - (define-key clojure-mode-map (kbd "C-c C-x") 'cider-start-map) - (define-key clojure-mode-map (kbd "C-c C-s") 'sesman-map) +(defun cider--setup-clojure-major-mode (mode-map mode-hook) + "Setup Cider key bindings on a Clojure mode's MODE-MAP and hooks in MODE-HOOK." + (define-key mode-map (kbd "C-c M-x") #'cider) + (define-key mode-map (kbd "C-c M-j") #'cider-jack-in-clj) + (define-key mode-map (kbd "C-c M-J") #'cider-jack-in-cljs) + (define-key mode-map (kbd "C-c M-c") #'cider-connect-clj) + (define-key mode-map (kbd "C-c M-C") #'cider-connect-cljs) + (define-key mode-map (kbd "C-c C-x") 'cider-start-map) + (define-key mode-map (kbd "C-c C-s") 'sesman-map) (require 'sesman) - (sesman-install-menu clojure-mode-map) - (add-hook 'clojure-mode-hook (lambda () (setq-local sesman-system 'CIDER)))) + (sesman-install-menu mode-map) + (add-hook mode-hook (lambda () (setq-local sesman-system 'CIDER)))) + +;;;###autoload +(with-eval-after-load 'clojure-mode + (cider--setup-clojure-major-mode clojure-mode-map 'clojure-mode-hook)) + +;;;###autoload +(with-eval-after-load 'clojure-ts-mode + (cider--setup-clojure-major-mode + (with-suppressed-warnings ((free-vars clojure-ts-mode-map)) + clojure-ts-mode-map) + 'clojure-ts-mode-hook)) (provide 'cider) diff --git a/elpa/cider-20241203.1607/clojure.sh b/elpa/cider-20241203.1607/clojure.sh new file mode 100755 index 00000000..ee1d9676 --- /dev/null +++ b/elpa/cider-20241203.1607/clojure.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +# This wrapper script adds enrich-classpath's (https://github.com/clojure-emacs/enrich-classpath) functionalities to the `clojure` binary. +# It works by accepting the `clojure` binary as the first argument, and whatever arguments you'd pass to `clojure` as the rest. +# sample usage: clojure.sh clojure -Asome-alias <<< "(System/getProperty \"java.class.path\")" + +clojure="$1" +# remove it from "$@"/"$*": +shift + +file="deps.edn" + +if [ ! -e $file ]; then + echo "$file not found." + $clojure "$@" +elif [[ "$*" == *Spath* ]]; then + echo "-Spath was passed; skipping enrich-classpath." + $clojure "$@" +elif [[ "$*" == *Scp* ]]; then + echo "-Scp was passed; skipping enrich-classpath." + $clojure "$@" +else + + here="$PWD" + there=$(mktemp -d -t mytempdir.XXXXXX) + + # copy any relevant file to the temporary folder + files_to_copy=( ".tool-versions" # asdf runtime versions configuration + ) + for file_to_copy in "${files_to_copy[@]}"; do + if [ -e "$file_to_copy" ]; then + cp "$file_to_copy" "$there" + fi + done + + # don't let local deps.edn files interfere: + cd "$there" + + # enrich-classpath will emit a command starting by "clojure", or print a stacktrace: + output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.19.3"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@") + cmd=$(tail -n1 <(echo "$output")) + + cd "$here" + + if grep --silent "^$clojure" <<< "$cmd"; then + # eval is necessary because $cmd contains arguments that have been processed through pr-str. + eval "$cmd" + else + # Print errors: + echo "$output" + $clojure "$@" + fi + +fi diff --git a/elpa/cider-20241203.1607/lein.sh b/elpa/cider-20241203.1607/lein.sh new file mode 100755 index 00000000..028e1675 --- /dev/null +++ b/elpa/cider-20241203.1607/lein.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# there's no -Ee -o pipefail, intentionally + +# This wrapper script invokes lein with the provided args (which must include the enrich-classpath middleware), +# detecting success, and invoking in return the generated `java` command. +# It falls back to lein with the same args, except that the enrich middleware will be replaced with a no-op middleware. +# By having all this logic as a .sh script (vs. inline in Elisp), we can keep using the same process/async machinery, +# which is concise and results in a non-blocking UX. + +lein="$1" +shift + +output=$(2>&1 "$lein" "$@") +cmd=$(grep "\s-cp\s"<<< "$output") + +function cache_root() { + local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}" + cache_dir="${cache_dir/#\~/$HOME}" + mkdir -p "$cache_dir" 2>/dev/null + if [[ -w "$cache_dir" ]]; then + echo "${cache_dir%/}" + else + return 1 + fi +} + +if grep --silent "\s-cp\s"<<< "$cmd"; then + eval "$cmd" +else + # Print errors: + if cache_dir=$(cache_root); then + logfile="$cache_dir"/cider-enrich-classpath-error.log + echo "$output" >> "$logfile" + echo "Could not activate enrich-classpath. Error report available at $logfile" + fi + no_enrich=() + for arg in "$@"; do + if [ "$arg" == "cider.enrich-classpath.plugin-v2/middleware" ]; then + no_enrich+=("cider.enrich-classpath.fallback/middleware") + else + no_enrich+=("$arg") + fi + done + $lein "${no_enrich[@]}" +fi diff --git a/elpa/cider-20230707.640/nrepl-client.el b/elpa/cider-20241203.1607/nrepl-client.el similarity index 95% rename from elpa/cider-20230707.640/nrepl-client.el rename to elpa/cider-20241203.1607/nrepl-client.el index beb9b32d..ed29fc8a 100644 --- a/elpa/cider-20230707.640/nrepl-client.el +++ b/elpa/cider-20241203.1607/nrepl-client.el @@ -1,7 +1,7 @@ ;;; nrepl-client.el --- Client for Clojure nREPL -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -77,7 +77,8 @@ (require 'sesman) (require 'tramp) - +(require 'cider-util) + ;;; Custom (defgroup nrepl nil @@ -126,7 +127,6 @@ Setting this to nil disables the timeout functionality." When true some special buffers like the server buffer will be hidden." :type 'boolean) - ;;; Buffer Local Declarations ;; These variables are used to track the state of nREPL connections @@ -168,7 +168,6 @@ To be used for tooling calls (i.e. completion, eldoc, etc)") (defvar-local nrepl-aux nil "Auxiliary information received from the describe op.") - ;;; nREPL Buffer Names (defconst nrepl-message-buffer-name-template "*nrepl-messages %s(%r:%S)*") @@ -213,7 +212,6 @@ PARAMS is as in `nrepl-make-buffer-name'." "Return the name for the message buffer given connection PARAMS." (nrepl-make-buffer-name nrepl-message-buffer-name-template params)) - ;;; Utilities (defun nrepl-op-supported-p (op connection) "Return t iff the given operation OP is supported by the nREPL CONNECTION." @@ -232,29 +230,55 @@ PARAMS is as in `nrepl-make-buffer-name'." (defun nrepl-extract-port (dir) "Read port from applicable repl-port file in directory DIR." - (or (nrepl--port-from-file (expand-file-name "repl-port" dir)) - (nrepl--port-from-file (expand-file-name ".nrepl-port" dir)) - (nrepl--port-from-file (expand-file-name "target/repl-port" dir)) - (nrepl--port-from-file (expand-file-name ".shadow-cljs/nrepl.port" dir)))) + (condition-case nil + (or (nrepl--port-from-file (expand-file-name "repl-port" dir)) + (nrepl--port-from-file (expand-file-name ".nrepl-port" dir)) + (nrepl--port-from-file (expand-file-name "target/repl-port" dir)) + (nrepl--port-from-file (expand-file-name ".shadow-cljs/nrepl.port" dir))) + ;; This operation can hit permission errors, particularly on macOS: + (error nil))) (defun nrepl-extract-ports (dir) "Read ports from applicable repl-port files in directory DIR." - (delq nil - (list (nrepl--port-from-file (expand-file-name "repl-port" dir)) - (nrepl--port-from-file (expand-file-name ".nrepl-port" dir)) - (nrepl--port-from-file (expand-file-name "target/repl-port" dir)) - (nrepl--port-from-file (expand-file-name ".shadow-cljs/nrepl.port" dir))))) + (condition-case nil + (delq nil + (list (nrepl--port-from-file (expand-file-name "repl-port" dir)) + (nrepl--port-from-file (expand-file-name ".nrepl-port" dir)) + (nrepl--port-from-file (expand-file-name "target/repl-port" dir)) + (nrepl--port-from-file (expand-file-name ".shadow-cljs/nrepl.port" dir)))) + ;; This operation can hit permission errors, particularly on macOS: + (error nil))) (make-obsolete 'nrepl-extract-port 'nrepl-extract-ports "1.5.0") +(defun nrepl--port-string-to-number (s) + "Converts `S' from string to number when suitable." + (when (string-match "^\\([0-9]+\\)" s) + (string-to-number (match-string 0 s)))) + (defun nrepl--port-from-file (file) - "Attempts to read port from a file named by FILE." + "Attempts to read port from a file named by FILE. + +Discards it if it can be determined that the port is not active." (when (file-exists-p file) - (with-temp-buffer - (insert-file-contents file) - (buffer-string)))) + (when-let* ((port-string (with-temp-buffer + (insert-file-contents file) + (buffer-string))) + ;; extract the number, most of all for not passing garbage to `lsof' (which might even be a security risk): + (port-number (nrepl--port-string-to-number port-string))) + (if (eq system-type 'windows-nt) + port-string + (when (not (equal "" + (shell-command-to-string (format "lsof -i:%s" port-number)))) + port-string))))) + +(defun nrepl--ssh-file-name-matches-host-p (file-name host) + "Return t, if FILE-NAME is a tramp-file-name on HOST via ssh." + (when (tramp-tramp-file-p file-name) + (with-parsed-tramp-file-name file-name v + (and (member v-method '("ssh" "sshx")) + (member host (list v-host (concat v-host "#" v-port))))))) - ;;; Bencode (cl-defstruct (nrepl-response-queue @@ -422,7 +446,6 @@ specification. Everything else is encoded as string." ((listp object) (format "l%se" (mapconcat #'nrepl-bencode object ""))) (t (format "%s:%s" (string-bytes object) object)))) - ;;; Client: Process Filter (defvar nrepl-response-handler-functions nil @@ -464,7 +487,7 @@ older requests with \"done\" status." (gethash id nrepl-completed-requests)))) (if callback (funcall callback response) - (error "[nREPL] No response handler with id %s found" id))))) + (error "[nREPL] No response handler with id %s found for %s" id (buffer-name)))))) (defun nrepl-client-sentinel (process message) "Handle sentinel events from PROCESS. @@ -484,7 +507,9 @@ and kill the process buffer." (goto-char (point-max)) (insert-before-markers (propertize - (format "\n*** Closed on %s ***\n" (current-time-string)) + (format "\n*** Closed on %s ***\n" (replace-regexp-in-string " +" + " " + (current-time-string))) 'face 'cider-repl-stderr-face)) (run-hooks 'nrepl-disconnected-hook) (let ((server-buffer nrepl-server-buffer)) @@ -493,7 +518,6 @@ and kill the process buffer." (setq nrepl-server-buffer nil) (nrepl--maybe-kill-server-buffer server-buffer))))))) - ;;; Network (defun nrepl--unix-connect (socket-file &optional no-error) @@ -570,14 +594,12 @@ If NO-ERROR is non-nil, show messages instead of throwing an error." (defun nrepl--ssh-tunnel-connect (host port) "Connect to a remote machine identified by HOST and PORT through SSH tunnel." (message "[nREPL] Establishing SSH tunneled connection to %s:%s ..." host port) - (let* ((current-buf (buffer-file-name)) - (tramp-file-regexp "/ssh:\\(.+@\\)?\\(.+?\\)\\(:\\|#\\).+") + (let* ((file-name (or (buffer-file-name) nrepl-project-dir)) (remote-dir (cond ;; If current buffer is a TRAMP buffer and its host is ;; the same as HOST, reuse its connection parameters for ;; SSH tunnel. - ((and (string-match tramp-file-regexp current-buf) - (string= host (match-string 2 current-buf))) current-buf) + ((nrepl--ssh-file-name-matches-host-p file-name host) file-name) ;; Otherwise, if HOST was provided, use it for connection. (host (format "/ssh:%s:" host)) ;; Use default directory as fallback. @@ -635,7 +657,6 @@ If NO-ERROR is non-nil, show messages instead of throwing an error." (comint-watch-for-password-prompt string)) (if moving (goto-char (process-mark proc))))))))) - ;;; Client: Process Handling (defun nrepl--kill-process (proc) @@ -767,7 +788,6 @@ which we can eventually reuse." (setq nrepl-session nil) (setq nrepl-tooling-session nil))) - ;;; Client: Response Handling ;; After being decoded, responses (aka, messages from the server) are dispatched ;; to handlers. Handlers are constructed with `nrepl-make-response-handler'. @@ -838,7 +858,7 @@ the corresponding type of response." value ns out err status id) (when (buffer-live-p buffer) (with-current-buffer buffer - (when (and ns (not (derived-mode-p 'clojure-mode))) + (when (and ns (not (cider-clojure-major-mode-p))) (cider-set-buffer-ns ns)))) (cond ((and content-type content-type-handler) (funcall content-type-handler buffer @@ -876,7 +896,6 @@ the corresponding type of response." (when done-handler (funcall done-handler buffer)))))))) - ;;; Client: Request Core API ;; Requests are messages from an nREPL client (like CIDER) to an nREPL server. @@ -1064,7 +1083,6 @@ session." "Get a list of middleware on the nREPL server using CONNECTION." (nrepl-dict-get (nrepl-sync-request:ls-middleware connection) "middleware")) - ;;; Server ;; The server side process is started by `nrepl-start-server-process' and has a @@ -1227,7 +1245,6 @@ close any existing client connections." (buffer-substring (point-min) (point-max)))))) (error "Could not start nREPL server: %s (%S)" problem (string-trim event))))))) - ;;; Messages (defcustom nrepl-log-messages nil diff --git a/elpa/cider-20230707.640/nrepl-dict.el b/elpa/cider-20241203.1607/nrepl-dict.el similarity index 84% rename from elpa/cider-20230707.640/nrepl-dict.el rename to elpa/cider-20241203.1607/nrepl-dict.el index b6b2e980..d8daeb5c 100644 --- a/elpa/cider-20230707.640/nrepl-dict.el +++ b/elpa/cider-20241203.1607/nrepl-dict.el @@ -1,7 +1,7 @@ ;;; nrepl-dict.el --- Dictionary functions for Clojure nREPL -*- lexical-binding: t -*- -;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2023 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2012-2024 Tim King, Phil Hagelberg, Bozhidar Batsov +;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King ;; Phil Hagelberg @@ -28,7 +28,8 @@ ;;; Commentary: ;; ;; Provides functions to interact with and create `nrepl-dict's. These are -;; simply plists with an extra element at the head. +;; simply plists with an extra element at the head, and using `equal' for +;; comparison of string keys. ;;; Code: (require 'cl-lib) @@ -44,12 +45,11 @@ (maphash (lambda (k v) (nrepl-dict-put dict k v)) hash) dict)) -(defun nrepl-dict-p (object) +(defsubst nrepl-dict-p (object) "Return t if OBJECT is an nREPL dict." - (and (listp object) - (eq (car object) 'dict))) + (eq (car-safe object) 'dict)) -(defun nrepl-dict-empty-p (dict) +(defsubst nrepl-dict-empty-p (dict) "Return t if nREPL dict DICT is empty." (null (cdr dict))) @@ -61,14 +61,23 @@ whose car is KEY. Comparison is done with `equal'." (member key (nrepl-dict-keys dict))) (defun nrepl-dict-get (dict key &optional default) - "Get from DICT value associated with KEY, optional DEFAULT if KEY not in DICT. -If dict is nil, return nil. If DEFAULT not provided, and KEY not in DICT, -return nil. If DICT is not an nREPL dict object, an error is thrown." + "Get from DICT value associated with KEY. +If DICT is nil, return nil. +If DICT is not an nREPL dict object, an error is thrown. + +If KEY is not in DICT, return DEFAULT (if provided). +Note that the use of DEFAULT is deprecated and will be +removed in a future release." + (declare (advertised-calling-convention (dict key) "1.16")) (when dict (if (nrepl-dict-p dict) - (if (nrepl-dict-contains dict key) - (lax-plist-get (cdr dict) key) - default) + ;; Note: The structure of the following expression avoids the + ;; expensive containment check in nearly all cases, see #3717 + (or (lax-plist-get (cdr dict) key) + ;; TODO: remove DEFAULT argument and the following clause + (when default + (and (not (nrepl-dict-contains dict key)) + default))) (error "Not an nREPL dict object: %s" dict)))) (defun nrepl-dict-put (dict key value) @@ -86,14 +95,14 @@ Return new dict. Dict is modified by side effects." (if (nrepl-dict-p dict) (cl-loop for l on (cdr dict) by #'cddr collect (car l)) - (error "Not an nREPL dict"))) + (error "Not an nREPL dict object: %s" dict))) (defun nrepl-dict-vals (dict) "Return all the values in the nREPL DICT." (if (nrepl-dict-p dict) (cl-loop for l on (cdr dict) by #'cddr collect (cadr l)) - (error "Not an nREPL dict"))) + (error "Not an nREPL dict object: %s" dict))) (defun nrepl-dict-map (fn dict) "Map FN on nREPL DICT. @@ -101,7 +110,7 @@ FN must accept two arguments key and value." (if (nrepl-dict-p dict) (cl-loop for l on (cdr dict) by #'cddr collect (funcall fn (car l) (cadr l))) - (error "Not an nREPL dict"))) + (error "Not an nREPL dict object: %s" dict))) (defun nrepl-dict-merge (dict1 dict2) "Destructively merge DICT2 into DICT1. @@ -190,7 +199,7 @@ If NO-JOIN is given, return the first non nil dict." (t `(,dict1 ,dict2))))) -;;; Dbind +;;; Destructuring-bind of string keys (defmacro nrepl-dbind-response (response keys &rest body) "Destructure an nREPL RESPONSE dict. Bind the value of the provided KEYS and execute BODY." -- 2.47.3