From b8dc27e8c3901179234dd8f905b349678521a8f0 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 31 Oct 2019 14:51:42 +0100 Subject: [PATCH] update cider --- elpa/cider-20190121.1852/cider-grimoire.el | 130 ----- .../cider-apropos.el | 14 +- .../cider-autoloads.el | 290 ++++-------- .../cider-browse-ns.el | 0 .../cider-browse-spec.el | 0 .../cider-cheatsheet.el | 0 .../cider-classpath.el | 6 +- .../cider-client.el | 322 ++++++++----- elpa/cider-20191027.1704/cider-clojuredocs.el | 159 +++++++ .../cider-common.el | 31 +- .../cider-compat.el | 0 .../cider-completion.el | 6 +- .../cider-connection.el | 97 ++-- .../cider-debug.el | 131 ++++-- .../cider-doc.el | 45 +- .../cider-eldoc.el | 0 .../cider-eval.el | 251 ++++++---- .../cider-find.el | 2 - .../cider-format.el | 8 +- .../cider-inspector.el | 37 ++ .../cider-macroexpansion.el | 4 +- .../cider-mode.el | 77 ++- .../cider-ns.el | 57 ++- .../cider-overlays.el | 34 +- .../cider-pkg.el | 3 +- .../cider-popup.el | 0 .../cider-profile.el | 0 .../cider-repl-history.el | 12 +- .../cider-repl.el | 443 ++++++++---------- .../cider-resolve.el | 4 +- .../cider-scratch.el | 0 .../cider-selector.el | 24 +- .../cider-stacktrace.el | 28 +- .../cider-test.el | 34 +- .../cider-tracing.el | 0 .../cider-util.el | 9 +- elpa/cider-20191027.1704/cider-xref.el | 183 ++++++++ .../cider.el | 193 +++++--- .../nrepl-client.el | 30 +- .../nrepl-dict.el | 6 + 40 files changed, 1588 insertions(+), 1082 deletions(-) delete mode 100644 elpa/cider-20190121.1852/cider-grimoire.el rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-apropos.el (95%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-autoloads.el (70%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-browse-ns.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-browse-spec.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-cheatsheet.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-classpath.el (95%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-client.el (69%) create mode 100644 elpa/cider-20191027.1704/cider-clojuredocs.el rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-common.el (91%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-compat.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-completion.el (96%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-connection.el (91%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-debug.el (90%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-doc.el (93%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-eldoc.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-eval.el (87%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-find.el (99%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-format.el (95%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-inspector.el (91%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-macroexpansion.el (98%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-mode.el (94%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-ns.el (85%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-overlays.el (91%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-pkg.el (88%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-popup.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-profile.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-repl-history.el (98%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-repl.el (85%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-resolve.el (98%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-scratch.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-selector.el (86%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-stacktrace.el (98%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-test.el (98%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-tracing.el (100%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider-util.el (99%) create mode 100644 elpa/cider-20191027.1704/cider-xref.el rename elpa/{cider-20190121.1852 => cider-20191027.1704}/cider.el (89%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/nrepl-client.el (98%) rename elpa/{cider-20190121.1852 => cider-20191027.1704}/nrepl-dict.el (97%) diff --git a/elpa/cider-20190121.1852/cider-grimoire.el b/elpa/cider-20190121.1852/cider-grimoire.el deleted file mode 100644 index 93424883..00000000 --- a/elpa/cider-20190121.1852/cider-grimoire.el +++ /dev/null @@ -1,130 +0,0 @@ -;;; cider-grimoire.el --- Grimoire integration -*- lexical-binding: t -*- - -;; Copyright © 2014-2019 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: - -;; A few commands for Grimoire documentation lookup. - -;;; Code: - -(require 'cider-client) -(require 'cider-common) -(require 'subr-x) -(require 'cider-compat) -(require 'cider-popup) - -(require 'nrepl-dict) - -(require 'url-vars) - -(declare-function markdown-mode "markdown-mode.el") -(declare-function markdown-toggle-fontify-code-blocks-natively "markdown-mode.el") - -(defconst cider-grimoire-url "http://conj.io/") - -(defconst cider-grimoire-buffer "*cider-grimoire*") - -(defun cider-grimoire-replace-special (name) - "Convert the dashes in NAME to a grimoire friendly format." - (thread-last name - (replace-regexp-in-string "\\?" "_QMARK_") - (replace-regexp-in-string "\\." "_DOT_") - (replace-regexp-in-string "\\/" "_SLASH_") - (replace-regexp-in-string "\\(\\`_\\)\\|\\(_\\'\\)" ""))) - -(defun cider-grimoire-url (name ns) - "Generate a grimoire search v0 url from NAME, NS." - (let ((base-url cider-grimoire-url)) - (when (and name ns) - (concat base-url "search/v0/" ns "/" (cider-grimoire-replace-special name) "/")))) - -(defun cider-grimoire-web-lookup (symbol) - "Open the grimoire documentation for SYMBOL in a web browser." - (if-let* ((var-info (cider-var-info symbol))) - (let ((name (nrepl-dict-get var-info "name")) - (ns (nrepl-dict-get var-info "ns"))) - (browse-url (cider-grimoire-url name ns))) - (error "Symbol %s not resolved" symbol))) - -;;;###autoload -(defun cider-grimoire-web (&optional arg) - "Open grimoire documentation in the default web browser. - -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") - (funcall (cider-prompt-for-symbol-function arg) - "Grimoire doc for" - #'cider-grimoire-web-lookup)) - -(defun cider-create-grimoire-buffer (content) - "Create a new grimoire buffer with CONTENT." - (with-current-buffer (cider-popup-buffer cider-grimoire-buffer t) - (read-only-mode -1) - (insert content) - (when (require 'markdown-mode nil 'noerror) - (markdown-mode) - (cider-popup-buffer-mode 1) - (when (fboundp 'markdown-toggle-fontify-code-blocks-natively) - (markdown-toggle-fontify-code-blocks-natively 1))) - (view-mode 1) - (goto-char (point-min)) - (current-buffer))) - -(defun cider-grimoire-lookup (symbol) - "Look up the grimoire documentation for SYMBOL. - -If SYMBOL is a special form, the clojure.core ns is used, as is -Grimoire's convention." - (if-let* ((var-info (cider-var-info symbol))) - (let ((name (nrepl-dict-get var-info "name")) - (ns (nrepl-dict-get var-info "ns" "clojure.core")) - (url-request-method "GET") - (url-request-extra-headers `(("Content-Type" . "text/plain")))) - (url-retrieve (cider-grimoire-url name ns) - (lambda (_status) - ;; we need to strip the http header - (goto-char (point-min)) - (re-search-forward "^$") - (delete-region (point-min) (point)) - (delete-blank-lines) - ;; and create a new buffer with whatever is left - (pop-to-buffer (cider-create-grimoire-buffer (buffer-string)))))) - (error "Symbol %s not resolved" symbol))) - -;;;###autoload -(defun cider-grimoire (&optional arg) - "Open grimoire documentation in a popup buffer. - -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) - (user-error "`cider-grimoire' doesn't support ClojureScript")) - (funcall (cider-prompt-for-symbol-function arg) - "Grimoire doc for" - #'cider-grimoire-lookup)) - -(provide 'cider-grimoire) - -;;; cider-grimoire.el ends here diff --git a/elpa/cider-20190121.1852/cider-apropos.el b/elpa/cider-20191027.1704/cider-apropos.el similarity index 95% rename from elpa/cider-20190121.1852/cider-apropos.el rename to elpa/cider-20191027.1704/cider-apropos.el index 6c0ca5d6..8b19609a 100644 --- a/elpa/cider-20190121.1852/cider-apropos.el +++ b/elpa/cider-20191027.1704/cider-apropos.el @@ -29,6 +29,7 @@ (require 'cider-util) (require 'subr-x) (require 'cider-compat) +(require 'cider-mode) (require 'cider-client) (require 'cider-popup) @@ -42,7 +43,7 @@ (defcustom cider-apropos-actions '(("display-doc" . cider-doc-lookup) ("find-def" . cider--find-var) - ("lookup-on-grimoire" . cider-grimoire-lookup)) + ("lookup-on-clojuredocs" . cider-clojuredocs-lookup)) "Controls the actions to be applied on the symbol found by an apropos search. The first action key in the list will be selected as default. If the list contains only one action key, the associated action function will be @@ -96,10 +97,13 @@ and be case-sensitive (based on CASE-SENSITIVE-P)." "Emit a RESULT matching QUERY into current buffer, formatted for DOCS-P." (nrepl-dbind-response result (name type doc) (let* ((label (capitalize (if (string= type "variable") "var" type))) - (help (concat "Display doc for this " (downcase label)))) - (cider-propertize-region (list 'apropos-symbol name - 'action 'cider-apropos-doc - 'help-echo help) + (help (concat "Display doc for this " (downcase label))) + (props (list 'apropos-symbol name + 'action 'cider-apropos-doc)) + (props (if cider-use-tooltips + (append props (list 'help-echo help)) + props))) + (cider-propertize-region props (insert-text-button name 'type 'apropos-symbol) (insert "\n ") (insert-text-button label 'type (intern (concat "apropos-" type))) diff --git a/elpa/cider-20190121.1852/cider-autoloads.el b/elpa/cider-20191027.1704/cider-autoloads.el similarity index 70% rename from elpa/cider-20190121.1852/cider-autoloads.el rename to elpa/cider-20191027.1704/cider-autoloads.el index 56c25811..d07341e6 100644 --- a/elpa/cider-20190121.1852/cider-autoloads.el +++ b/elpa/cider-20191027.1704/cider-autoloads.el @@ -1,12 +1,9 @@ ;;; cider-autoloads.el --- automatically extracted autoloads ;; ;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) -;;;### (autoloads nil "cider" "cider.el" (0 0 0 0)) +;;;### (autoloads nil "cider" "cider.el" (23994 46787 338102 379000)) ;;; Generated autoloads from cider.el (autoload 'cider-version "cider" "\ @@ -18,7 +15,8 @@ Display CIDER's version. (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, prompt for all these parameters. +With the prefix argument, allow editing of the jack in command; with a +double prefix prompt for all these parameters. \(fn PARAMS)" t nil) @@ -26,7 +24,8 @@ With the prefix argument, prompt for all these parameters. 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, -prompt for all these parameters. +allow editing of the jack in command; with a double prefix prompt for all +these parameters. \(fn PARAMS)" t nil) @@ -34,8 +33,9 @@ prompt for all these parameters. 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, -prompt for all these parameters. When SOFT-CLJS-START is non-nil, start -cljs REPL only when the ClojureScript dependencies are met. +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. \(fn &optional PARAMS SOFT-CLJS-START)" t nil) @@ -87,27 +87,26 @@ Start a connection of any type interactively. (defalias 'cider-jack-in #'cider-jack-in-clj) -(defalias 'cider-jack-in-clojure #'cider-jack-in-clj) +(define-obsolete-function-alias 'cider-jack-in-clojure 'cider-jack-in-clj "0.22") -(defalias 'cider-jack-in-clojurescript #'cider-jack-in-cljs) +(define-obsolete-function-alias 'cider-jack-in-clojurescript 'cider-jack-in-cljs "0.22") (defalias 'cider-connect #'cider-connect-clj) -(defalias 'cider-connect-clojure #'cider-connect-clj) +(define-obsolete-function-alias 'cider-connect-clojure 'cider-connect-clj "0.22") -(defalias 'cider-connect-clojurescript #'cider-connect-cljs) +(define-obsolete-function-alias 'cider-connect-clojurescript 'cider-connect-cljs "0.22") -(defalias 'cider-connect-sibling-clojure #'cider-connect-sibling-clj) +(define-obsolete-function-alias 'cider-connect-sibling-clojure 'cider-connect-sibling-clj "0.22") -(defalias 'cider-connect-sibling-clojurescript #'cider-connect-sibling-cljs) +(define-obsolete-function-alias 'cider-connect-sibling-clojurescript 'cider-connect-sibling-cljs "0.22") (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)))) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-apropos" "cider-apropos.el" (0 0 0 0)) +;;;### (autoloads nil "cider-apropos" "cider-apropos.el" (23994 46787 +;;;;;; 362746 719000)) ;;; Generated autoloads from cider-apropos.el (autoload 'cider-apropos "cider-apropos" "\ @@ -141,12 +140,10 @@ Shortcut for (cider-apropos-select nil t). \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-apropos" '("cider-" "apropos-special-form"))) - ;;;*** -;;;### (autoloads nil "cider-browse-ns" "cider-browse-ns.el" (0 0 -;;;;;; 0 0)) +;;;### (autoloads nil "cider-browse-ns" "cider-browse-ns.el" (23994 +;;;;;; 46787 349161 109000)) ;;; Generated autoloads from cider-browse-ns.el (autoload 'cider-browse-ns "cider-browse-ns" "\ @@ -159,12 +156,10 @@ List all loaded namespaces in BUFFER. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-browse-ns" '("cider-browse-ns-"))) - ;;;*** ;;;### (autoloads nil "cider-browse-spec" "cider-browse-spec.el" -;;;;;; (0 0 0 0)) +;;;;;; (23994 46787 360446 881000)) ;;; Generated autoloads from cider-browse-spec.el (autoload 'cider-browse-spec "cider-browse-spec" "\ @@ -180,12 +175,10 @@ No filter applied if the regexp is the empty string. \(fn &optional ARG)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-browse-spec" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-cheatsheet" "cider-cheatsheet.el" (0 -;;;;;; 0 0 0)) +;;;### (autoloads nil "cider-cheatsheet" "cider-cheatsheet.el" (23994 +;;;;;; 46787 358216 149000)) ;;; Generated autoloads from cider-cheatsheet.el (autoload 'cider-cheatsheet "cider-cheatsheet" "\ @@ -195,12 +188,10 @@ When you make it to a Clojure var its doc buffer gets displayed. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-cheatsheet" '("cider-cheatsheet-"))) - ;;;*** -;;;### (autoloads nil "cider-classpath" "cider-classpath.el" (0 0 -;;;;;; 0 0)) +;;;### (autoloads nil "cider-classpath" "cider-classpath.el" (23994 +;;;;;; 46787 340329 115000)) ;;; Generated autoloads from cider-classpath.el (autoload 'cider-classpath "cider-classpath" "\ @@ -213,41 +204,39 @@ Open a classpath entry. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-classpath" '("cider-classpath-"))) - ;;;*** -;;;### (autoloads nil "cider-client" "cider-client.el" (0 0 0 0)) -;;; Generated autoloads from cider-client.el +;;;### (autoloads nil "cider-clojuredocs" "cider-clojuredocs.el" +;;;;;; (23994 46787 347024 145000)) +;;; Generated autoloads from cider-clojuredocs.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-client" '("cider-"))) +(autoload 'cider-clojuredocs-web "cider-clojuredocs" "\ +Open ClojureDocs documentation in the default web browser. -;;;*** - -;;;### (autoloads nil "cider-common" "cider-common.el" (0 0 0 0)) -;;; Generated autoloads from cider-common.el +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. -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-common" '("cider-"))) +\(fn &optional ARG)" t nil) -;;;*** - -;;;### (autoloads nil "cider-completion" "cider-completion.el" (0 -;;;;;; 0 0 0)) -;;; Generated autoloads from cider-completion.el +(autoload 'cider-clojuredocs-refresh-cache "cider-clojuredocs" "\ +Refresh the ClojureDocs cache. -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-completion" '("cider-"))) +\(fn)" t nil) -;;;*** - -;;;### (autoloads nil "cider-connection" "cider-connection.el" (0 -;;;;;; 0 0 0)) -;;; Generated autoloads from cider-connection.el +(autoload 'cider-clojuredocs "cider-clojuredocs" "\ +Open ClojureDocs documentation in a popup buffer. + +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. -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-connection" '("cider-"))) +\(fn &optional ARG)" t nil) ;;;*** -;;;### (autoloads nil "cider-debug" "cider-debug.el" (0 0 0 0)) +;;;### (autoloads nil "cider-debug" "cider-debug.el" (23994 46787 +;;;;;; 321717 694000)) ;;; Generated autoloads from cider-debug.el (autoload 'cider-debug-defun-at-point "cider-debug" "\ @@ -261,32 +250,10 @@ a number of keys will be prompted to the user. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-debug" '("cider-"))) - -;;;*** - -;;;### (autoloads nil "cider-doc" "cider-doc.el" (0 0 0 0)) -;;; Generated autoloads from cider-doc.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-doc" '("cider-"))) - -;;;*** - -;;;### (autoloads nil "cider-eldoc" "cider-eldoc.el" (0 0 0 0)) -;;; Generated autoloads from cider-eldoc.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-eldoc" '("cider-"))) - -;;;*** - -;;;### (autoloads nil "cider-eval" "cider-eval.el" (0 0 0 0)) -;;; Generated autoloads from cider-eval.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-eval" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-find" "cider-find.el" (0 0 0 0)) +;;;### (autoloads nil "cider-find" "cider-find.el" (23994 46787 352722 +;;;;;; 741000)) ;;; Generated autoloads from cider-find.el (autoload 'cider-find-var "cider-find" "\ @@ -348,11 +315,10 @@ thing at point. \(fn &optional ARG)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-find" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-format" "cider-format.el" (0 0 0 0)) +;;;### (autoloads nil "cider-format" "cider-format.el" (23994 46787 +;;;;;; 317854 377000)) ;;; Generated autoloads from cider-format.el (autoload 'cider-format-region "cider-format" "\ @@ -387,38 +353,10 @@ Format the EDN data of the last sexp. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-format" '("cider--format-"))) - ;;;*** -;;;### (autoloads nil "cider-grimoire" "cider-grimoire.el" (0 0 0 -;;;;;; 0)) -;;; Generated autoloads from cider-grimoire.el - -(autoload 'cider-grimoire-web "cider-grimoire" "\ -Open grimoire documentation in the default web browser. - -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) - -(autoload 'cider-grimoire "cider-grimoire" "\ -Open grimoire documentation in a popup buffer. - -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) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-grimoire" '("cider-"))) - -;;;*** - -;;;### (autoloads nil "cider-inspector" "cider-inspector.el" (0 0 -;;;;;; 0 0)) +;;;### (autoloads nil "cider-inspector" "cider-inspector.el" (23994 +;;;;;; 46787 332162 234000)) ;;; Generated autoloads from cider-inspector.el (autoload 'cider-inspect-last-sexp "cider-inspector" "\ @@ -451,12 +389,10 @@ current buffer's namespace. \(fn EXPR NS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-inspector" '("cider-"))) - ;;;*** ;;;### (autoloads nil "cider-macroexpansion" "cider-macroexpansion.el" -;;;;;; (0 0 0 0)) +;;;;;; (23994 46787 336918 325000)) ;;; Generated autoloads from cider-macroexpansion.el (autoload 'cider-macroexpand-1 "cider-macroexpansion" "\ @@ -471,11 +407,10 @@ Invoke \\=`macroexpand-all\\=` on the expression preceding point. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-macroexpansion" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-mode" "cider-mode.el" (0 0 0 0)) +;;;### (autoloads nil "cider-mode" "cider-mode.el" (23994 46787 345945 +;;;;;; 693000)) ;;; Generated autoloads from cider-mode.el (defvar cider-mode-line '(:eval (format " cider[%s]" (cider--modeline-info))) "\ @@ -500,11 +435,10 @@ Minor mode for REPL interaction from a Clojure buffer. \(fn &optional ARG)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-mode" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-ns" "cider-ns.el" (0 0 0 0)) +;;;### (autoloads nil "cider-ns" "cider-ns.el" (23994 46787 351533 +;;;;;; 778000)) ;;; Generated autoloads from cider-ns.el (autoload 'cider-ns-reload "cider-ns" "\ @@ -551,26 +485,10 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and (define-obsolete-function-alias 'cider-refresh 'cider-ns-refresh "0.18") -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-ns" '("cider-ns-"))) - -;;;*** - -;;;### (autoloads nil "cider-overlays" "cider-overlays.el" (0 0 0 -;;;;;; 0)) -;;; Generated autoloads from cider-overlays.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-overlays" '("cider-"))) - -;;;*** - -;;;### (autoloads nil "cider-popup" "cider-popup.el" (0 0 0 0)) -;;; Generated autoloads from cider-popup.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-popup" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-profile" "cider-profile.el" (0 0 0 0)) +;;;### (autoloads nil "cider-profile" "cider-profile.el" (23994 46787 +;;;;;; 333278 435000)) ;;; Generated autoloads from cider-profile.el (autoload 'cider-profile-samples "cider-profile" "\ @@ -617,19 +535,10 @@ Clear any collected profile data. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-profile" '("cider-profile-"))) - -;;;*** - -;;;### (autoloads nil "cider-repl" "cider-repl.el" (0 0 0 0)) -;;; Generated autoloads from cider-repl.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-repl" '("cider-"))) - ;;;*** ;;;### (autoloads nil "cider-repl-history" "cider-repl-history.el" -;;;;;; (0 0 0 0)) +;;;;;; (23994 46787 330975 600000)) ;;; Generated autoloads from cider-repl-history.el (autoload 'cider-repl-history "cider-repl-history" "\ @@ -637,18 +546,10 @@ Display items in the CIDER command history in another buffer. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (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 - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-resolve" '("cider-resolve-"))) - ;;;*** -;;;### (autoloads nil "cider-scratch" "cider-scratch.el" (0 0 0 0)) +;;;### (autoloads nil "cider-scratch" "cider-scratch.el" (23994 46787 +;;;;;; 323692 59000)) ;;; Generated autoloads from cider-scratch.el (autoload 'cider-scratch "cider-scratch" "\ @@ -656,36 +557,25 @@ Go to the scratch buffer named `cider-scratch-buffer-name'. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-scratch" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-selector" "cider-selector.el" (0 0 0 -;;;;;; 0)) +;;;### (autoloads nil "cider-selector" "cider-selector.el" (23994 +;;;;;; 46787 329803 229000)) ;;; Generated autoloads from cider-selector.el (autoload 'cider-selector "cider-selector" "\ Select a new buffer by type, indicated by a single character. The user is prompted for a single character indicating the method by -which to choose a new buffer. The `?' character describes then +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) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-selector" '("??" "?c" "?e" "?q" "?r" "?m" "?x" "?p" "?d" "?s" "def-cider-selector-method" "cider-selector-"))) - ;;;*** -;;;### (autoloads nil "cider-stacktrace" "cider-stacktrace.el" (0 -;;;;;; 0 0 0)) -;;; Generated autoloads from cider-stacktrace.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-stacktrace" '("cider-"))) - -;;;*** - -;;;### (autoloads nil "cider-test" "cider-test.el" (0 0 0 0)) +;;;### (autoloads nil "cider-test" "cider-test.el" (23994 46787 341379 +;;;;;; 213000)) ;;; Generated autoloads from cider-test.el (defvar cider-auto-test-mode nil "\ @@ -707,11 +597,10 @@ nothing if no tests are defined or if the file failed to load. \(fn &optional ARG)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-test" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-tracing" "cider-tracing.el" (0 0 0 0)) +;;;### (autoloads nil "cider-tracing" "cider-tracing.el" (23994 46787 +;;;;;; 344834 674000)) ;;; Generated autoloads from cider-tracing.el (autoload 'cider-toggle-trace-var "cider-tracing" "\ @@ -728,11 +617,10 @@ Defaults to the current ns. With prefix arg QUERY, prompts for a ns. \(fn QUERY)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-tracing" '("cider-"))) - ;;;*** -;;;### (autoloads nil "cider-util" "cider-util.el" (0 0 0 0)) +;;;### (autoloads nil "cider-util" "cider-util.el" (23994 46787 327338 +;;;;;; 170000)) ;;; Generated autoloads from cider-util.el (autoload 'cider-view-manual "cider-util" "\ @@ -740,26 +628,39 @@ View the manual in your default browser. \(fn)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "cider-util" '("cider-"))) - ;;;*** -;;;### (autoloads nil "nrepl-client" "nrepl-client.el" (0 0 0 0)) -;;; Generated autoloads from nrepl-client.el +;;;### (autoloads nil "cider-xref" "cider-xref.el" (23994 46787 353930 +;;;;;; 359000)) +;;; Generated autoloads from cider-xref.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "nrepl-client" '("nrepl-" "cider-enlighten-mode"))) +(autoload 'cider-xref-fn-refs "cider-xref" "\ +Show all functions that reference the var matching NS and SYMBOL. -;;;*** - -;;;### (autoloads nil "nrepl-dict" "nrepl-dict.el" (0 0 0 0)) -;;; Generated autoloads from nrepl-dict.el +\(fn &optional NS SYMBOL)" t nil) + +(autoload 'cider-xref-fn-deps "cider-xref" "\ +Show all functions referenced by the var matching NS and SYMBOL. + +\(fn &optional NS SYMBOL)" t nil) + +(autoload 'cider-xref-fn-refs-select "cider-xref" "\ +Displays the references for NS and SYMBOL using completing read. + +\(fn &optional NS SYMBOL)" t nil) + +(autoload 'cider-xref-fn-deps-select "cider-xref" "\ +Displays the function dependencies for NS and SYMBOL using completing read. -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "nrepl-dict" '("nrepl-"))) +\(fn &optional NS SYMBOL)" t nil) ;;;*** -;;;### (autoloads nil nil ("cider-compat.el" "cider-pkg.el") (0 0 -;;;;;; 0 0)) +;;;### (autoloads nil nil ("cider-client.el" "cider-common.el" "cider-compat.el" +;;;;;; "cider-completion.el" "cider-connection.el" "cider-doc.el" +;;;;;; "cider-eldoc.el" "cider-eval.el" "cider-overlays.el" "cider-pkg.el" +;;;;;; "cider-popup.el" "cider-repl.el" "cider-resolve.el" "cider-stacktrace.el" +;;;;;; "nrepl-client.el" "nrepl-dict.el") (23994 46787 361626 850000)) ;;;*** @@ -767,6 +668,5 @@ View the manual in your default browser. ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 ;; End: ;;; cider-autoloads.el ends here diff --git a/elpa/cider-20190121.1852/cider-browse-ns.el b/elpa/cider-20191027.1704/cider-browse-ns.el similarity index 100% rename from elpa/cider-20190121.1852/cider-browse-ns.el rename to elpa/cider-20191027.1704/cider-browse-ns.el diff --git a/elpa/cider-20190121.1852/cider-browse-spec.el b/elpa/cider-20191027.1704/cider-browse-spec.el similarity index 100% rename from elpa/cider-20190121.1852/cider-browse-spec.el rename to elpa/cider-20191027.1704/cider-browse-spec.el diff --git a/elpa/cider-20190121.1852/cider-cheatsheet.el b/elpa/cider-20191027.1704/cider-cheatsheet.el similarity index 100% rename from elpa/cider-20190121.1852/cider-cheatsheet.el rename to elpa/cider-20191027.1704/cider-cheatsheet.el diff --git a/elpa/cider-20190121.1852/cider-classpath.el b/elpa/cider-20191027.1704/cider-classpath.el similarity index 95% rename from elpa/cider-20190121.1852/cider-classpath.el rename to elpa/cider-20191027.1704/cider-classpath.el index b40a3cee..3b242c6a 100644 --- a/elpa/cider-20190121.1852/cider-classpath.el +++ b/elpa/cider-20191027.1704/cider-classpath.el @@ -91,20 +91,18 @@ "List all classpath entries." (interactive) (cider-ensure-connected) - (cider-ensure-op-supported "classpath") (with-current-buffer (cider-popup-buffer cider-classpath-buffer 'select nil 'ancillary) (cider-classpath-list (current-buffer) (mapcar (lambda (name) (cider-classpath-properties name)) - (cider-sync-request:classpath))))) + (cider-classpath-entries))))) ;;;###autoload (defun cider-open-classpath-entry () "Open a classpath entry." (interactive) (cider-ensure-connected) - (cider-ensure-op-supported "classpath") - (when-let* ((entry (completing-read "Classpath entries: " (cider-sync-request:classpath)))) + (when-let* ((entry (completing-read "Classpath entries: " (cider-classpath-entries)))) (find-file-other-window entry))) (provide 'cider-classpath) diff --git a/elpa/cider-20190121.1852/cider-client.el b/elpa/cider-20191027.1704/cider-client.el similarity index 69% rename from elpa/cider-20190121.1852/cider-client.el rename to elpa/cider-20191027.1704/cider-client.el index 8a155568..6be6e9f0 100644 --- a/elpa/cider-20190121.1852/cider-client.el +++ b/elpa/cider-20191027.1704/cider-client.el @@ -25,16 +25,19 @@ ;;; Code: +(require 'map) +(require 'seq) +(require 'subr-x) +(require 'parseedn) + +(require 'clojure-mode) (require 'spinner) -(require 'nrepl-client) + +(require 'cider-compat) (require 'cider-connection) (require 'cider-common) (require 'cider-util) -(require 'clojure-mode) - -(require 'subr-x) -(require 'cider-compat) -(require 'seq) +(require 'nrepl-client) ;;; Eval spinner @@ -59,6 +62,14 @@ Value is a symbol. The possible values are the symbols in the :group 'cider :package-version '(cider . "0.10.0")) +(defcustom cider-enhanced-cljs-completion-p t + "This setting enables dynamic cljs completions. +That is, expressions at point are evaluated and the properties of the +resulting value are used to compute completions." + :type 'boolean + :group 'cider + :package-version '(cider . "0.23.0")) + (defun cider-spinner-start (buffer) "Start the evaluation spinner in BUFFER. Do nothing if `cider-show-eval-spinner' is nil." @@ -112,33 +123,38 @@ will return nil instead of \"user\"." (buffer-local-value 'cider-buffer-ns repl)) (if no-default nil "user"))) +(defun cider-path-to-ns (relpath) + "Transform RELPATH to Clojure namespace. +Remove extension and substitute \"/\" with \".\", \"_\" with \"-\"." + (thread-last relpath + (file-name-sans-extension) + (replace-regexp-in-string "/" ".") + (replace-regexp-in-string "_" "-"))) + (defun cider-expected-ns (&optional path) "Return the namespace string matching PATH, or nil if not found. -PATH is expected to be an absolute file path. If PATH is nil, use the path -to the file backing the current buffer. The command falls back to -`clojure-expected-ns' in the absence of an active nREPL connection." +If PATH is nil, use the path to the file backing the current buffer. The +command falls back to `clojure-expected-ns' in the absence of an active +nREPL connection." (if (cider-connected-p) - (let* ((path (or path (file-truename (buffer-file-name)))) - (relpath (thread-last (cider-sync-request:classpath) - (seq-map - (lambda (cp) - (when (string-prefix-p cp path) - (substring path (length cp))))) + (let* ((path (file-truename (or path buffer-file-name))) + (relpath (thread-last (cider-classpath-entries) + (seq-filter #'file-directory-p) + (seq-map (lambda (dir) + (when (file-in-directory-p path dir) + (file-relative-name path dir)))) (seq-filter #'identity) (seq-sort (lambda (a b) (< (length a) (length b)))) (car)))) (if relpath - (thread-last (substring relpath 1) ; remove leading / - (file-name-sans-extension) - (replace-regexp-in-string "/" ".") - (replace-regexp-in-string "_" "-")) + (cider-path-to-ns relpath) (clojure-expected-ns path))) (clojure-expected-ns path))) (defun cider-nrepl-op-supported-p (op &optional connection) "Check whether the CONNECTION supports the nREPL middleware OP." - (nrepl-op-supported-p op (or connection (cider-current-repl)))) + (nrepl-op-supported-p op (or connection (cider-current-repl nil 'ensure)))) (defvar cider-version) (defun cider-ensure-op-supported (op) @@ -153,7 +169,7 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\" \"par1\" ... ). If CONNECTION is provided dispatch to that connection instead of the current connection. Return the id of the sent message." - (nrepl-send-request request callback (or connection (cider-current-repl 'any)))) + (nrepl-send-request request callback (or connection (cider-current-repl 'any 'ensure)))) (defun cider-nrepl-send-sync-request (request &optional connection abort-on-input) "Send REQUEST to the nREPL server synchronously using CONNECTION. @@ -163,13 +179,13 @@ If ABORT-ON-INPUT is non-nil, the function will return nil at the first sign of user input, so as not to hang the interface." (nrepl-send-sync-request request - (or connection (cider-current-repl 'any)) + (or connection (cider-current-repl 'any 'ensure)) abort-on-input)) (defun cider-nrepl-send-unhandled-request (request &optional connection) "Send REQUEST to the nREPL CONNECTION and ignore any responses. Immediately mark the REQUEST as done. Return the id of the sent message." - (let* ((conn (or connection (cider-current-repl 'any))) + (let* ((conn (or connection (cider-current-repl 'any 'ensure))) (id (nrepl-send-request request #'ignore conn))) (with-current-buffer conn (nrepl--mark-id-completed id)) @@ -181,7 +197,7 @@ If NS is non-nil, include it in the request. LINE and COLUMN, if non-nil, define the position of INPUT in its buffer. ADDITIONAL-PARAMS is a plist to be appended to the request message. CONNECTION is the connection buffer, defaults to (cider-current-repl)." - (let ((connection (or connection (cider-current-repl)))) + (let ((connection (or connection (cider-current-repl nil 'ensure)))) (nrepl-request:eval input (if cider-show-eval-spinner (cider-eval-spinner-handler connection callback) @@ -193,66 +209,73 @@ buffer, defaults to (cider-current-repl)." (defun cider-nrepl-sync-request:eval (input &optional connection ns) "Send the INPUT to the nREPL CONNECTION synchronously. If NS is non-nil, include it in the eval request." - (nrepl-sync-request:eval input (or connection (cider-current-repl)) ns)) + (nrepl-sync-request:eval input (or connection (cider-current-repl nil 'ensure)) ns)) + +(defcustom cider-print-fn 'pprint + "Sets the function to use for printing. -(defcustom cider-pprint-fn 'pprint - "Sets the function to use when pretty-printing evaluation results. +nil – to defer to nREPL to choose the printing function. This will use +the bound value of \\=`nrepl.middleware.print/*print-fn*\\=`, which +defaults to the equivalent of \\=`clojure.core/pr\\=`. -The value must be one of the following symbols: +`pr' – to use the equivalent of \\=`clojure.core/pr\\=`. -`pprint' - to use \\=`clojure.pprint/pprint\\=` +`pprint' – to use \\=`clojure.pprint/pprint\\=` (this is the default). -`fipp' - to use the Fast Idiomatic Pretty Printer, approximately 5-10x -faster than \\=`clojure.core/pprint\\=` (this is the default) +`fipp' – to use the Fast Idiomatic Pretty Printer, approximately 5-10x +faster than \\=`clojure.core/pprint\\=`. -`puget' - to use Puget, which provides canonical serialization of data on -top of fipp, but at a slight performance cost +`puget' – to use Puget, which provides canonical serialization of data on +top of fipp, but at a slight performance cost. -`zprint' - to use zprint, a fast and flexible alternative to the libraries +`zprint' – to use zprint, a fast and flexible alternative to the libraries mentioned above. -Alternatively, can be the namespace-qualified name of a Clojure function of -two arguments - an object to print and an options map. The options map will -have string keys. If the function -cannot be resolved, an exception will be thrown. - -The function should ideally have a two-arity variant that accepts the -object to print and a map of configuration options for the printer. See -`cider-pprint-options' for details. - -The function is also assumed to respect the contract of -\\=`clojure.pprint/pprint\\=` with respect to the bound values of -\\=`*print-length*\\=`, \\=`*print-level*\\=`, \\=`*print-meta*\\=`, and -\\=`clojure.pprint/*print-right-margin*\\=`. Those would normally serve as -fallback values when a map of print options is not supplied explicitly." - :type '(choice (const pprint) +Alternatively can be the namespace-qualified name of a Clojure var whose +function takes three arguments: the object to print, the +\\=`java.io.PrintWriter\\=` to print on, and a (possibly nil) map of +options. If the function cannot be resolved, will behave as if set to +nil." + :type '(choice (const nil) + (const pr) + (const pprint) (const fipp) (const puget) (const zprint) string) :group 'cider - :package-version '(cider . "0.11.0")) + :package-version '(cider . "0.21.0")) -(defcustom cider-pprint-options nil - "A list of options for the pretty-printer that will be converted to a map. -Note that map can only have string keys, so the printer functions should be -able to handle those. Here's an example for `pprint': +(defcustom cider-print-options nil + "A map of options that will be passed to `cider-print-fn'. +Here's an example for `pprint': - '(dict \"length\" 50 \"right-margin\" 70)" + '((\"length\" 50) (\"right-margin\" 70))" :type 'list :group 'cider - :package-version '(cider . "0.20.0")) + :package-version '(cider . "0.21.0")) + +(make-obsolete-variable 'cider-pprint-fn 'cider-print-fn "0.21") +(make-obsolete-variable 'cider-pprint-options 'cider-print-options "0.21") + +(defcustom cider-print-quota (* 1024 1024) + "A hard limit on the number of bytes to return from any printing operation. +Set to nil for no limit." + :type 'integer + :group 'cider + :package-version '(cider . "0.21.0")) -(defun cider--pprint-fn () - "Return the value to send in the pprint-fn slot of messages." - (pcase cider-pprint-fn +(defun cider--print-fn () + "Return the value to send in the nrepl.middleware.print/print slot." + (pcase cider-print-fn + (`pr "cider.nrepl.pprint/pr") (`pprint "cider.nrepl.pprint/pprint") - (`fipp "cider.nrepl.pprint/fipp-pprint") - (`puget "cider.nrepl.pprint/puget-pprint") - (`zprint "zprint.core/zprint-str") - (_ cider-pprint-fn))) + (`fipp "cider.nrepl.pprint/fipp-pprint") + (`puget "cider.nrepl.pprint/puget-pprint") + (`zprint "cider.nrepl.pprint/zprint-pprint") + (_ cider-print-fn))) -(defvar cider--pprint-options-mapping +(defvar cider--print-options-mapping '((right-margin ((fipp . width) (puget . width) (zprint . width))) (length @@ -261,8 +284,8 @@ able to handle those. Here's an example for `pprint': ((fipp . print-level) (puget . print-level) (zprint . max-depth)))) "A mapping of print option for the various supported print engines.") -(defun cider--pprint-option (name printer) - "Covert the generic NAME to its PRINTER specific variant. +(defun cider--print-option (name printer) + "Convert the generic NAME to its PRINTER specific variant. E.g. pprint's right-margin would become width for fipp. The function is useful when you want to generate dynamically print options. @@ -270,23 +293,47 @@ print options. NAME can be a string or a symbol. PRINTER has to be a symbol. The result will be a string." (let* ((name (cider-maybe-intern name)) - (result (cdr (assoc printer (cadr (assoc name cider--pprint-options-mapping)))))) + (result (cdr (assoc printer (cadr (assoc name cider--print-options-mapping)))))) (symbol-name (or result name)))) -(defun cider--nrepl-pprint-request-plist (right-margin &optional pprint-fn) - "Plist to be appended to an eval request to make it use pprint. -PPRINT-FN is the name of the Clojure function to use. -RIGHT-MARGIN specifies the maximum column-width of the pretty-printed -result, and is included in the request if non-nil." - (let* ((print-options (or cider-pprint-options (nrepl-dict)))) - (when right-margin - (setq print-options (nrepl-dict-put print-options (cider--pprint-option "right-margin" cider-pprint-fn) right-margin))) - (nconc `("printer" ,(or pprint-fn (cider--pprint-fn))) - (and (not (nrepl-dict-empty-p print-options)) `("print-options" ,print-options))))) - -(defun cider--nrepl-content-type-plist () - "Plist to be appended to an eval request to make it use content-types." - '("content-type" "true")) +(defun cider--nrepl-print-request-map (&optional right-margin) + "Map to merge into requests that require pretty-printing. +RIGHT-MARGIN specifies the maximum column-width of the printed result, and +is included in the request if non-nil." + (let* ((width-option (cider--print-option "right-margin" cider-print-fn)) + (print-options (thread-last + (map-merge 'hash-table + `((,width-option ,right-margin)) + cider-print-options) + (map-pairs) + (seq-mapcat #'identity) + (apply #'nrepl-dict)))) + (map-merge 'list + `(("nrepl.middleware.print/stream?" "1")) + (when cider-print-fn + `(("nrepl.middleware.print/print" ,(cider--print-fn)))) + (when cider-print-quota + `(("nrepl.middleware.print/quota" ,cider-print-quota))) + (unless (nrepl-dict-empty-p print-options) + `(("nrepl.middleware.print/options" ,print-options)))))) + +(defun cider--nrepl-pr-request-map () + "Map to merge into requests that do not require pretty printing." + (let ((print-options (thread-last cider-print-options + (map-pairs) + (seq-mapcat #'identity) + (apply #'nrepl-dict)))) + (map-merge 'list + `(("nrepl.middleware.print/print" "cider.nrepl.pprint/pr" + "nrepl.middleware.print/stream?" nil)) + (unless (nrepl-dict-empty-p print-options) + `(("nrepl.middleware.print/options" ,print-options))) + (when cider-print-quota + `(("nrepl.middleware.print/quota" ,cider-print-quota)))))) + +(defun cider--nrepl-content-type-map () + "Map to be merged into an eval request to make it use content-types." + '(("content-type" "true"))) (defun cider-tooling-eval (input callback &optional ns connection) "Send the request INPUT to CONNECTION and register the CALLBACK. @@ -297,7 +344,7 @@ clobber *1/2/3)." ;; namespace forms are always evaluated in the "user" namespace (nrepl-request:eval input callback - (or connection (cider-current-repl)) + (or connection (cider-current-repl nil 'ensure)) ns nil nil nil 'tooling)) (defun cider-sync-tooling-eval (input &optional ns connection) @@ -308,34 +355,15 @@ bindings of the primary eval nREPL session (e.g. this is not going to clobber *1/2/3)." ;; namespace forms are always evaluated in the "user" namespace (nrepl-sync-request:eval input - (or connection (cider-current-repl)) + (or connection (cider-current-repl nil 'ensure)) ns 'tooling)) -;; TODO: Add some unit tests and pretty those two functions up. -;; FIXME: Currently that's broken for group-id with multiple segments (e.g. org.clojure/clojure) -(defun cider-classpath-libs () - "Return a list of all libs on the classpath." - (let ((libs (seq-filter (lambda (cp-entry) - (string-suffix-p ".jar" cp-entry)) - (cider-sync-request:classpath))) - (dir-sep (if (string-equal system-type "windows-nt") "\\\\" "/"))) - (thread-last libs - (seq-map (lambda (s) (split-string s dir-sep))) - (seq-map #'reverse) - (seq-map (lambda (l) (reverse (seq-take l 4))))))) - -(defun cider-library-present-p (lib) - "Check whether LIB is present on the classpath. -The library is a string of the format \"group-id/artifact-id\"." - (let* ((lib (split-string lib "/")) - (group-id (car lib)) - (artifact-id (cadr lib))) - (seq-find (lambda (lib) - (let ((g (car lib)) - (a (cadr lib))) - (and (equal group-id g) (equal artifact-id a)))) - (cider-classpath-libs)))) +(defun cider-library-present-p (lib-ns) + "Check whether LIB-NS is present. +If a certain well-known ns in a library is present we assume that library +itself is present." + (nrepl-dict-get (cider-sync-tooling-eval (format "(require '%s)" lib-ns)) "value")) ;;; Interrupt evaluation @@ -348,7 +376,7 @@ The library is a string of the format \"group-id/artifact-id\"." "Interrupt any pending evaluations." (interactive) ;; FIXME: does this work correctly in cljc files? - (with-current-buffer (cider-current-repl) + (with-current-buffer (cider-current-repl nil 'ensure) (let ((pending-request-ids (cider-util--hash-keys nrepl-pending-requests))) (dolist (request-id pending-request-ids) (nrepl-request:interrupt @@ -379,12 +407,36 @@ contain a `candidates' key, it is returned as is." info) var-info))) +(defconst cider-info-form " +(do + (require 'clojure.java.io) + (require 'clojure.walk) + + (if-let [var (resolve '%s)] + (let [info (meta var)] + (-> info + (update :ns str) + (update :name str) + (update :file (comp str clojure.java.io/resource)) + (assoc :arglists-str (str (:arglists info))) + (clojure.walk/stringify-keys))))) +") + +(defun cider-fallback-eval:info (var) + "Obtain VAR metadata via a regular eval. +Used only when the info nREPL middleware is not available." + (let* ((response (cider-sync-tooling-eval (format cider-info-form var))) + (var-info (nrepl-dict-from-hash (parseedn-read-str (nrepl-dict-get response "value"))))) + var-info)) + (defun cider-var-info (var &optional all) "Return VAR's info as an alist with list cdrs. 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 (cider-sync-request:info var))) + (let ((var-info (if (cider-nrepl-op-supported-p "info") + (cider-sync-request:info var) + (cider-fallback-eval:info var)))) (if all var-info (cider--var-choice var-info))))) (defun cider-member-info (class member) @@ -439,7 +491,7 @@ Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P." ,@(when docs-p '("docs?" "t")) ,@(when privates-p '("privates?" "t")) ,@(when case-sensitive-p '("case-sensitive?" "t")) - "filter-regexps" ,cider-filtered-namespaces-regexps)))) + "exclude-regexps" ,cider-filtered-namespaces-regexps)))) (if (member "apropos-regexp-error" (nrepl-dict-get response "status")) (user-error "Invalid regexp: %s" (nrepl-dict-get response "error-msg")) (nrepl-dict-get response "apropos-matches")))) @@ -451,13 +503,24 @@ Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P." (cider-nrepl-send-sync-request) (nrepl-dict-get "classpath"))) +(defun cider-fallback-eval:classpath () + "Return a list of classpath entries using eval." + (read (nrepl-dict-get (cider-sync-tooling-eval "(seq (.split (System/getProperty \"java.class.path\") \":\"))") "value"))) + +(defun cider-classpath-entries () + "Return a list of classpath entries." + (if (cider-nrepl-op-supported-p "classpath") + (cider-sync-request:classpath) + (cider-fallback-eval:classpath))) + (defun cider-sync-request:complete (str context) "Return a list of completions for STR using nREPL's \"complete\" op. CONTEXT represents a completion context for compliment." (when-let* ((dict (thread-first `("op" "complete" "ns" ,(cider-current-ns) "symbol" ,str - "context" ,context) + "context" ,context + ,@(when cider-enhanced-cljs-completion-p '("enhanced-cljs-completion?" "t"))) (cider-nrepl-send-sync-request (cider-current-repl) 'abort-on-input)))) (nrepl-dict-get dict "completions"))) @@ -509,14 +572,16 @@ Optional argument FILTER-REGEX filters specs. By default, all specs are returned." (setq filter-regex (or filter-regex "")) (thread-first `("op" "spec-list" - "filter-regex" ,filter-regex) + "filter-regex" ,filter-regex + "ns" ,(cider-current-ns)) (cider-nrepl-send-sync-request) (nrepl-dict-get "spec-list"))) (defun cider-sync-request:spec-form (spec) "Get SPEC's form from registry." (thread-first `("op" "spec-form" - "spec-name" ,spec) + "spec-name" ,spec + "ns" ,(cider-current-ns)) (cider-nrepl-send-sync-request) (nrepl-dict-get "spec-form"))) @@ -530,7 +595,7 @@ returned." (defun cider-sync-request:ns-list () "Get a list of the available namespaces." (thread-first `("op" "ns-list" - "filter-regexps" ,cider-filtered-namespaces-regexps) + "exclude-regexps" ,cider-filtered-namespaces-regexps) (cider-nrepl-send-sync-request) (nrepl-dict-get "ns-list"))) @@ -576,6 +641,24 @@ The result entries are relative to the classpath." (nrepl-dict-get "resources-list")))) (seq-map (lambda (resource) (nrepl-dict-get resource "relpath")) resources))) +(defun cider-sync-request:fn-refs (ns sym) + "Return a list of functions that reference the function identified by NS and SYM." + (cider-ensure-op-supported "fn-refs") + (thread-first `("op" "fn-refs" + "ns" ,ns + "sym" ,sym) + (cider-nrepl-send-sync-request) + (nrepl-dict-get "fn-refs"))) + +(defun cider-sync-request:fn-deps (ns sym) + "Return a list of function deps for the function identified by NS and SYM." + (cider-ensure-op-supported "fn-deps") + (thread-first `("op" "fn-deps" + "ns" ,ns + "sym" ,sym) + (cider-nrepl-send-sync-request) + (nrepl-dict-get "fn-deps"))) + (defun cider-sync-request:format-code (code) "Perform nREPL \"format-code\" op with CODE." (thread-first `("op" "format-code" @@ -585,10 +668,13 @@ The result entries are relative to the classpath." (defun cider-sync-request:format-edn (edn right-margin) "Perform \"format-edn\" op with EDN and RIGHT-MARGIN." - (let* ((response (thread-first `("op" "format-edn" - "edn" ,edn) - (append (cider--nrepl-pprint-request-plist right-margin)) - (cider-nrepl-send-sync-request))) + (let* ((request (thread-last + (map-merge 'list + `(("op" "format-edn") + ("edn" ,edn)) + (cider--nrepl-print-request-map right-margin)) + (seq-mapcat #'identity))) + (response (cider-nrepl-send-sync-request request)) (err (nrepl-dict-get response "err"))) (when err ;; err will be a stacktrace with a first line that looks like: diff --git a/elpa/cider-20191027.1704/cider-clojuredocs.el b/elpa/cider-20191027.1704/cider-clojuredocs.el new file mode 100644 index 00000000..9ed23578 --- /dev/null +++ b/elpa/cider-20191027.1704/cider-clojuredocs.el @@ -0,0 +1,159 @@ +;;; cider-clojuredocs.el --- ClojureDocs integration -*- lexical-binding: t -*- + +;; Copyright © 2014-2019 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: + +;; A few commands for ClojureDocs documentation lookup. + +;;; Code: + +(require 'cider-client) +(require 'cider-common) +(require 'subr-x) +(require 'cider-compat) +(require 'cider-popup) + +(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." + (thread-first `("op" "clojuredocs-lookup" + "ns" ,ns + "sym" ,sym) + (cider-nrepl-send-sync-request) + (nrepl-dict-get "clojuredocs"))) + +(defun cider-sync-request:clojuredocs-refresh () + "Refresh the ClojureDocs cache." + (thread-first '("op" "clojuredocs-refresh-cache") + (cider-nrepl-send-sync-request) + (nrepl-dict-get "status"))) + +(defun cider-clojuredocs-replace-special (name) + "Convert the dashes in NAME to a ClojureDocs friendly format. +We need to handle \"?\", \".\", \"..\" and \"/\"." + (thread-last name + (replace-regexp-in-string "\\?" "_q") + (replace-regexp-in-string "\\(\\.+\\)" "_\\1") + (replace-regexp-in-string "/" "fs"))) + +(defun cider-clojuredocs-url (name ns) + "Generate a ClojureDocs url from NAME and NS." + (let ((base-url cider-clojuredocs-url)) + (when (and name ns) + (concat base-url ns "/" (cider-clojuredocs-replace-special name))))) + +(defun cider-clojuredocs-web-lookup (sym) + "Open the ClojureDocs documentation for SYM in a web browser." + (if-let* ((var-info (cider-var-info sym))) + (let ((name (nrepl-dict-get var-info "name")) + (ns (nrepl-dict-get var-info "ns"))) + (browse-url (cider-clojuredocs-url name ns))) + (error "Symbol %s not resolved" sym))) + +;;;###autoload +(defun cider-clojuredocs-web (&optional arg) + "Open ClojureDocs documentation in the default web browser. + +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") + (funcall (cider-prompt-for-symbol-function arg) + "ClojureDocs doc for" + #'cider-clojuredocs-web-lookup)) + +;;;###autoload +(defun cider-clojuredocs-refresh-cache () + "Refresh the ClojureDocs cache." + (interactive) + (let ((result (cider-sync-request:clojuredocs-refresh))) + (if (member "ok" result) + (message "ClojureDocs cache refreshed successfully") + (message "An error occurred while trying to refresh the ClojureDocs cache")))) + +(defun cider-create-clojuredocs-buffer (content) + "Create a new ClojureDocs buffer with CONTENT." + (with-current-buffer (cider-popup-buffer cider-clojuredocs-buffer t) + (read-only-mode -1) + (insert content) + (cider-popup-buffer-mode 1) + (view-mode 1) + (goto-char (point-min)) + (current-buffer))) + +(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 (format "* %s\n" 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")) + (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))))) + +;;;###autoload +(defun cider-clojuredocs (&optional arg) + "Open ClojureDocs documentation in a popup buffer. + +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) + (user-error "`cider-clojuredocs' doesn't support ClojureScript")) + (funcall (cider-prompt-for-symbol-function arg) + "ClojureDocs doc for" + #'cider-clojuredocs-lookup)) + +(provide 'cider-clojuredocs) + +;;; cider-clojuredocs.el ends here diff --git a/elpa/cider-20190121.1852/cider-common.el b/elpa/cider-20191027.1704/cider-common.el similarity index 91% rename from elpa/cider-20190121.1852/cider-common.el rename to elpa/cider-20191027.1704/cider-common.el index e17ac7a8..5832c599 100644 --- a/elpa/cider-20190121.1852/cider-common.el +++ b/elpa/cider-20191027.1704/cider-common.el @@ -138,7 +138,7 @@ If OTHER-WINDOW is non-nil don't reuse current window." (with-no-warnings (ring-insert find-tag-marker-ring (point-marker))) (if other-window - (pop-to-buffer buffer) + (pop-to-buffer buffer 'display-buffer-pop-up-window) ;; like switch-to-buffer, but reuse existing window if BUFFER is visible (pop-to-buffer buffer '((display-buffer-reuse-window display-buffer-same-window)))) (with-current-buffer buffer @@ -255,6 +255,29 @@ otherwise, nil." localname) name)) +(defcustom cider-path-translations nil + "Alist of path prefixes to path prefixes. +Useful to intercept the location of a path in a docker image and translate +to the oringal location. If your project is located at \"~/projects/foo\" +and the src directory of foo is mounted at \"/src\" in the docker +container, the alist would be `((\"/src\" \"~/projects/foo/src\"))" + :type '(alist :key-type string :value-type string) + :group 'cider + :package-version '(cider . "0.23.0")) + +(defun cider--translate-path (path) + "Attempt to translate the PATH. +Looks at `cider-path-translations' for (docker . host) alist of path +prefixes." + (seq-some (lambda (translation) + (let ((prefix (file-name-as-directory (expand-file-name (car translation))))) + (when (string-prefix-p prefix path) + (replace-regexp-in-string (format "^%s" (regexp-quote prefix)) + (file-name-as-directory + (expand-file-name (cdr translation))) + path)))) + cider-path-translations)) + (defvar cider-from-nrepl-filename-function (with-no-warnings (if (eq system-type 'cygwin) @@ -271,14 +294,16 @@ otherwise, nil." "Return PATH's local or tramp path using `cider-prefer-local-resources'. If no local or remote file exists, return nil." (let* ((local-path (funcall cider-from-nrepl-filename-function path)) - (tramp-path (and local-path (cider--client-tramp-filename local-path)))) + (tramp-path (and local-path (cider--client-tramp-filename local-path))) + (translated-path (cider--translate-path local-path))) (cond ((equal local-path "") "") ((and cider-prefer-local-resources (file-exists-p local-path)) local-path) ((and tramp-path (file-exists-p tramp-path)) tramp-path) ((and local-path (file-exists-p local-path)) - local-path)))) + local-path) + ((and translated-path (file-exists-p translated-path)) translated-path)))) (declare-function archive-extract "arc-mode") (declare-function archive-zip-extract "arc-mode") diff --git a/elpa/cider-20190121.1852/cider-compat.el b/elpa/cider-20191027.1704/cider-compat.el similarity index 100% rename from elpa/cider-20190121.1852/cider-compat.el rename to elpa/cider-20191027.1704/cider-compat.el diff --git a/elpa/cider-20190121.1852/cider-completion.el b/elpa/cider-20191027.1704/cider-completion.el similarity index 96% rename from elpa/cider-20190121.1852/cider-completion.el rename to elpa/cider-20191027.1704/cider-completion.el index d4be0a73..bf8a6d01 100644 --- a/elpa/cider-20190121.1852/cider-completion.el +++ b/elpa/cider-20191027.1704/cider-completion.el @@ -132,7 +132,11 @@ form, with symbol at point replaced by __prefix__." ;; `ending-of-defun' work incorrectly in the REPL ;; buffer, so context extraction fails there. (derived-mode-p 'clojure-mode)) - (or (cider-completion-get-context-at-point) + ;; 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) diff --git a/elpa/cider-20190121.1852/cider-connection.el b/elpa/cider-20191027.1704/cider-connection.el similarity index 91% rename from elpa/cider-20190121.1852/cider-connection.el rename to elpa/cider-20191027.1704/cider-connection.el index a73ccc93..c72d6210 100644 --- a/elpa/cider-20190121.1852/cider-connection.el +++ b/elpa/cider-20191027.1704/cider-connection.el @@ -66,7 +66,7 @@ available) and the matching REPL buffer." :safe #'booleanp :package-version '(cider . "0.9.0")) -(defconst cider-required-nrepl-version "0.4.4" +(defconst cider-required-nrepl-version "0.6.0" "The minimum nREPL version that's known to work properly with CIDER.") @@ -84,6 +84,10 @@ PARAMS is a plist containing :host, :port, :server and other parameters for (lambda (_) (cider-repl-create params))))) +(defun cider-sessions () + "Return a list of all active CIDER sessions." + (sesman-sessions 'CIDER)) + (defun cider-connected-p () "Return t if CIDER is currently connected, nil otherwise." (process-live-p (get-buffer-process (cider-current-repl)))) @@ -187,11 +191,11 @@ FORMAT is a format string to compile with ARGS and display on the REPL." "Check whether we're using a compatible nREPL version." (if-let* ((nrepl-version (cider--nrepl-version))) (when (version< nrepl-version cider-required-nrepl-version) - (cider-emit-manual-warning "troubleshooting/#warning-saying-you-have-to-use-nrepl-0212" + (cider-emit-manual-warning "troubleshooting.html#_warning_saying_you_have_to_use_newer_nrepl" "CIDER requires nREPL %s (or newer) to work properly" cider-required-nrepl-version)) - (cider-emit-manual-warning "troubleshooting/#warning-saying-you-have-to-use-nrepl-0212" - "Can't determine nREPL's version.\nPlease, update nREPL to %s." + (cider-emit-manual-warning "troubleshooting.html#_warning_saying_you_have_to_use_newer_nrepl" + "Can't determine nREPL's version.\nPlease, update nREPL to %s (or newer)." cider-required-nrepl-version))) (defvar cider-minimum-clojure-version) @@ -199,13 +203,34 @@ FORMAT is a format string to compile with ARGS and display on the REPL." "Ensure that we are meeting the minimum supported version of Clojure." (if-let* ((clojure-version (cider--clojure-version))) (when (version< clojure-version cider-minimum-clojure-version) - (cider-emit-manual-warning "installation/#prerequisites" + (cider-emit-manual-warning "installation.html#_prerequisites" "Clojure version (%s) is not supported (minimum %s). CIDER will not work." clojure-version cider-minimum-clojure-version)) - (cider-emit-manual-warning "installation/#prerequisites" + (cider-emit-manual-warning "installation.html#_prerequisites" "Can't determine Clojure's version. CIDER requires Clojure %s (or newer)." cider-minimum-clojure-version))) +(defun cider--strip-version-patch (v) + "Strips everything but major.minor from the version, returning a version list. +V is the version string to strip the patch from." + (seq-take (version-to-list v) 2)) + +(defun cider--compatible-middleware-version-p (required-ver ver) + "Checks that the available middleware version is compatible with the required. +We look only at the major and minor components. When the major +version is 0, only check that the minor versions match. When the major version +is > 0, first check that the major version matches, then that the minor +version is >= the required minor version. +VER the 'installed' version, +REQUIRED-VER the version required by cider." + (let ((ver* (cider--strip-version-patch ver)) + (required-ver* (cider--strip-version-patch required-ver))) + (cond ((= 0 (car required-ver*)) (= (cadr required-ver*) + (cadr ver*))) + (t (and (= (car required-ver*) + (car ver*)) + (version-list-<= required-ver* ver*)))))) + (defvar cider-required-middleware-version) (defun cider--check-middleware-compatibility () "CIDER frontend/backend compatibility check. @@ -216,11 +241,11 @@ message in the REPL area." (middleware-version (nrepl-dict-get version-dict "version-string"))) (cond ((null middleware-version) - (cider-emit-manual-warning "troubleshooting/#cider-complains-of-the-cider-nrepl-version" - "CIDER requires cider-nrepl to be fully functional. Many things will not work without it!")) - ((version< middleware-version cider-required-middleware-version) - (cider-emit-manual-warning "troubleshooting/#cider-complains-of-the-cider-nrepl-version" - "CIDER %s requires cider-nrepl %s+, but you're currently using cider-nrepl %s. Things will break!" + (cider-emit-manual-warning "troubleshooting.html#_cider_complains_of_the_cider_nrepl_version" + "CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!")) + ((not (cider--compatible-middleware-version-p cider-required-middleware-version middleware-version)) + (cider-emit-manual-warning "troubleshooting.html#_cider_complains_of_the_cider_nrepl_version" + "CIDER %s requires cider-nrepl %s, but you're currently using cider-nrepl %s. The version mismatch might break some functionality!" cider-version cider-required-middleware-version middleware-version))))) (declare-function cider-interactive-eval-handler "cider-eval") @@ -248,8 +273,8 @@ See command `cider-mode'." (cider-mode -1)))) (defun cider-possibly-disable-on-existing-clojure-buffers () - "If not connected, disable command `cider-mode' on existing Clojure buffers." - (unless (cider-connected-p) + "Disable command `cider-mode' on existing Clojure buffers when all CIDER sessions are closed." + (unless (cider-sessions) (cider-disable-on-existing-clojure-buffers))) (declare-function cider--debug-init-connection "cider-debug") @@ -264,23 +289,25 @@ buffer." (let ((cider-enlighten-mode nil)) ;; after initialization, set mode-line and buffer name. (cider-set-repl-type cider-repl-type) - (cider-repl-init (current-buffer)) - (cider--check-required-nrepl-version) - (cider--check-clojure-version-supported) - (cider--check-middleware-compatibility) - (when cider-redirect-server-output-to-repl - (cider--subscribe-repl-to-server-out)) - (when cider-auto-mode - (cider-enable-on-existing-clojure-buffers)) - ;; Middleware on cider-nrepl's side is deferred until first usage, but - ;; loading middleware concurrently can lead to occasional "require" issues - ;; (likely a Clojure bug). Thus, we load the heavy debug middleware towards - ;; the end, allowing for the faster "server-out" middleware to load - ;; first. - (cider--debug-init-connection) - (when cider-repl-init-function - (funcall cider-repl-init-function)) - (run-hooks 'cider-connected-hook))) + (cider-repl-init + (current-buffer) + (lambda () + (cider--check-required-nrepl-version) + (cider--check-clojure-version-supported) + (cider--check-middleware-compatibility) + (when cider-redirect-server-output-to-repl + (cider--subscribe-repl-to-server-out)) + (when cider-auto-mode + (cider-enable-on-existing-clojure-buffers)) + ;; Middleware on cider-nrepl's side is deferred until first usage, but + ;; loading middleware concurrently can lead to occasional "require" issues + ;; (likely a Clojure bug). Thus, we load the heavy debug middleware towards + ;; the end, allowing for the faster "server-out" middleware to load + ;; first. + (cider--debug-init-connection) + (when cider-repl-init-function + (funcall cider-repl-init-function)) + (run-hooks 'cider-connected-hook))))) (defun cider--disconnected-handler () "Cleanup after nREPL connection has been lost or closed. @@ -343,8 +370,8 @@ REPL defaults to the current REPL." (sesman-browser-get 'object) (cider-current-repl nil 'ensure)))) (cider--close-connection repl)) - ;; if there are no more connections we can kill all ancillary buffers - (unless (cider-connected-p) + ;; if there are no more sessions we can kill all ancillary buffers + (unless (cider-sessions) (cider-close-ancillary-buffers)) ;; need this to refresh sesman browser (run-hooks 'sesman-post-command-hook)) @@ -429,7 +456,7 @@ REPL defaults to the current REPL." (when (process-live-p proc) (let* ((classpath (or (process-get proc :cached-classpath) (let ((cp (with-current-buffer repl - (cider-sync-request:classpath)))) + (cider-classpath-entries)))) (process-put proc :cached-classpath cp) cp))) (classpath-roots (or (process-get proc :cached-classpath-roots) @@ -473,8 +500,8 @@ Fallback on `cider' command." (cl-defmethod sesman-quit-session ((_system (eql CIDER)) session) (mapc #'cider--close-connection (cdr session)) - ;; if there are no more connections we can kill all ancillary buffers - (unless (cider-connected-p) + ;; if there are no more session we can kill all ancillary buffers + (unless (cider-sessions) (cider-close-ancillary-buffers))) (cl-defmethod sesman-restart-session ((_system (eql CIDER)) session) diff --git a/elpa/cider-20190121.1852/cider-debug.el b/elpa/cider-20191027.1704/cider-debug.el similarity index 90% rename from elpa/cider-20190121.1852/cider-debug.el rename to elpa/cider-20191027.1704/cider-debug.el index ba517482..717734b3 100644 --- a/elpa/cider-20190121.1852/cider-debug.el +++ b/elpa/cider-20191027.1704/cider-debug.el @@ -25,18 +25,21 @@ ;;; Code: -(require 'nrepl-dict) -(require 'nrepl-client) ; `nrepl--mark-id-completed' -(require 'cider-eval) +(require 'map) +(require 'seq) +(require 'subr-x) + +(require 'spinner) + +(require 'cider-browse-ns) (require 'cider-client) -(require 'cider-util) +(require 'cider-eval) (require 'cider-inspector) -(require 'cider-browse-ns) +(require 'cider-util) (require 'cider-common) -(require 'subr-x) (require 'cider-compat) -(require 'seq) -(require 'spinner) +(require 'nrepl-client) ; `nrepl--mark-id-completed' +(require 'nrepl-dict) ;;; Customization @@ -103,13 +106,7 @@ configure `cider-debug-prompt' instead." (make-obsolete 'cider-debug-print-length 'cider-debug-print-options "0.20") (make-obsolete 'cider-debug-print-level 'cider-debug-print-options "0.20") - -(defcustom cider-debug-print-options '(dict "length" 10 "level" 10) - "The print options for values displayed by the debugger. -This variable must be set before starting the repl connection." - :type 'listp - :group 'cider-stacktrace - :package-version '(cider . "0.20.0")) +(make-obsolete-variable 'cider-debug-print-options 'cider-print-options "0.21") ;;; Implementation @@ -156,9 +153,11 @@ This variable must be set before starting the repl connection." (defun cider--debug-init-connection () "Initialize a connection with the cider.debug middleware." (cider-nrepl-send-request - (nconc '("op" "init-debugger") - (when cider-debug-print-options - `("print-options" ,cider-debug-print-options))) + (thread-last + (map-merge 'list + '(("op" "init-debugger")) + (cider--nrepl-print-request-map fill-column)) + (seq-mapcat #'identity)) #'cider--debug-response-handler)) @@ -186,10 +185,6 @@ This variable must be set before starting the repl connection." ;;; Minor mode -(defvar-local cider--debug-mode-commands-dict nil - "An nrepl-dict from keys to debug commands. -Autogenerated by `cider--turn-on-debug-mode'.") - (defvar-local cider--debug-mode-response nil "Response that triggered current debug session. Set by `cider--turn-on-debug-mode'.") @@ -201,6 +196,39 @@ Can be toggled at any time with `\\[cider-debug-toggle-locals]'." :group 'cider-debug :package-version '(cider . "0.10.0")) +(defcustom cider-debug-prompt-commands + '((?c "continue" "continue") + (?C "continue-all" nil) + (?n "next" "next") + (?i "in" "in") + (?o "out" "out") + (?h "here" "here") + (?e "eval" "eval") + (?p "inspect" "inspect") + (?P "inspect-prompt" nil) + (?l "locals" "locals") + (?j "inject" "inject") + (?s "stacktrace" "stacktrace") + (?t "trace" "trace") + (?q "quit" "quit")) + "A list of debugger command specs. +They are in the format (KEY COMMAND-NAME DISPLAY-NAME?), where: + +* KEY is a character which is mapped to the command +* COMMAND-NAME is a valid debug command to be passed to the cider-nrepl +middleware +* DISPLAY-NAME is the string displayed in the debugger overlay + +If DISPLAY-NAME is nil, that command is hidden from the overlay but still +callable. The rest of the commands are displayed in their order of appearance +on this list." + :type '(alist :key-type character + :value-type (list + (string :tag "command name") + (choice (string :tag "display name") nil))) + :group 'cider-debug + :package-version '(cider . "0.24.0")) + (defun cider--debug-format-locals-list (locals) "Return a string description of list LOCALS. Each element of LOCALS should be a list of at least two elements." @@ -215,24 +243,35 @@ Each element of LOCALS should be a list of at least two elements." locals "")) "")) -(defun cider--debug-prompt (command-dict) - "Return prompt to display for COMMAND-DICT." +(defun cider--debug-propertize-prompt-commands () + "In-place formatting of the command display names for the cider-debug-prompt overlay." + (mapc (lambda (spec) + (cl-destructuring-bind (char cmd disp-name) spec + (when-let* ((pos (cl-position char disp-name))) + (put-text-property pos (1+ pos) 'face 'cider-debug-prompt-face disp-name)))) + cider-debug-prompt-commands)) + +(defun cider--debug-prompt (commands) + "Return prompt to display for COMMANDS." ;; Force `default' face, otherwise the overlay "inherits" the face of the text ;; after it. (format (propertize "%s\n" 'face 'default) - (string-join - (nrepl-dict-map (lambda (char cmd) - (when-let* ((pos (cl-search char cmd))) - (put-text-property pos (1+ pos) 'face 'cider-debug-prompt-face cmd)) - cmd) - command-dict) - " "))) + (cl-reduce + (lambda (prompt spec) + (cl-destructuring-bind (char cmd disp) spec + (if (and disp (cl-find cmd commands :test 'string=)) + (concat prompt " " disp) + prompt))) + cider-debug-prompt-commands + :initial-value ""))) (defvar-local cider--debug-prompt-overlay nil) (defun cider--debug-mode-redisplay () "Display the input prompt to the user." (nrepl-dbind-response cider--debug-mode-response (debug-value input-type locals) + ;; input-type is an unsorted collection of command names, + ;; as sent by `cider.nrepl.middleware.debug/read-debug-input` (when (or (eq cider-debug-prompt t) (eq cider-debug-prompt 'overlay)) (if (overlayp cider--debug-prompt-overlay) @@ -311,14 +350,16 @@ In order to work properly, this mode must be activated by (setq cider-interactive-eval-override (apply-partially #'cider--debug-lexical-eval (nrepl-dict-get cider--debug-mode-response "key"))) - ;; Set the keymap. - (nrepl-dict-map (lambda (char _cmd) - (unless (string= char "h") ; `here' needs a special command. - (define-key cider--debug-mode-map char #'cider-debug-mode-send-reply)) - (when (string= char "o") - (define-key cider--debug-mode-map (upcase char) #'cider-debug-mode-send-reply))) - input-type) - (setq cider--debug-mode-commands-dict input-type) + ;; Map over the key->command alist and set the keymap + (mapc + (lambda (p) + (let ((char (car p)) (cmd (cdr p))) + (unless (= char ?h) ; `here' needs a special command. + (define-key cider--debug-mode-map (string char) #'cider-debug-mode-send-reply)) + (when (= char ?o) + (define-key cider--debug-mode-map (string (upcase ?o)) #'cider-debug-mode-send-reply)))) + cider-debug-prompt-commands) + (cider--debug-propertize-prompt-commands) ;; Show the prompt. (cider--debug-mode-redisplay) ;; If a sync request is ongoing, the user can't act normally to @@ -330,7 +371,6 @@ In order to work properly, this mode must be activated by (user-error (substitute-command-keys "Don't call this mode manually, use `\\[universal-argument] \\[cider-eval-defun-at-point]' instead")) (error "Attempt to activate `cider--debug-mode' without setting `cider--debug-mode-response' first"))) (setq cider-interactive-eval-override nil) - (setq cider--debug-mode-commands-dict nil) (setq cider--debug-mode-response nil) ;; We wait a moment before clearing overlays and the read-onlyness, so that ;; cider-nrepl has a chance to send the next message, and so that the user @@ -370,13 +410,14 @@ In order to work properly, this mode must be activated by `("CIDER Debugger" ["Next step" (cider-debug-mode-send-reply ":next") :keys "n"] ["Continue" (cider-debug-mode-send-reply ":continue") :keys "c"] - ["Continue non-stop" (cider-debug-mode-send-reply ":Continue") :keys "C"] + ["Continue non-stop" (cider-debug-mode-send-reply ":continue-all") :keys "C"] ["Move out of sexp" (cider-debug-mode-send-reply ":out") :keys "o"] ["Quit" (cider-debug-mode-send-reply ":quit") :keys "q"] "--" ["Evaluate in current scope" (cider-debug-mode-send-reply ":eval") :keys "e"] ["Inject value" (cider-debug-mode-send-reply ":inject") :keys "i"] - ["Inspect value" (cider-debug-mode-send-reply ":inspect")] + ["Inspect current value" (cider-debug-mode-send-reply ":inspect") :keys "p"] + ["Inspect expression" (cider-debug-mode-send-reply ":inspect-prompt") :keys "P"] ["Inspect local variables" (cider-debug-mode-send-reply ":locals") :keys "l"] "--" ("Configure keys prompt" @@ -403,8 +444,7 @@ message." (if (symbolp last-command-event) (symbol-name last-command-event) (ignore-errors - (concat ":" (nrepl-dict-get cider--debug-mode-commands-dict - (string last-command-event))))) + (concat ":" (cadr (assoc last-command-event cider-debug-prompt-commands))))) nil (cider--uppercase-command-p))) (when (and (string-prefix-p ":" command) force) @@ -631,6 +671,7 @@ needed. It is expected to contain at least \"key\", \"input-type\", and (setq cider--debug-mode-response response) (cider--debug-mode 1))) (when inspect + (setq cider-inspector--current-repl (cider-current-repl)) (cider-inspector--render-value inspect))) ;; If something goes wrong, we send a "quit" or the session hangs. (error (cider-debug-mode-send-reply ":quit" key) @@ -721,7 +762,7 @@ The boolean value of FORCE will be sent in the reply." (forward-sexp 1) (> here (point)))) (user-error "Point is outside the sexp being debugged")) - ;; Move forward untill start of sexp. + ;; Move forward until start of sexp. (comment-normalize-vars) (comment-forward (point-max)) ;; Find the coordinate and send it. diff --git a/elpa/cider-20190121.1852/cider-doc.el b/elpa/cider-20191027.1704/cider-doc.el similarity index 93% rename from elpa/cider-20190121.1852/cider-doc.el rename to elpa/cider-20191027.1704/cider-doc.el index df3e97d1..0806dff8 100644 --- a/elpa/cider-20190121.1852/cider-doc.el +++ b/elpa/cider-20191027.1704/cider-doc.el @@ -31,7 +31,7 @@ (require 'cider-util) (require 'cider-popup) (require 'cider-client) -(require 'cider-grimoire) +(require 'cider-clojuredocs) (require 'nrepl-dict) (require 'org-table) (require 'button) @@ -70,10 +70,10 @@ (define-key cider-doc-map (kbd "C-e") #'cider-apropos-documentation-select) (define-key cider-doc-map (kbd "d") #'cider-doc) (define-key cider-doc-map (kbd "C-d") #'cider-doc) - (define-key cider-doc-map (kbd "r") #'cider-grimoire) - (define-key cider-doc-map (kbd "C-r") #'cider-grimoire) - (define-key cider-doc-map (kbd "w") #'cider-grimoire-web) - (define-key cider-doc-map (kbd "C-w") #'cider-grimoire-web) + (define-key cider-doc-map (kbd "c") #'cider-clojuredocs) + (define-key cider-doc-map (kbd "C-c") #'cider-clojuredocs) + (define-key cider-doc-map (kbd "w") #'cider-clojuredocs-web) + (define-key cider-doc-map (kbd "C-w") #'cider-clojuredocs-web) (define-key cider-doc-map (kbd "j") #'cider-javadoc) (define-key cider-doc-map (kbd "C-j") #'cider-javadoc) cider-doc-map) @@ -83,8 +83,11 @@ '("Documentation" ["CiderDoc" cider-doc] ["JavaDoc in browser" cider-javadoc] - ["Grimoire" cider-grimoire] - ["Grimoire in browser" cider-grimoire-web] + "--" + ["Clojuredocs" cider-clojuredocs] + ["Clojuredocs in browser" cider-clojuredocs-web] + ["Refresh ClojureDocs cache" cider-clojuredocs-refresh-cache] + "--" ["Search symbols" cider-apropos] ["Search symbols & select" cider-apropos-select] ["Search documentation" cider-apropos-documentation] @@ -156,8 +159,8 @@ (defvar cider-docview-mode-map (let ((map (make-sparse-keymap))) (define-key map "q" #'cider-popup-buffer-quit-function) - (define-key map "g" #'cider-docview-grimoire) - (define-key map "G" #'cider-docview-grimoire-web) + (define-key map "g" #'cider-docview-clojuredocs) + (define-key map "G" #'cider-docview-clojuredocs-web) (define-key map "j" #'cider-docview-javadoc) (define-key map "s" #'cider-docview-source) (define-key map (kbd "") #'backward-button) @@ -165,8 +168,8 @@ (easy-menu-define cider-docview-mode-menu map "Menu for CIDER's doc mode" `("CiderDoc" - ["Look up in Grimoire" cider-docview-grimoire] - ["Look up in Grimoire (browser)" cider-docview-grimoire-web] + ["Look up in Clojuredocs" cider-docview-clojuredocs] + ["Look up in Clojuredocs (browser)" cider-docview-clojuredocs-web] ["JavaDoc in browser" cider-docview-javadoc] ["Jump to source" cider-docview-source] "--" @@ -242,23 +245,23 @@ opposite of what that option dictates." (defvar cider-buffer-ns) -(declare-function cider-grimoire-lookup "cider-grimoire") +(declare-function cider-clojuredocs-lookup "cider-clojuredocs") -(defun cider-docview-grimoire () - "Return the grimoire documentation for `cider-docview-symbol'." +(defun cider-docview-clojuredocs () + "Return the clojuredocs documentation for `cider-docview-symbol'." (interactive) (if cider-buffer-ns - (cider-grimoire-lookup cider-docview-symbol) - (error "%s cannot be looked up on Grimoire" cider-docview-symbol))) + (cider-clojuredocs-lookup cider-docview-symbol) + (error "%s cannot be looked up on ClojureDocs" cider-docview-symbol))) -(declare-function cider-grimoire-web-lookup "cider-grimoire") +(declare-function cider-clojuredocs-web-lookup "cider-clojuredocs") -(defun cider-docview-grimoire-web () - "Open the grimoire documentation for `cider-docview-symbol' in a web browser." +(defun cider-docview-clojuredocs-web () + "Open the clojuredocs documentation for `cider-docview-symbol' in a web browser." (interactive) (if cider-buffer-ns - (cider-grimoire-web-lookup cider-docview-symbol) - (error "%s cannot be looked up on Grimoire" cider-docview-symbol))) + (cider-clojuredocs-web-lookup cider-docview-symbol) + (error "%s cannot be looked up on ClojureDocs" cider-docview-symbol))) (defconst cider-doc-buffer "*cider-doc*") diff --git a/elpa/cider-20190121.1852/cider-eldoc.el b/elpa/cider-20191027.1704/cider-eldoc.el similarity index 100% rename from elpa/cider-20190121.1852/cider-eldoc.el rename to elpa/cider-20191027.1704/cider-eldoc.el diff --git a/elpa/cider-20190121.1852/cider-eval.el b/elpa/cider-20191027.1704/cider-eval.el similarity index 87% rename from elpa/cider-20190121.1852/cider-eval.el rename to elpa/cider-20191027.1704/cider-eval.el index 58b2a572..5f61993a 100644 --- a/elpa/cider-20190121.1852/cider-eval.el +++ b/elpa/cider-20191027.1704/cider-eval.el @@ -40,20 +40,23 @@ ;;; Code: -(require 'cider-client) -(require 'cider-repl) -(require 'cider-popup) -(require 'cider-common) -(require 'cider-util) -(require 'cider-stacktrace) -(require 'cider-overlays) -(require 'cider-compat) - -(require 'clojure-mode) (require 'ansi-color) (require 'cl-lib) -(require 'subr-x) (require 'compile) +(require 'map) +(require 'seq) +(require 'subr-x) + +(require 'clojure-mode) + +(require 'cider-client) +(require 'cider-common) +(require 'cider-compat) +(require 'cider-overlays) +(require 'cider-popup) +(require 'cider-repl) +(require 'cider-stacktrace) +(require 'cider-util) (defconst cider-read-eval-buffer "*cider-read-eval*") (defconst cider-result-buffer "*cider-result*") @@ -109,6 +112,11 @@ If t, save the file without confirmation." :group 'cider :package-version '(cider . "0.6.0")) +(defcustom cider-file-loaded-hook nil + "List of functions to call when a load file has completed." + :type 'hook + :group 'cider + :package-version '(cider . "0.1.7")) (defconst cider-output-buffer "*cider-out*") @@ -276,11 +284,11 @@ into a new error buffer." ;; Causes are returned as a series of messages, which we aggregate in `causes' (let (causes) (cider-nrepl-send-request - (nconc '("op" "stacktrace") - (when (cider--pprint-fn) - `("pprint-fn" ,(cider--pprint-fn))) - (when cider-stacktrace-print-options - `("print-options" ,cider-stacktrace-print-options))) + (thread-last + (map-merge 'list + '(("op" "stacktrace")) + (cider--nrepl-print-request-map fill-column)) + (seq-mapcat #'identity)) (lambda (response) ;; While the return value of `cider--handle-stacktrace-response' is not ;; meaningful for the last message, we do not need the value of `causes' @@ -294,8 +302,47 @@ It delegates the actual error content to the eval or op handler." (cider-default-err-op-handler) (cider-default-err-eval-handler))) +(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)) + ":" + (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)) + ":" + (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)) + ":" + (group-n 4 (one-or-more digit)) + " - ")) + +(defconst cider-clojure-compilation-regexp (rx bol (or (eval cider-clojure-1.9-error) + (eval cider-clojure-warning) + (eval cider-clojure-1.10-error)))) + + (defvar cider-compilation-regexp - '("\\(?:.*\\(warning, \\)\\|.*?\\(, compiling\\):(\\)\\(.*?\\):\\([[:digit:]]+\\)\\(?::\\([[:digit:]]+\\)\\)?\\(\\(?: - \\(.*\\)\\)\\|)\\)" 3 4 5 (1)) + (list cider-clojure-compilation-regexp 2 3 4 '(1)) "Specifications for matching errors and warnings in Clojure stacktraces. See `compilation-error-regexp-alist' for help on their format.") @@ -483,8 +530,9 @@ or it can be a list with (START END) of the evaluated region." (cider-handle-compilation-errors err eval-buffer)) '()))) -(defun cider-load-file-handler (&optional buffer) - "Make a load file handler for BUFFER." +(defun cider-load-file-handler (&optional buffer done-handler) + "Make a load file handler for BUFFER. +Optional argument DONE-HANDLER lambda will be run once load is complete." (let ((eval-buffer (current-buffer))) (nrepl-make-response-handler (or buffer eval-buffer) (lambda (buffer value) @@ -498,7 +546,7 @@ or it can be a list with (START END) of the evaluated region." (lambda (_buffer err) (cider-emit-interactive-eval-err-output err) (cider-handle-compilation-errors err eval-buffer)) - '() + (or done-handler '()) (lambda () (funcall nrepl-err-handler))))) @@ -519,13 +567,13 @@ or it can be a list with (START END) of the evaluated region." (defun cider-eval-print-with-comment-handler (buffer location comment-prefix) "Make a handler for evaluating and printing commented results in BUFFER. -LOCATION is the location at which to insert. COMMENT-PREFIX is the comment -prefix to use." +LOCATION is the location marker at which to insert. COMMENT-PREFIX is the +comment prefix to use." (nrepl-make-response-handler buffer (lambda (buffer value) (with-current-buffer buffer (save-excursion - (goto-char location) + (goto-char (marker-position location)) (insert (concat comment-prefix value "\n"))))) (lambda (_buffer out) @@ -537,41 +585,49 @@ prefix to use." (defun cider-eval-pprint-with-multiline-comment-handler (buffer location comment-prefix continued-prefix comment-postfix) "Make a handler for evaluating and inserting results in BUFFER. The inserted text is pretty-printed and region will be commented. -LOCATION is the location at which to insert. +LOCATION is the location marker at which to insert. COMMENT-PREFIX is the comment prefix for the first line of output. CONTINUED-PREFIX is the comment prefix to use for the remaining lines. COMMENT-POSTFIX is the text to output after the last line." - (cl-flet ((multiline-comment-handler (buffer value) - (with-current-buffer buffer - (save-excursion - (goto-char location) - (let ((lines (split-string value "[\n]+" t))) - ;; only the first line gets the normal comment-prefix - (insert (concat comment-prefix (pop lines))) - (dolist (elem lines) - (insert (concat "\n" continued-prefix elem))) - (unless (string= comment-postfix "") - (insert comment-postfix))))))) - (nrepl-make-response-handler buffer - '() - #'multiline-comment-handler - #'multiline-comment-handler - '()))) + (let ((res "")) + (nrepl-make-response-handler + buffer + (lambda (_buffer value) + (setq res (concat res value))) + nil + nil + (lambda (buffer) + (with-current-buffer buffer + (save-excursion + (goto-char (marker-position location)) + (let ((lines (split-string res "[\n]+" t))) + ;; only the first line gets the normal comment-prefix + (insert (concat comment-prefix (pop lines))) + (dolist (elem lines) + (insert (concat "\n" continued-prefix elem))) + (unless (string= comment-postfix "") + (insert comment-postfix)))))) + nil + nil + (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. This is used by pretty-printing commands." - (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)) - '())) + (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)))) ;;; Interactive valuation commands @@ -617,7 +673,7 @@ API. Most other interactive eval functions should rely on this function. If CALLBACK is nil use `cider-interactive-eval-handler'. BOUNDS, if non-nil, is a list of two numbers marking the start and end positions of FORM in its buffer. -ADDITIONAL-PARAMS is a plist to be appended to the request message. +ADDITIONAL-PARAMS is a map to be merged into the request message. If `cider-interactive-eval-override' is a function, call it with the same arguments and only proceed with evaluation if it returns nil." @@ -640,13 +696,16 @@ arguments and only proceed with evaluation if it returns nil." (if (cider-ns-form-p form) "user" (cider-current-ns)) (when start (line-number-at-pos start)) (when start (cider-column-number-at-pos start)) - additional-params + (seq-mapcat #'identity additional-params) connection)))))) (defun cider-eval-region (start end) "Evaluate the region between START and END." (interactive "r") - (cider-interactive-eval nil nil (list start end))) + (cider-interactive-eval nil + nil + (list start end) + (cider--nrepl-pr-request-map))) (defun cider-eval-last-sexp (&optional output-to-current-buffer) "Evaluate the expression preceding point. @@ -655,7 +714,8 @@ buffer." (interactive "P") (cider-interactive-eval nil (when output-to-current-buffer (cider-eval-print-handler)) - (cider-last-sexp 'bounds))) + (cider-last-sexp 'bounds) + (cider--nrepl-pr-request-map))) (defun cider-eval-last-sexp-and-replace () "Evaluate the expression preceding point and replace it with its result." @@ -665,7 +725,10 @@ buffer." (cider-nrepl-sync-request:eval last-sexp) ;; seems like the sexp is valid, so we can safely kill it (backward-kill-sexp) - (cider-interactive-eval last-sexp (cider-eval-print-handler)))) + (cider-interactive-eval last-sexp + (cider-eval-print-handler) + nil + (cider--nrepl-pr-request-map)))) (defun cider-eval-sexp-at-point (&optional output-to-current-buffer) "Evaluate the expression around point. @@ -686,7 +749,10 @@ That's set by commands like `cider-eval-last-sexp-in-context'.") (format "Evaluation context (let-style) for `%s': " code) cider-previous-eval-context)) (code (concat "(let [" eval-context "]\n " code ")"))) - (cider-interactive-eval code) + (cider-interactive-eval code + nil + nil + (cider--nrepl-pr-request-map)) (setq-local cider-previous-eval-context eval-context))) (defun cider-eval-last-sexp-in-context () @@ -717,9 +783,10 @@ With the prefix arg INSERT-BEFORE, insert before the form, otherwise afterwards. (cider-interactive-eval nil (cider-eval-print-with-comment-handler (current-buffer) - insertion-point + (set-marker (make-marker) insertion-point) cider-comment-prefix) - bounds))) + bounds + (cider--nrepl-pr-request-map)))) (defun cider-pprint-form-to-comment (form-fn insert-before) "Evaluate the form selected by FORM-FN and insert result as comment. @@ -744,12 +811,12 @@ If INSERT-BEFORE is non-nil, insert before the form, otherwise afterwards." (cider-interactive-eval nil (cider-eval-pprint-with-multiline-comment-handler (current-buffer) - insertion-point + (set-marker (make-marker) insertion-point) cider-comment-prefix cider-comment-continued-prefix comment-postfix) bounds - (cider--nrepl-pprint-request-plist (cider--pretty-print-width))))) + (cider--nrepl-print-request-map fill-column)))) (defun cider-pprint-eval-last-sexp-to-comment (&optional insert-before) "Evaluate the last sexp and insert result as comment. @@ -791,7 +858,8 @@ 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-last-sexp 'bounds) + (cider--nrepl-pr-request-map)) (when prefix (cider-switch-to-repl-buffer))) @@ -802,7 +870,7 @@ If invoked with a PREFIX argument, switch to the REPL buffer." (cider-interactive-eval nil (cider-insert-eval-handler (cider-current-repl)) (cider-last-sexp 'bounds) - (cider--nrepl-pprint-request-plist (cider--pretty-print-width))) + (cider--nrepl-print-request-map fill-column)) (when prefix (cider-switch-to-repl-buffer))) @@ -814,17 +882,20 @@ With an optional PRETTY-PRINT prefix it pretty-prints the result." (cider-interactive-eval nil (cider-eval-print-handler) (cider-last-sexp 'bounds) - (when pretty-print - (cider--nrepl-pprint-request-plist (cider--pretty-print-width))))) + (if pretty-print + (cider--nrepl-print-request-map fill-column) + (cider--nrepl-pr-request-map)))) (defun cider--pprint-eval-form (form) "Pretty print FORM in popup buffer." - (let* ((result-buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 'ancillary)) + (let* ((buffer (current-buffer)) + (result-buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 'ancillary)) (handler (cider-popup-eval-handler result-buffer))) - (cider-interactive-eval (when (stringp form) form) - handler - (when (consp form) form) - (cider--nrepl-pprint-request-plist (cider--pretty-print-width))))) + (with-current-buffer buffer + (cider-interactive-eval (when (stringp form) form) + handler + (when (consp form) form) + (cider--nrepl-print-request-map fill-column))))) (defun cider-pprint-eval-last-sexp (&optional output-to-current-buffer) "Evaluate the sexp preceding point and pprint its value. @@ -875,7 +946,9 @@ command `cider-debug-defun-at-point'." (cider--prompt-and-insert-inline-dbg))) (cider-interactive-eval (when (and debug-it (not inline-debug)) (concat "#dbg\n" (cider-defun-at-point))) - nil (cider-defun-at-point 'bounds)))) + nil + (cider-defun-at-point 'bounds) + (cider--nrepl-pr-request-map)))) (defun cider--calculate-opening-delimiters () "Walks up the list of expressions to collect all sexp opening delimiters. @@ -918,9 +991,11 @@ buffer. It constructs an expression to eval in the following manner: (let* ((beg-of-defun (save-excursion (beginning-of-defun) (point))) (code (buffer-substring-no-properties beg-of-defun (point))) (code (concat code (cider--calculate-closing-delimiters)))) - (cider-interactive-eval - code - (when output-to-current-buffer (cider-eval-print-handler))))) + (cider-interactive-eval code + (when output-to-current-buffer + (cider-eval-print-handler)) + nil + (cider--nrepl-pr-request-map)))) (defun cider-eval-sexp-up-to-point (&optional output-to-current-buffer) "Evaluate the current sexp form up to point. @@ -938,7 +1013,10 @@ buffer. It constructs an expression to eval in the following manner: (code (if (= beg-set? ?#) (concat (list beg-set?) code) code)) (code (concat code (list (cider--matching-delimiter beg-delimiter))))) (cider-interactive-eval code - (when output-to-current-buffer (cider-eval-print-handler))))) + (when output-to-current-buffer + (cider-eval-print-handler)) + nil + (cider--nrepl-pr-request-map)))) (defun cider-pprint-eval-defun-at-point (&optional output-to-current-buffer) "Evaluate the \"top-level\" form at point and pprint its value. @@ -971,7 +1049,10 @@ If VALUE is non-nil, it is inserted into the minibuffer as initial input." (insert ns-form "\n\n")) (insert form) (let ((cider-interactive-eval-override override)) - (cider-interactive-eval form))))) + (cider-interactive-eval form + nil + nil + (cider--nrepl-pr-request-map)))))) (defun cider-read-and-eval-defun-at-point () "Insert the toplevel form at point in the minibuffer and output its result. @@ -997,7 +1078,8 @@ passing arguments." (define-key map (kbd "C-c e") #'cider-pprint-eval-last-sexp-to-comment) (define-key map (kbd "C-c C-e") #'cider-pprint-eval-last-sexp-to-comment) (define-key map (kbd "C-c d") #'cider-pprint-eval-defun-to-comment) - (define-key map (kbd "C-c C-d") #'cider-pprint-eval-defun-to-comment))) + (define-key map (kbd "C-c C-d") #'cider-pprint-eval-defun-to-comment) + map)) (defvar cider-eval-commands-map (let ((map (define-prefix-command 'cider-eval-commands-map))) @@ -1027,18 +1109,22 @@ passing arguments." (define-key map (kbd "C-z") #'cider-eval-defun-up-to-point) (define-key map (kbd "C-c") #'cider-eval-last-sexp-in-context) (define-key map (kbd "C-b") #'cider-eval-sexp-at-point-in-context) - (define-key map (kbd "C-f") 'cider-eval-pprint-commands-map))) + (define-key map (kbd "C-f") 'cider-eval-pprint-commands-map) + map)) (defun cider--file-string (file) "Read the contents of a FILE and return as a string." (with-current-buffer (find-file-noselect file) - (substring-no-properties (buffer-string)))) + (save-restriction + (widen) + (substring-no-properties (buffer-string))))) -(defun cider-load-buffer (&optional buffer) +(defun cider-load-buffer (&optional buffer callback) "Load (eval) BUFFER's file in nREPL. If no buffer is provided the command acts on the current buffer. If the buffer is for a cljc file, and both a Clojure and ClojureScript REPL exists -for the project, it is evaluated in both REPLs." +for the project, it is evaluated in both REPLs. +Optional argument CALLBACK will override the default ‘cider-load-file-handler’." (interactive) (setq buffer (or buffer (current-buffer))) ;; When cider-load-buffer or cider-load-file are called in programs the @@ -1069,7 +1155,8 @@ for the project, it is evaluated in both REPLs." (funcall cider-to-nrepl-filename-function (cider--server-filename filename)) (file-name-nondirectory filename) - repl))) + repl + callback))) (message "Loading %s..." filename)))))) (defun cider-load-file (filename) diff --git a/elpa/cider-20190121.1852/cider-find.el b/elpa/cider-20191027.1704/cider-find.el similarity index 99% rename from elpa/cider-20190121.1852/cider-find.el rename to elpa/cider-20191027.1704/cider-find.el index e1a90cdd..fef12069 100644 --- a/elpa/cider-20190121.1852/cider-find.el +++ b/elpa/cider-20191027.1704/cider-find.el @@ -58,7 +58,6 @@ 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." (interactive "P") - (cider-ensure-op-supported "info") (if var (cider--find-var var line) (funcall (cider-prompt-for-symbol-function arg) @@ -71,7 +70,6 @@ thing at point." (defun cider-find-dwim-at-mouse (event) "Find and display variable or resource at mouse EVENT." (interactive "e") - (cider-ensure-op-supported "info") (if-let* ((symbol-file (save-excursion (mouse-set-point event) (cider-symbol-at-point 'look-back)))) diff --git a/elpa/cider-20190121.1852/cider-format.el b/elpa/cider-20191027.1704/cider-format.el similarity index 95% rename from elpa/cider-20190121.1852/cider-format.el rename to elpa/cider-20191027.1704/cider-format.el index 2cf9d09d..cd62ed8d 100644 --- a/elpa/cider-20190121.1852/cider-format.el +++ b/elpa/cider-20191027.1704/cider-format.el @@ -26,6 +26,8 @@ ;;; Code: +(require 'map) +(require 'seq) (require 'subr-x) (require 'cider-client) @@ -117,8 +119,6 @@ of the buffer into a formatted string." ;;; Format EDN -(declare-function cider--pretty-print-width "cider-repl") - ;;;###autoload (defun cider-format-edn-buffer () "Format the EDN data in the current buffer." @@ -126,7 +126,7 @@ of the buffer into a formatted string." (check-parens) (cider-ensure-connected) (cider--format-buffer (lambda (edn) - (cider-sync-request:format-edn edn (cider--pretty-print-width))))) + (cider-sync-request:format-edn edn fill-column)))) ;;;###autoload (defun cider-format-edn-region (start end) @@ -135,7 +135,7 @@ START and END represent the region's boundaries." (interactive "r") (cider-ensure-connected) (let* ((start-column (save-excursion (goto-char start) (current-column))) - (right-margin (- (cider--pretty-print-width) start-column))) + (right-margin (- fill-column start-column))) (cider--format-region start end (lambda (edn) (cider-sync-request:format-edn edn right-margin))))) diff --git a/elpa/cider-20190121.1852/cider-inspector.el b/elpa/cider-20191027.1704/cider-inspector.el similarity index 91% rename from elpa/cider-20190121.1852/cider-inspector.el rename to elpa/cider-20191027.1704/cider-inspector.el index c8c71f10..6f4bff44 100644 --- a/elpa/cider-20190121.1852/cider-inspector.el +++ b/elpa/cider-20191027.1704/cider-inspector.el @@ -28,6 +28,7 @@ ;;; Code: (require 'cl-lib) +(require 'easymenu) (require 'seq) (require 'cider-eval) @@ -71,11 +72,29 @@ The page size can be also changed interactively within the inspector." (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 "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 [(shift tab)] #'cider-inspector-previous-inspectable-object) ;; 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] + ["Define Var" cider-inspector-def-current-val] + "--" + ["Quit" cider-popup-buffer-quit-function] + )) map)) (define-derived-mode cider-inspector-mode special-mode "Inspector" @@ -198,6 +217,16 @@ Current page will be reset to zero." (when-let* ((value (cider-sync-request:inspect-set-page-size page-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." + (interactive (list (cider-read-from-minibuffer "Var name: ") + (cider-current-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))) + ;; nREPL interactions (defun cider-sync-request:inspect-pop () "Move one level up in the inspector stack." @@ -237,6 +266,14 @@ Current page will be reset to zero." (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) "Evaluate EXPR in context of NS and inspect its result. Set the page size in paginated view to PAGE-SIZE." diff --git a/elpa/cider-20190121.1852/cider-macroexpansion.el b/elpa/cider-20191027.1704/cider-macroexpansion.el similarity index 98% rename from elpa/cider-20190121.1852/cider-macroexpansion.el rename to elpa/cider-20191027.1704/cider-macroexpansion.el index 7efe1c08..bb8a1572 100644 --- a/elpa/cider-20190121.1852/cider-macroexpansion.el +++ b/elpa/cider-20191027.1704/cider-macroexpansion.el @@ -44,8 +44,8 @@ Possible values are: 'qualified ;=> Vars are fully-qualified in the expansion 'none ;=> Vars are displayed without namespace qualification 'tidy ;=> Vars that are :refer-ed or defined in the current namespace are - displayed with their simple name, non-refered vars from other - namespaces are refered using the alias for that namespace (if + displayed with their simple name, non-referred vars from other + namespaces are referred using the alias for that namespace (if defined), other vars are displayed fully qualified." :type '(choice (const :tag "Suppress namespaces" none) (const :tag "Show fully-qualified namespaces" qualified) diff --git a/elpa/cider-20190121.1852/cider-mode.el b/elpa/cider-20191027.1704/cider-mode.el similarity index 94% rename from elpa/cider-20190121.1852/cider-mode.el rename to elpa/cider-20191027.1704/cider-mode.el index 8c5c4dd9..7ccfb8dc 100644 --- a/elpa/cider-20190121.1852/cider-mode.el +++ b/elpa/cider-20191027.1704/cider-mode.el @@ -121,7 +121,7 @@ Clojure buffer." (defun cider-switch-to-last-clojure-buffer () "Switch to the last Clojure buffer. The default keybinding for this command is -the same as `cider-switch-to-repl-buffer', +the same as variable `cider-switch-to-repl-buffer', so that it is very convenient to jump between a Clojure buffer and the REPL buffer." (interactive) @@ -151,7 +151,7 @@ the related commands `cider-repl-clear-buffer' and `cider-repl-clear-output'." (interactive "P") (let ((origin-buffer (current-buffer))) - (switch-to-buffer (cider-current-repl)) + (switch-to-buffer (cider-current-repl nil 'ensure)) (if clear-repl (cider-repl-clear-buffer) (cider-repl-clear-output)) @@ -223,6 +223,17 @@ With a prefix argument, prompt for function to run instead of -main." :group 'cider :package-version '(cider . "0.18.0")) +(define-obsolete-variable-alias + 'cider-switch-to-repl-after-insert-p + 'cider-switch-to-repl-on-insert + "0.21.0") + +(defcustom cider-switch-to-repl-on-insert t + "Whether to switch to the repl when inserting a form into the repl." + :type 'boolean + :group 'cider + :package-version '(cider . "0.21.0")) + (defcustom cider-invert-insert-eval-p nil "Whether to invert the behavior of evaling. Default behavior when inserting is to NOT eval the form and only eval with @@ -234,20 +245,26 @@ and eval and the prefix is required to prevent evaluation." (defun cider-insert-in-repl (form eval) "Insert FORM in the REPL buffer and switch to it. -If EVAL is non-nil the form will also be evaluated." +If EVAL is non-nil the form will also be evaluated. Use +`cider-invert-insert-eval-p' to invert this behavior." (while (string-match "\\`[ \t\n\r]+\\|[ \t\n\r]+\\'" form) (setq form (replace-match "" t t form))) - (with-current-buffer (cider-current-repl) - (goto-char (point-max)) - (let ((beg (point))) - (insert form) - (indent-region beg (point))) - (when (if cider-invert-insert-eval-p - (not eval) - eval) - (cider-repl-return))) - (when cider-switch-to-repl-after-insert-p - (cider-switch-to-repl-buffer))) + (when cider-switch-to-repl-on-insert + (cider-switch-to-repl-buffer)) + (let ((repl (cider-current-repl))) + (with-selected-window (or (get-buffer-window repl) + (selected-window)) + (with-current-buffer repl + (goto-char (point-max)) + (let ((beg (point))) + (insert form) + (indent-region beg (point)) + (cider--font-lock-ensure beg (point))) + (when (if cider-invert-insert-eval-p + (not eval) + eval) + (cider-repl-return)) + (goto-char (point-max)))))) (defun cider-insert-last-sexp-in-repl (&optional arg) "Insert the expression preceding point in the REPL buffer. @@ -313,8 +330,8 @@ If invoked with a prefix ARG eval the expression after inserting it." :active (seq-remove #'null cider-ancillary-buffers)] ("nREPL" :active (cider-connected-p) ["Describe nrepl session" cider-describe-nrepl-session] - ["Toggle message logging" nrepl-toggle-message-logging]) - "Menu for CIDER mode.")) + ["Toggle message logging" nrepl-toggle-message-logging])) + "Menu for CIDER mode.") (defconst cider-mode-eval-menu '("CIDER Eval" :visible (cider-connected-p) @@ -379,6 +396,11 @@ If invoked with a prefix ARG eval the expression after inserting it." ["Find resource" cider-find-resource] ["Find keyword" cider-find-keyword] ["Go back" cider-pop-back]) + ("Xref" + ["Find fn references" cider-xref-fn-refs] + ["Find fn references and select" cider-xref-fn-refs-select] + ["Find fn dependencies" cider-xref-fn-defs] + ["Find fn dependencies and select" cider-xref-fn-defs-select]) ("Browse" ["Browse namespace" cider-browse-ns] ["Browse all namespaces" cider-browse-ns-all] @@ -448,6 +470,10 @@ If invoked with a prefix ARG eval the expression after inserting it." (declare-function cider-find-keyword "cider-find") (declare-function cider-find-var "cider-find") (declare-function cider-find-dwim-at-mouse "cider-find") +(declare-function cider-xref-fn-refs "cider-xref") +(declare-function cider-xref-fn-refs-select "cider-xref") +(declare-function cider-xref-fn-deps "cider-xref") +(declare-function cider-xref-fn-deps-select "cider-xref") (defconst cider--has-many-mouse-buttons (not (memq window-system '(mac ns))) "Non-nil if system binds forward and back buttons to and . @@ -497,6 +523,10 @@ As it stands Emacs fires these events on and on 'x' and (define-key map (kbd "C-c M-s") #'cider-selector) (define-key map (kbd "C-c M-d") #'cider-describe-connection) (define-key map (kbd "C-c C-=") 'cider-profile-map) + (define-key map (kbd "C-c C-? r") #'cider-xref-fn-refs) + (define-key map (kbd "C-c C-? C-r") #'cider-xref-fn-refs-select) + (define-key map (kbd "C-c C-? d") #'cider-xref-fn-deps) + (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) (dolist (variable '(cider-mode-interactions-menu @@ -546,6 +576,8 @@ re-visited." (defun cider--get-symbol-indent (symbol-name) "Return the indent metadata for SYMBOL-NAME in the current namespace." (let* ((ns (let ((clojure-cache-ns t)) ; we force ns caching here for performance reasons + ;; silence bytecode warning of unused lexical var + (ignore clojure-cache-ns) (cider-current-ns)))) (if-let* ((meta (cider-resolve-var ns symbol-name)) (indent (or (nrepl-dict-get meta "style/indent") @@ -945,7 +977,7 @@ SYM and INFO is passed to `cider-docview-render'" (buffer-substring-no-properties (point-min) (1- (point)))))) (defcustom cider-use-tooltips t - "If non-nil, CIDER displays mouse-over tooltips." + "If non-nil, CIDER displays mouse-over tooltips, as well as the `help-echo' mechanism." :group 'cider :type 'boolean :package-version '(cider "0.12.0")) @@ -987,7 +1019,8 @@ property." (lambda (beg end &rest rest) (with-silent-modifications (remove-text-properties beg end '(cider-locals nil cider-block-dynamic-font-lock nil)) - (add-text-properties beg end '(help-echo cider--help-echo)) + (when cider-use-tooltips + (add-text-properties beg end '(help-echo cider--help-echo))) (when cider-font-lock-dynamically (cider--update-locals-for-region beg end))) (apply func beg end rest))) @@ -1008,9 +1041,7 @@ property." (progn (setq-local sesman-system 'CIDER) (cider-eldoc-setup) - (make-local-variable 'completion-at-point-functions) - (add-to-list 'completion-at-point-functions - #'cider-complete-at-point) + (add-hook 'completion-at-point-functions #'cider-complete-at-point nil t) (font-lock-add-keywords nil cider--static-font-lock-keywords) (cider-refresh-dynamic-font-lock) (font-lock-add-keywords nil cider--reader-conditionals-font-lock-keywords) @@ -1026,6 +1057,7 @@ property." (setq-local clojure-get-indent-function #'cider--get-symbol-indent)) (setq-local clojure-expected-ns-function #'cider-expected-ns) (setq next-error-function #'cider-jump-to-compilation-error)) + ;; Mode cleanup (mapc #'kill-local-variable '(completion-at-point-functions next-error-function x-gtk-use-system-tooltips @@ -1035,7 +1067,8 @@ property." (font-lock-add-keywords nil cider--reader-conditionals-font-lock-keywords) (font-lock-remove-keywords nil cider--dynamic-font-lock-keywords) (font-lock-remove-keywords nil cider--static-font-lock-keywords) - (cider--font-lock-flush))) + (cider--font-lock-flush) + (remove-hook 'completion-at-point-functions #'cider-complete-at-point t))) (defun cider-set-buffer-ns (ns) "Set this buffer's namespace to NS and refresh font-locking." diff --git a/elpa/cider-20190121.1852/cider-ns.el b/elpa/cider-20191027.1704/cider-ns.el similarity index 85% rename from elpa/cider-20190121.1852/cider-ns.el rename to elpa/cider-20191027.1704/cider-ns.el index 227e803c..e6b82de9 100644 --- a/elpa/cider-20190121.1852/cider-ns.el +++ b/elpa/cider-20191027.1704/cider-ns.el @@ -57,6 +57,8 @@ ;;; Code: +(require 'map) +(require 'seq) (require 'subr-x) (require 'cider-client) @@ -65,7 +67,7 @@ (define-obsolete-variable-alias 'cider-save-files-on-cider-ns-refresh 'cider-ns-save-files-on-refresh "0.18") (defcustom cider-ns-save-files-on-refresh 'prompt - "Controls whether to prompt to save Clojure files on `cider-ns-refresh'. + "Controls whether to prompt to save files before refreshing. If nil, files are not saved. If 'prompt, the user is prompted to save files if they have been modified. If t, save the files without confirmation." @@ -75,6 +77,16 @@ 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) + "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. +If t, all buffers visiting files on the classpath might be saved." + :type '(choice listp + (const t)) + :group 'cider + :package-version '(cider . "0.21.0")) + (defconst cider-ns-refresh-log-buffer "*cider-ns-refresh-log*") (define-obsolete-variable-alias 'cider-refresh-show-log-buffer 'cider-ns-refresh-show-log-buffer "0.18") @@ -161,19 +173,20 @@ namespace-qualified function of zero arity." (when (member "error" status) (cider--render-stacktrace-causes error)))) -(defun cider-ns-refresh--save-project-buffers () - "Ensure modified project buffers are saved before certain operations. -Its behavior is controlled by `cider-save-files-on-cider-ns-refresh'." - (when-let* ((project-root (clojure-project-dir))) - (when cider-save-files-on-cider-ns-refresh +(defun cider-ns-refresh--save-modified-buffers () + "Ensure any relevant modified buffers are saved before refreshing. +Its behavior is controlled by `cider-ns-save-files-on-refresh' and +`cider-ns-save-files-on-refresh-modes'." + (when cider-ns-save-files-on-refresh + (let ((dirs (seq-filter #'file-directory-p + (cider-classpath-entries)))) (save-some-buffers - (eq cider-save-files-on-cider-ns-refresh t) + (not (eq cider-ns-save-files-on-refresh 'prompt)) (lambda () - (and - (derived-mode-p 'clojure-mode) - (string-prefix-p project-root - (file-truename default-directory) - (eq system-type 'windows-nt)))))))) + (and (seq-some #'derived-mode-p cider-ns-save-files-on-refresh-modes) + (seq-some (lambda (dir) + (file-in-directory-p buffer-file-name dir)) + dirs))))))) ;;;###autoload (defun cider-ns-reload (&optional prompt) @@ -226,7 +239,7 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and (interactive "p") (cider-ensure-connected) (cider-ensure-op-supported "refresh") - (cider-ns-refresh--save-project-buffers) + (cider-ns-refresh--save-modified-buffers) (let ((clear? (member mode '(clear 16))) (refresh-all? (member mode '(refresh-all 4))) (inhibit-refresh-fns (member mode '(inhibit-fns -1)))) @@ -245,15 +258,15 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and (when clear? (cider-nrepl-send-sync-request '("op" "refresh-clear") conn)) (cider-nrepl-send-request - (nconc `("op" ,(if refresh-all? "refresh-all" "refresh")) - (when (cider--pprint-fn) - `("pprint-fn" ,(cider--pprint-fn))) - (when cider-stacktrace-print-options - `("print-options" ,cider-stacktrace-print-options)) - (when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn) - `("before" ,cider-ns-refresh-before-fn)) - (when (and (not inhibit-refresh-fns) cider-ns-refresh-after-fn) - `("after" ,cider-ns-refresh-after-fn))) + (thread-last + (map-merge 'list + `(("op" ,(if refresh-all? "refresh-all" "refresh"))) + (cider--nrepl-print-request-map fill-column) + (when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn) + `(("before" ,cider-ns-refresh-before-fn))) + (when (and (not inhibit-refresh-fns) cider-ns-refresh-after-fn) + `(("after" ,cider-ns-refresh-after-fn)))) + (seq-mapcat #'identity)) (lambda (response) (cider-ns-refresh--handle-response response log-buffer)) conn)))))) diff --git a/elpa/cider-20190121.1852/cider-overlays.el b/elpa/cider-20191027.1704/cider-overlays.el similarity index 91% rename from elpa/cider-20190121.1852/cider-overlays.el rename to elpa/cider-20191027.1704/cider-overlays.el index 5be7f00f..05d6da3f 100644 --- a/elpa/cider-20190121.1852/cider-overlays.el +++ b/elpa/cider-20191027.1704/cider-overlays.el @@ -59,17 +59,27 @@ font-locking it." (defcustom cider-use-overlays 'both "Whether to display evaluation results with overlays. -If t, use overlays. If nil, display on the echo area. If both, display on -both places. +If t, use overlays determined by `cider-result-overlay-position'. +If nil, display on the echo area. +If both, display on both places. Only applies to evaluation commands. To configure the debugger overlays, see `cider-debug-use-overlays'." - :type '(choice (const :tag "End of line" t) - (const :tag "Bottom of screen" nil) + :type '(choice (const :tag "Display using overlays" t) + (const :tag "Display in echo area" nil) (const :tag "Both" both)) :group 'cider :package-version '(cider . "0.10.0")) +(defcustom cider-result-overlay-position 'at-eol + "Where to display result overlays for inline evaluation and the debugger. +If 'at-eol, display at the end of the line. +If 'at-point, display at the end of the respective sexp." + :group 'cider + :type ''(choice (const :tag "End of line" at-eol) + (const :tag "End of sexp" at-point)) + :package-version '(cider . "0.23.0")) + (defcustom cider-eval-result-prefix "=> " "The prefix displayed in the minibuffer before a result value." :type 'string @@ -156,10 +166,9 @@ END is the position where the sexp ends, and defaults to point." (format (concat " " cider-eval-result-prefix "%s ")) (prepend-face 'cider-result-overlay-face) &allow-other-keys) - "Place an overlay displaying VALUE at the end of line. + "Place an overlay displaying VALUE at the position determined by WHERE. VALUE is used as the overlay's after-string property, meaning it is -displayed at the end of the overlay. The overlay itself is placed from -beginning to end of current line. +displayed at the end of the overlay. Return nil if the overlay was not placed or if it might not be visible, and return the overlay otherwise. @@ -167,10 +176,9 @@ Return the overlay if it was placed successfully, and nil if it failed. This function takes some optional keyword arguments: - If WHERE is a number or a marker, apply the overlay over - the entire line at that place (defaulting to `point'). If - it is a cons cell, the car and cdr determine the start and - end of the overlay. + If WHERE is a number or a marker, apply the overlay as determined by + `cider-result-overlay-position'. If it is a cons cell, the car and cdr + determine the start and end of the overlay. DURATION takes the same possible values as the `cider-eval-result-duration' variable. TYPE is passed to `cider--make-overlay' (defaults to `result'). @@ -200,7 +208,9 @@ overlay." (point)))) (end (if (consp where) (cdr where) - (line-end-position))) + (pcase cider-result-overlay-position + ('at-eol (line-end-position)) + ('at-point (point))))) (display-string (format format value)) (o nil)) (remove-overlays beg end 'category type) diff --git a/elpa/cider-20190121.1852/cider-pkg.el b/elpa/cider-20191027.1704/cider-pkg.el similarity index 88% rename from elpa/cider-20190121.1852/cider-pkg.el rename to elpa/cider-20191027.1704/cider-pkg.el index c4558ff3..b3b58a2b 100644 --- a/elpa/cider-20190121.1852/cider-pkg.el +++ b/elpa/cider-20191027.1704/cider-pkg.el @@ -1,6 +1,7 @@ -(define-package "cider" "20190121.1852" "Clojure Interactive Development Environment that Rocks" +(define-package "cider" "20191027.1704" "Clojure Interactive Development Environment that Rocks" '((emacs "25") (clojure-mode "5.9") + (parseedn "0.1") (pkg-info "0.4") (queue "0.2") (spinner "1.7") diff --git a/elpa/cider-20190121.1852/cider-popup.el b/elpa/cider-20191027.1704/cider-popup.el similarity index 100% rename from elpa/cider-20190121.1852/cider-popup.el rename to elpa/cider-20191027.1704/cider-popup.el diff --git a/elpa/cider-20190121.1852/cider-profile.el b/elpa/cider-20191027.1704/cider-profile.el similarity index 100% rename from elpa/cider-20190121.1852/cider-profile.el rename to elpa/cider-20191027.1704/cider-profile.el diff --git a/elpa/cider-20190121.1852/cider-repl-history.el b/elpa/cider-20191027.1704/cider-repl-history.el similarity index 98% rename from elpa/cider-20190121.1852/cider-repl-history.el rename to elpa/cider-20191027.1704/cider-repl-history.el index f6cd4c86..bf9aaa5f 100644 --- a/elpa/cider-20190121.1852/cider-repl-history.el +++ b/elpa/cider-20191027.1704/cider-repl-history.el @@ -411,14 +411,14 @@ text is still inserted at the end." (pt (cdr data))) (cider-repl-history-do-insert buf pt))) -(defun cider-repl-history-clear-highlighed-entry () +(defun cider-repl-history-clear-highlighted-entry () "Clear the highlighted entry, when one exists." (when cider-repl-history-previous-overlay (cl-assert (overlayp cider-repl-history-previous-overlay) nil "not an overlay") (overlay-put cider-repl-history-previous-overlay 'face nil))) -(defun cider-repl-history-update-highlighed-entry () +(defun cider-repl-history-update-highlighted-entry () "Update highlighted entry, when feature is turned on." (when cider-repl-history-highlight-current-entry (if-let* ((current-overlay (cider-repl-history-target-overlay-at (point) t))) @@ -426,12 +426,12 @@ text is still inserted at the end." ;; We've changed overlay. Clear current highlighting, ;; and highlight the new overlay. (cl-assert (overlay-get current-overlay 'cider-repl-history-target) t) - (cider-repl-history-clear-highlighed-entry) + (cider-repl-history-clear-highlighted-entry) (setq cider-repl-history-previous-overlay current-overlay) (overlay-put current-overlay 'face cider-repl-history-current-entry-face)) ;; No overlay at point. Just clear all current highlighting. - (cider-repl-history-clear-highlighed-entry)))) + (cider-repl-history-clear-highlighted-entry)))) (defun cider-repl-history-forward (&optional arg) "Move forward by ARG command history entries." @@ -571,7 +571,7 @@ spacing when it's actually inserted into the REPL buffer." This function is called whenever the selection in the *cider-repl-history* buffer is adjusted, the `cider-repl-history-preview-overlay' -is udpated to preview the text of the selection at PT (or the +is updated to preview the text of the selection at PT (or the current point if not specified)." (let ((new-text (cider-repl-history-current-string (or pt (point)) t))) @@ -641,7 +641,7 @@ text from the *cider-repl-history* buffer." nil t)) (when cider-repl-history-highlight-current-entry (add-hook 'post-command-hook - 'cider-repl-history-update-highlighed-entry + 'cider-repl-history-update-highlighted-entry nil t)) (message (let ((entry (if (= 1 (length cider-command-history)) diff --git a/elpa/cider-20190121.1852/cider-repl.el b/elpa/cider-20191027.1704/cider-repl.el similarity index 85% rename from elpa/cider-20190121.1852/cider-repl.el rename to elpa/cider-20191027.1704/cider-repl.el index 2d75d211..52dc84d3 100644 --- a/elpa/cider-20190121.1852/cider-repl.el +++ b/elpa/cider-20191027.1704/cider-repl.el @@ -33,21 +33,25 @@ ;;; Code: +(require 'cl-lib) +(require 'easymenu) +(require 'image) +(require 'map) +(require 'seq) +(require 'subr-x) + +(require 'clojure-mode) +(require 'sesman) + (require 'cider-client) (require 'cider-doc) (require 'cider-test) (require 'cider-eldoc) ; for cider-eldoc-setup (require 'cider-common) -(require 'subr-x) (require 'cider-compat) (require 'cider-util) (require 'cider-resolve) -(require 'clojure-mode) -(require 'easymenu) -(require 'cl-lib) -(require 'sesman) - (eval-when-compile (defvar paredit-version) (defvar paredit-space-for-delimiter-predicates)) @@ -101,18 +105,7 @@ focused. Otherwise the buffer is displayed and focused." :type 'boolean :group 'cider-repl) -(defcustom cider-repl-scroll-on-output t - "Controls whether the REPL buffer auto-scrolls on new output. - -When set to t (the default), if the REPL buffer contains more lines than the -size of the window, the buffer is automatically re-centered upon completion -of evaluating an expression, so that the bottom line of output is on the -bottom line of the window. - -If this is set to nil, no re-centering takes place." - :type 'boolean - :group 'cider-repl - :package-version '(cider . "0.11.0")) +(make-obsolete-variable 'cider-repl-scroll-on-output 'scroll-conservatively "0.21") (defcustom cider-repl-use-pretty-printing t "Control whether results in the REPL are pretty-printed or not. @@ -122,14 +115,7 @@ change the setting's value." :type 'boolean :group 'cider-repl) -(defcustom cider-repl-pretty-print-width nil - "Control the width of pretty printing on the REPL. -This sets the wrap point for pretty printing on the repl. If nil, it -defaults to the variable `fill-column'." - :type '(restricted-sexp :match-alternatives - (integerp 'nil)) - :group 'cider-repl - :package-version '(cider . "0.15.0")) +(make-obsolete-variable 'cider-repl-pretty-print-width 'cider-print-options "0.21") (defcustom cider-repl-use-content-types t "Control whether REPL results are presented using content-type information. @@ -157,6 +143,12 @@ will be used." :group 'cider-repl :package-version '(cider . "0.10.0")) +(defcustom cider-repl-require-ns-on-set nil + "Controls whether to require the ns before setting it in the REPL." + :type 'boolean + :group 'cider-repl + :package-version '(cider . "0.22.0")) + (defcustom cider-repl-result-prefix "" "The prefix displayed in the REPL before a result value. By default there's no prefix, but you can specify something @@ -173,17 +165,19 @@ you'd like to use the default Emacs behavior use :type 'symbol :group 'cider-repl) -(defcustom cider-repl-print-length 100 - "Initial value for *print-length* set during REPL start." - :type 'integer - :group 'cider - :package-version '(cider . "0.17.0")) +(make-obsolete-variable 'cider-repl-print-length 'cider-print-options "0.21") +(make-obsolete-variable 'cider-repl-print-level 'cider-print-options "0.21") -(defcustom cider-repl-print-level nil - "Initial value for *print-level* set during REPL start." - :type 'integer - :group 'cider - :package-version '(cider . "0.17.0")) +(defvar cider-repl-require-repl-utils-code + '((clj . "(clojure.core/apply clojure.core/require clojure.main/repl-requires)") + (cljs . "(use '[cljs.repl :only [apropos dir doc find-doc print-doc pst source]])"))) + +(defcustom cider-repl-init-code (list (cdr (assoc 'clj cider-repl-require-repl-utils-code))) + "Clojure code to evaluate when starting a REPL. +Will be evaluated with bindings for set!-able vars in place." + :type '(list string) + :group 'cider-repl + :package-version '(cider . "0.21.0")) (defcustom cider-repl-display-help-banner t "When non-nil a bit of help text will be displayed on REPL start." @@ -261,58 +255,55 @@ This cache is stored in the connection buffer.") ns-dict))))) (cider-refresh-dynamic-font-lock ns-dict)))))))))) -(declare-function cider-set-buffer-ns "cider-mode") -(defun cider-repl-set-initial-ns (buffer) - "Require standard REPL util functions and set the ns of the REPL's BUFFER. -Namespace is \"user\" by default, but can be overridden in apps like -lein (:init-ns). Both of these operations need to be done as a sync -request at the beginning of the session. Bundling them together for -efficiency." - ;; we don't want to get a timeout during init - (let ((nrepl-sync-request-timeout nil)) - (with-current-buffer buffer - (let* ((response (nrepl-send-sync-request - (lax-plist-put (nrepl--eval-request "(str *ns*)") - "inhibit-cider-middleware" "true") - (cider-current-repl))) - (initial-ns (or (read (nrepl-dict-get response "value")) - "user"))) - (cider-set-buffer-ns initial-ns))))) - (defun cider-repl-require-repl-utils () "Require standard REPL util functions into the current REPL." (interactive) - (nrepl-send-sync-request - (lax-plist-put - (nrepl--eval-request - "(when (clojure.core/resolve 'clojure.main/repl-requires) - (clojure.core/map clojure.core/require clojure.main/repl-requires))") - "inhibit-cider-middleware" "true") - (cider-current-repl))) - -(defun cider-repl--build-config-expression () - "Build the initial config expression." - (when (or cider-repl-print-length cider-repl-print-level) - (concat - "(do" - (when cider-repl-print-length (format " (set! *print-length* %d)" cider-repl-print-length)) - (when cider-repl-print-level (format " (set! *print-level* %d)" cider-repl-print-level)) - ")"))) - -(defun cider-repl-set-config () - "Set an inititial REPL configuration." - (interactive) - (when-let* ((config-expression (cider-repl--build-config-expression))) + (let* ((current-repl (cider-current-repl nil 'ensure)) + (require-code (cdr (assoc (cider-repl-type current-repl) cider-repl-require-repl-utils-code)))) (nrepl-send-sync-request (lax-plist-put - (nrepl--eval-request config-expression) + (nrepl--eval-request require-code (cider-current-ns)) "inhibit-cider-middleware" "true") - (cider-current-repl)))) + current-repl))) + +(defun cider-repl-init-eval-handler (&optional callback) + "Make an nREPL evaluation handler for use during REPL init. +Run CALLBACK once the evaluation is complete." + (nrepl-make-response-handler (current-buffer) + (lambda (_buffer _value)) + (lambda (buffer out) + (cider-repl-emit-stdout buffer out)) + (lambda (buffer err) + (cider-repl-emit-stderr buffer err)) + (lambda (buffer) + (cider-repl-emit-prompt buffer) + (when callback + (funcall callback))))) -(defun cider-repl-init (buffer &optional no-banner) +(defun cider-repl-eval-init-code (&optional callback) + "Evaluate `cider-repl-init-code' in the current REPL. +Run CALLBACK once the evaluation is complete." + (interactive) + (let* ((request (map-merge 'hash-table + (cider--repl-request-map fill-column) + '(("inhibit-cider-middleware" "true"))))) + (cider-nrepl-request:eval + ;; Ensure we evaluate _something_ so the initial namespace is correctly set + (thread-first (or cider-repl-init-code '("nil")) + (string-join "\n")) + (cider-repl-init-eval-handler callback) + nil + (line-number-at-pos (point)) + (cider-column-number-at-pos (point)) + (thread-last request + (map-pairs) + (seq-mapcat #'identity))))) + +(defun cider-repl-init (buffer &optional callback) "Initialize the REPL in BUFFER. BUFFER must be a REPL buffer with `cider-repl-mode' and a running -client process connection. Unless NO-BANNER is non-nil, insert a banner." +client process connection. CALLBACK will be run once the REPL is +fully initialized." (when cider-repl-display-in-current-window (add-to-list 'same-window-buffer-names (buffer-name buffer))) (pcase cider-repl-pop-to-buffer-on-connect @@ -326,25 +317,21 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner." ;; against user config (set-buffer orig-buffer))) ((pred identity) (pop-to-buffer buffer))) - (cider-repl-set-initial-ns buffer) - (cider-repl-require-repl-utils) - (cider-repl-set-config) - (unless no-banner - (cider-repl--insert-banner-and-prompt buffer)) (with-current-buffer buffer - (set-window-point (get-buffer-window) (point-max))) + (cider-repl--insert-banner) + (when-let* ((window (get-buffer-window buffer t))) + (with-selected-window window + (recenter (- -1 scroll-margin)))) + (cider-repl-eval-init-code callback)) buffer) -(defun cider-repl--insert-banner-and-prompt (buffer) - "Insert REPL banner and REPL prompt in BUFFER." - (with-current-buffer buffer - (insert (propertize (cider-repl--banner) 'font-lock-face 'font-lock-comment-face)) - (when cider-repl-display-help-banner - (insert (propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face))) - (goto-char (point-max)) - (cider-repl--mark-output-start) - (cider-repl--mark-input-start) - (cider-repl--insert-prompt cider-buffer-ns))) +(defun cider-repl--insert-banner () + "Insert the banner in the current REPL buffer." + (insert-before-markers + (propertize (cider-repl--banner) 'font-lock-face 'font-lock-comment-face)) + (when cider-repl-display-help-banner + (insert-before-markers + (propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face)))) (defun cider-repl--banner () "Generate the welcome REPL buffer banner." @@ -356,7 +343,8 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner." ;; Source: (source function-name) ;; Javadoc: (javadoc java-object-or-class) ;; Exit: -;; Results: Stored in vars *1, *2, *3, an exception in *e;" +;; Results: Stored in vars *1, *2, *3, an exception in *e; +" (plist-get nrepl-endpoint :host) (plist-get nrepl-endpoint :port) (cider--version) @@ -367,7 +355,7 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner." (defun cider-repl--help-banner () "Generate the help banner." (substitute-command-keys - "\n;; ====================================================================== + ";; ====================================================================== ;; If you're new to CIDER it is highly recommended to go through its ;; manual first. Type to view it. ;; In case you're seeing any warnings you should consult the manual's @@ -511,15 +499,6 @@ If given a negative value of ARG, move to the beginning of defun." This will not work on non-current prompts." (= (point) cider-repl-input-start-mark)) -(defun cider-repl--show-maximum-output () - "Put the end of the buffer at the bottom of the window." - (when (and cider-repl-scroll-on-output (eobp)) - (let ((win (get-buffer-window (current-buffer) t))) - (when win - (with-selected-window win - (set-window-point win (point-max)) - (recenter -1)))))) - (defmacro cider-save-marker (marker &rest body) "Save MARKER and execute BODY." (declare (debug t)) @@ -660,34 +639,35 @@ namespaces. STRING is REPL's output." Each functions takes a string and must return a modified string. Also see `cider-run-chained-hook'.") -(defun cider-repl--emit-output-at-pos (buffer string output-face position &optional bol) - "Using BUFFER, insert STRING (applying to it OUTPUT-FACE) at POSITION. -If BOL is non-nil insert at the beginning of line. Run -`cider-repl-preoutput-hook' on STRING." +(defun cider-repl--emit-output (buffer string face) + "Using BUFFER, emit STRING as output font-locked using FACE. +Before inserting, run `cider-repl-preoutput-hook' on STRING." (with-current-buffer buffer (save-excursion (cider-save-marker cider-repl-output-start - (cider-save-marker cider-repl-output-end - (goto-char position) - ;; TODO: Review the need for bol - (when (and bol (not (bolp))) (insert-before-markers "\n")) - (setq string (propertize string - 'font-lock-face output-face - 'rear-nonsticky '(font-lock-face))) - (setq string (cider-run-chained-hook 'cider-repl-preoutput-hook string)) - (insert-before-markers string) - (cider-repl--flush-ansi-color-context) - (when (and (= (point) cider-repl-prompt-start-mark) - (not (bolp))) - (insert-before-markers "\n") - (set-marker cider-repl-output-end (1- (point))))))) - (cider-repl--show-maximum-output))) + (goto-char cider-repl-output-end) + (setq string (propertize string + 'font-lock-face face + 'rear-nonsticky '(font-lock-face))) + (setq string (cider-run-chained-hook 'cider-repl-preoutput-hook string)) + (insert-before-markers string) + (cider-repl--flush-ansi-color-context)) + (when (and (= (point) cider-repl-prompt-start-mark) + (not (bolp))) + (insert-before-markers "\n") + (set-marker cider-repl-output-end (1- (point)))))) + (when-let* ((window (get-buffer-window buffer t))) + ;; If the prompt is on the first line of the window, then scroll the window + ;; down by a single line to make the emitted output visible. + (when (and (pos-visible-in-window-p cider-repl-prompt-start-mark window) + (< 1 cider-repl-prompt-start-mark) + (not (pos-visible-in-window-p (1- cider-repl-prompt-start-mark) window))) + (with-selected-window window + (scroll-down 1))))) (defun cider-repl--emit-interactive-output (string face) "Emit STRING as interactive output using FACE." - (with-current-buffer (cider-current-repl) - (let ((pos (cider-repl--end-of-output))) - (cider-repl--emit-output-at-pos (current-buffer) string face pos t)))) + (cider-repl--emit-output (cider-current-repl) string face)) (defun cider-repl-emit-interactive-stdout (string) "Emit STRING as interactive output." @@ -697,12 +677,6 @@ If BOL is non-nil insert at the beginning of line. Run "Emit STRING as interactive err output." (cider-repl--emit-interactive-output string 'cider-repl-stderr-face)) -(defun cider-repl--emit-output (buffer string face &optional bol) - "Using BUFFER, emit STRING font-locked with FACE. -If BOL is non-nil, emit at the beginning of the line." - (with-current-buffer buffer - (cider-repl--emit-output-at-pos buffer string face cider-repl-input-start-mark bol))) - (defun cider-repl-emit-stdout (buffer string) "Using BUFFER, emit STRING as standard output." (cider-repl--emit-output buffer string 'cider-repl-stdout-face)) @@ -715,10 +689,7 @@ If BOL is non-nil, emit at the beginning of the line." "Emit the REPL prompt into BUFFER." (with-current-buffer buffer (save-excursion - (cider-save-marker cider-repl-output-start - (cider-save-marker cider-repl-output-end - (cider-repl--insert-prompt cider-buffer-ns)))) - (cider-repl--show-maximum-output))) + (cider-repl--insert-prompt cider-buffer-ns)))) (defun cider-repl-emit-result (buffer string show-prefix &optional bol) "Emit into BUFFER the result STRING and mark it as an evaluation result. @@ -727,18 +698,16 @@ of the line. If BOL is non-nil insert at the beginning of the line." (with-current-buffer buffer (save-excursion (cider-save-marker cider-repl-output-start - (cider-save-marker cider-repl-output-end - (goto-char cider-repl-input-start-mark) - (when (and bol (not (bolp))) - (insert-before-markers "\n")) - (when show-prefix - (insert-before-markers (propertize cider-repl-result-prefix 'font-lock-face 'font-lock-comment-face))) - (if cider-repl-use-clojure-font-lock - (insert-before-markers (cider-font-lock-as-clojure string)) - (cider-propertize-region - '(font-lock-face cider-repl-result-face rear-nonsticky (font-lock-face)) - (insert-before-markers string)))))) - (cider-repl--show-maximum-output))) + (goto-char cider-repl-output-end) + (when (and bol (not (bolp))) + (insert-before-markers "\n")) + (when show-prefix + (insert-before-markers (propertize cider-repl-result-prefix 'font-lock-face 'font-lock-comment-face))) + (if cider-repl-use-clojure-font-lock + (insert-before-markers (cider-font-lock-as-clojure string)) + (cider-propertize-region + '(font-lock-face cider-repl-result-face rear-nonsticky (font-lock-face)) + (insert-before-markers string))))))) (defun cider-repl-newline-and-indent () "Insert a newline, then indent the next line. @@ -787,7 +756,7 @@ the symbol." t))) (t t)))) -(defun cider-repl--display-image (buffer image &optional show-prefix bol string) +(defun cider-repl--display-image (buffer image &optional show-prefix bol) "Insert IMAGE into BUFFER at the current point. For compatibility with the rest of CIDER's REPL machinery, supports @@ -795,17 +764,20 @@ SHOW-PREFIX and BOL." (with-current-buffer buffer (save-excursion (cider-save-marker cider-repl-output-start - (cider-save-marker cider-repl-output-end - (goto-char cider-repl-input-start-mark) - (when (and bol (not (bolp))) - (insert-before-markers "\n")) - (when show-prefix - (insert-before-markers - (propertize cider-repl-result-prefix 'font-lock-face 'font-lock-comment-face))) - (insert-image image string) - (set-marker cider-repl-input-start-mark (point) buffer) - (set-marker cider-repl-prompt-start-mark (point) buffer)))) - (cider-repl--show-maximum-output)) + (goto-char cider-repl-output-end) + (when (and bol (not (bolp))) + (insert-before-markers "\n")) + (when show-prefix + (insert-before-markers + (propertize cider-repl-result-prefix 'font-lock-face 'font-lock-comment-face))) + ;; The below is inlined from `insert-image' and changed to use + ;; `insert-before-markers' rather than `insert' + (let ((start (point)) + (props (nconc `(display ,image rear-nonsticky (display)) + (when (boundp 'image-map) + `(keymap ,image-map))))) + (insert-before-markers " ") + (add-text-properties start (point) props))))) t) (defcustom cider-repl-image-margin 10 @@ -830,14 +802,14 @@ raw image data or a filename. Returns an image instance with a margin per Part of the default `cider-repl-content-type-handler-alist'." (cider-repl--display-image buffer (cider-repl--image image 'jpeg t) - show-prefix bol " ")) + show-prefix bol)) (defun cider-repl-handle-png (_type buffer image &optional show-prefix bol) "A handler for inserting a png IMAGE into a repl BUFFER. Part of the default `cider-repl-content-type-handler-alist'." (cider-repl--display-image buffer (cider-repl--image image 'png t) - show-prefix bol " ")) + show-prefix bol)) (defun cider-repl-handle-external-body (type buffer _ &optional _show-prefix _bol) "Handler for slurping external content into BUFFER. @@ -867,44 +839,38 @@ nREPL ops, it may be convenient to prevent inserting a prompt.") (defun cider-repl-handler (buffer) "Make an nREPL evaluation handler for the REPL BUFFER." - (let (after-first-result-chunk - (show-prompt t)) + (let ((show-prompt t)) (nrepl-make-response-handler buffer (lambda (buffer value) - (cider-repl-emit-result buffer value (not after-first-result-chunk) t) - (setq after-first-result-chunk t)) + (cider-repl-emit-result buffer value t)) (lambda (buffer out) (cider-repl-emit-stdout buffer out)) (lambda (buffer err) (cider-repl-emit-stderr buffer err)) (lambda (buffer) (when show-prompt - (cider-repl-emit-prompt buffer) - (let ((win (get-buffer-window (current-buffer) t))) - (when win - (with-selected-window win - (set-window-point win cider-repl-input-start-mark)) - (cider-repl--show-maximum-output))))) + (cider-repl-emit-prompt buffer))) nrepl-err-handler (lambda (buffer value content-type) (if-let* ((content-attrs (cadr content-type)) (content-type* (car content-type)) (handler (cdr (assoc content-type* cider-repl-content-type-handler-alist)))) - (setq after-first-result-chunk t - show-prompt (funcall handler content-type buffer value - (not after-first-result-chunk) t)) - (progn (cider-repl-emit-result buffer value (not after-first-result-chunk) t) - (setq after-first-result-chunk t))))))) - -(defun cider--repl-request-plist (right-margin &optional pprint-fn) - "Plist to be appended to generic eval requests, as for the REPL. -PPRINT-FN and RIGHT-MARGIN are as in `cider--nrepl-pprint-request-plist'." - (nconc (when cider-repl-use-pretty-printing - (cider--nrepl-pprint-request-plist right-margin pprint-fn)) - (when cider-repl-use-content-types - (cider--nrepl-content-type-plist)))) + (setq show-prompt (funcall handler content-type buffer value nil t)) + (cider-repl-emit-result buffer value t t))) + (lambda (buffer warning) + (cider-repl-emit-stderr buffer warning))))) + +(defun cider--repl-request-map (right-margin) + "Map to be merged into REPL eval requests. +RIGHT-MARGIN is as in `cider--nrepl-print-request-map'." + (map-merge 'hash-table + (cider--nrepl-print-request-map right-margin) + (unless cider-repl-use-pretty-printing + '(("nrepl.middleware.print/print" "cider.nrepl.pprint/pr"))) + (when cider-repl-use-content-types + (cider--nrepl-content-type-map)))) (defun cider-repl--send-input (&optional newline) "Go to the end of the input and send the current input. @@ -923,8 +889,7 @@ If NEWLINE is true then add a newline at the end of the input." (let ((end (point))) ; end of input, without the newline (cider-repl--add-to-input-history input) (when newline - (insert "\n") - (cider-repl--show-maximum-output)) + (insert "\n")) (let ((inhibit-modification-hooks t)) (add-text-properties cider-repl-input-start-mark (point) @@ -946,7 +911,10 @@ If NEWLINE is true then add a newline at the end of the input." (cider-current-ns) (line-number-at-pos input-start) (cider-column-number-at-pos input-start) - (cider--repl-request-plist (cider--pretty-print-width))))))) + (thread-last + (cider--repl-request-map fill-column) + (map-pairs) + (seq-mapcat #'identity))))))) (defun cider-repl-return (&optional end-of-input) "Evaluate the current input string, or insert a newline. @@ -960,21 +928,13 @@ are not balanced." (cider-repl--send-input)) ((and (get-text-property (point) 'cider-old-input) (< (point) cider-repl-input-start-mark)) - (cider-repl--grab-old-input end-of-input) - (cider-repl--recenter-if-needed)) + (cider-repl--grab-old-input end-of-input)) ((cider-repl--input-complete-p cider-repl-input-start-mark (point-max)) (cider-repl--send-input t)) (t (cider-repl-newline-and-indent) (message "[input not complete]")))) -(defun cider-repl--recenter-if-needed () - "Make sure that the point is visible." - (unless (pos-visible-in-window-p (point-max)) - (save-excursion - (goto-char (point-max)) - (recenter -1)))) - (defun cider-repl--grab-old-input (replace) "Resend the old REPL input at point. If REPLACE is non-nil the current input is replaced with the old @@ -1003,9 +963,11 @@ text property `cider-old-input'." (save-restriction (narrow-to-region cider-repl-input-start-mark (point)) (let ((matching-delimiter nil)) - (while (ignore-errors (save-excursion - (backward-up-list 1) - (setq matching-delimiter (cdr (syntax-after (point))))) t) + (while (ignore-errors + (save-excursion + (backward-up-list 1) + (setq matching-delimiter (cdr (syntax-after (point))))) + t) (insert-char matching-delimiter)))) (cider-repl-return)) @@ -1016,12 +978,6 @@ text property `cider-old-input'." (message "Pretty printing in REPL %s." (if cider-repl-use-pretty-printing "enabled" "disabled"))) -(defun cider--pretty-print-width () - "Return the width to use for pretty-printing." - (or cider-repl-pretty-print-width - fill-column - 80)) - (defun cider-repl-toggle-content-types () "Toggle content-type rendering in the REPL." (interactive) @@ -1060,35 +1016,18 @@ See also the related commands `cider-repl-clear-output' and (recenter t)) (run-hooks 'cider-repl-clear-buffer-hook)) -(defun cider-repl--end-of-output () - "Return the position at the end of the previous REPL output." - (if (eq (get-text-property (1- cider-repl-input-start-mark) 'field) - 'cider-repl-prompt) - ;; if after prompt, return eol before prompt - (previous-single-property-change cider-repl-input-start-mark - 'field nil (point-min)) - ;; else, input mark because there is no prompt (yet) - cider-repl-input-start-mark)) - (defun cider-repl-clear-output (&optional clear-repl) "Delete the output inserted since the last input. With a prefix argument CLEAR-REPL it will clear the entire REPL buffer instead." (interactive "P") (if clear-repl (cider-repl-clear-buffer) - (let ((start (save-excursion - (cider-repl-previous-prompt) - (ignore-errors (forward-sexp)) - (forward-line) - (point))) - (end (cider-repl--end-of-output))) - (when (< start end) - (let ((inhibit-read-only t)) - (cider-repl--clear-region start end) - (save-excursion - (goto-char start) - (insert - (propertize ";; output cleared" 'font-lock-face 'font-lock-comment-face)))))))) + (let ((inhibit-read-only t)) + (cider-repl--clear-region cider-repl-output-start cider-repl-output-end) + (save-excursion + (goto-char cider-repl-output-end) + (insert-before-markers + (propertize ";; output cleared\n" 'font-lock-face 'font-lock-comment-face)))))) (defun cider-repl-clear-banners () "Delete the REPL banners." @@ -1152,7 +1091,9 @@ command will prompt for the name of the namespace to switch to." (user-error "No namespace selected")) (cider-map-repls :auto (lambda (connection) - (cider-nrepl-request:eval (format "(in-ns '%s)" ns) + (cider-nrepl-request:eval (if cider-repl-require-ns-on-set + (format "(do (require '%s) (in-ns '%s))" ns ns) + (format "(in-ns '%s)" ns)) (cider-repl-switch-ns-handler connection))))) @@ -1220,17 +1161,24 @@ regexes from `cider-locref-regexp-alist' to infer locations at point." (let* ((var (plist-get loc :var)) (line (plist-get loc :line)) (file (or - ;; retrieve from info middleware + ;; 1) retrieve from info middleware (when var (or (cider-sync-request:ns-path var) (nrepl-dict-get (cider-sync-request:info var) "file"))) - ;; when not found, return the file detected by regexp (when-let* ((file (plist-get loc :file))) - (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))))))) + ;; 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))))))) (if file (cider--jump-to-loc-from-info (nrepl-dict "file" file "line" line) t) (error "No source location for %s" var))) @@ -1257,7 +1205,7 @@ One for all REPLs.") WIN, BUFFER and POS are the window, buffer and point under mouse position." (with-current-buffer buffer (if-let* ((hl (plist-get (cider-locref-at-point pos) :highlight))) - (move-overlay cider-locref-hoover-overlay (car hl) (cdr hl)) + (move-overlay cider-locref-hoover-overlay (car hl) (cdr hl) buffer) (delete-overlay cider-locref-hoover-overlay)) nil)) @@ -1501,6 +1449,8 @@ constructs." (declare-function cider-repl-history "cider-repl-history") (declare-function cider-run "cider-mode") (declare-function cider-ns-refresh "cider-ns") +(declare-function cider-ns-reload "cider-ns") +(declare-function cider-find-var "cider-find") (declare-function cider-version "cider") (declare-function cider-test-run-loaded-tests "cider-test") (declare-function cider-test-run-project-tests "cider-test") @@ -1516,6 +1466,9 @@ constructs." (cider-repl-add-shortcut "trace-ns" #'cider-toggle-trace-ns) (cider-repl-add-shortcut "undef" #'cider-undef) (cider-repl-add-shortcut "refresh" #'cider-ns-refresh) +(cider-repl-add-shortcut "reload" #'cider-ns-reload) +(cider-repl-add-shortcut "find-var" #'cider-find-var) +(cider-repl-add-shortcut "doc" #'cider-doc) (cider-repl-add-shortcut "help" #'cider-repl-shortcuts-help) (cider-repl-add-shortcut "test-ns" #'cider-test-run-ns-tests) (cider-repl-add-shortcut "test-all" #'cider-test-run-loaded-tests) @@ -1526,13 +1479,13 @@ constructs." (cider-repl-add-shortcut "test-report" #'cider-test-show-report) (cider-repl-add-shortcut "run" #'cider-run) (cider-repl-add-shortcut "conn-info" #'cider-describe-connection) -(cider-repl-add-shortcut "hasta la vista" #'cider-quit) +(cider-repl-add-shortcut "version" #'cider-version) +(cider-repl-add-shortcut "require-repl-utils" #'cider-repl-require-repl-utils) +;; So many ways to quit :-) (cider-repl-add-shortcut "adios" #'cider-quit) (cider-repl-add-shortcut "sayonara" #'cider-quit) (cider-repl-add-shortcut "quit" #'cider-quit) (cider-repl-add-shortcut "restart" #'cider-restart) -(cider-repl-add-shortcut "version" #'cider-version) -(cider-repl-add-shortcut "require-repl-utils" #'cider-repl-require-repl-utils) (defconst cider-repl-shortcuts-help-buffer "*CIDER REPL Shortcuts Help*") @@ -1737,9 +1690,6 @@ constructs." (cider-repl-wrap-fontify-function font-lock-fontify-region-function)) (setq-local font-lock-unfontify-region-function (cider-repl-wrap-fontify-function font-lock-unfontify-region-function)) - (make-local-variable 'completion-at-point-functions) - (add-to-list 'completion-at-point-functions - #'cider-complete-at-point) (set-syntax-table cider-repl-mode-syntax-table) (cider-eldoc-setup) ;; At the REPL, we define beginning-of-defun and end-of-defun to be @@ -1754,6 +1704,7 @@ constructs." (cider-repl-history-load 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) (add-hook 'paredit-mode-hook (lambda () (clojure-paredit-setup cider-repl-mode-map)))) (provide 'cider-repl) diff --git a/elpa/cider-20190121.1852/cider-resolve.el b/elpa/cider-20191027.1704/cider-resolve.el similarity index 98% rename from elpa/cider-20190121.1852/cider-resolve.el rename to elpa/cider-20191027.1704/cider-resolve.el index 7963c897..2537e91b 100644 --- a/elpa/cider-20190121.1852/cider-resolve.el +++ b/elpa/cider-20191027.1704/cider-resolve.el @@ -95,8 +95,8 @@ Return nil only if VAR cannot be resolved." (cider-resolve--get-in (or var-ns ns) "interns" name) (unless var-ns ;; If the var had no prefix, it might be referred. - (if-let* ((referal (cider-resolve--get-in ns "refers" name))) - (cider-resolve-var ns referal) + (if-let* ((referral (cider-resolve--get-in ns "refers" name))) + (cider-resolve-var ns referral) ;; Or it might be from core. (unless (equal ns "clojure.core") (cider-resolve-var "clojure.core" name))))))) diff --git a/elpa/cider-20190121.1852/cider-scratch.el b/elpa/cider-20191027.1704/cider-scratch.el similarity index 100% rename from elpa/cider-20190121.1852/cider-scratch.el rename to elpa/cider-20191027.1704/cider-scratch.el diff --git a/elpa/cider-20190121.1852/cider-selector.el b/elpa/cider-20191027.1704/cider-selector.el similarity index 86% rename from elpa/cider-20190121.1852/cider-selector.el rename to elpa/cider-20191027.1704/cider-selector.el index 61d7aed7..b0d44967 100644 --- a/elpa/cider-20190121.1852/cider-selector.el +++ b/elpa/cider-20191027.1704/cider-selector.el @@ -49,23 +49,29 @@ 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) +(defun cider-selector--recently-visited-buffer (mode &optional consider-visible-p) "Return the most recently visited buffer, deriving its `major-mode' from MODE. -Only considers buffers that are not already visible." +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)) ;; names starting with space are considered hidden by Emacs (not (string-match-p "^ " (buffer-name buffer))) - (null (get-buffer-window buffer 'visible))) + (or consider-visible-p + (null (get-buffer-window buffer 'visible)))) return buffer - finally (error "Can't find unshown buffer in %S" mode))) + finally (if consider-visible-p + (error "Can't find unshown buffer in %S" mode) + (cider-selector--recently-visited-buffer mode t)))) ;;;###autoload (defun cider-selector (&optional other-window) "Select a new buffer by type, indicated by a single character. The user is prompted for a single character indicating the method by -which to choose a new buffer. The `?' character describes then +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." (interactive) @@ -97,7 +103,7 @@ is chosen. The returned buffer is selected with `switch-to-buffer'." (let ((method `(lambda () (let ((buffer (progn ,@body))) - (cond ((not (get-buffer buffer)) + (cond ((not (and buffer (get-buffer buffer))) (message "No such buffer: %S" buffer) (ding)) ((get-buffer-window buffer) @@ -138,8 +144,10 @@ is chosen. The returned buffer is selected with (top-level)) (def-cider-selector-method ?r - "Current REPL buffer." - (cider-current-repl)) + "Current REPL buffer or as a fallback, the most recently +visited cider-repl-mode buffer." + (or (cider-current-repl) + (cider-selector--recently-visited-buffer 'cider-repl-mode))) (def-cider-selector-method ?m "Current connection's *nrepl-messages* buffer." diff --git a/elpa/cider-20190121.1852/cider-stacktrace.el b/elpa/cider-20191027.1704/cider-stacktrace.el similarity index 98% rename from elpa/cider-20190121.1852/cider-stacktrace.el rename to elpa/cider-20191027.1704/cider-stacktrace.el index 66a2820f..5d927d50 100644 --- a/elpa/cider-20190121.1852/cider-stacktrace.el +++ b/elpa/cider-20191027.1704/cider-stacktrace.el @@ -25,18 +25,19 @@ ;;; Code: -(require 'cl-lib) -(require 'cider-popup) (require 'button) +(require 'cl-lib) (require 'easymenu) -(require 'cider-common) +(require 'map) +(require 'seq) (require 'subr-x) + +(require 'cider-common) (require 'cider-compat) (require 'cider-client) +(require 'cider-popup) (require 'cider-util) -(require 'seq) - ;; Variables (defgroup cider-stacktrace nil @@ -60,20 +61,7 @@ If nil, messages will not be wrapped. If truthy but non-numeric, (make-obsolete 'cider-stacktrace-print-length 'cider-stacktrace-print-options "0.20") (make-obsolete 'cider-stacktrace-print-level 'cider-stacktrace-print-options "0.20") - -(defcustom cider-stacktrace-print-options '(dict "length" 50 "level" 50) - "Set the maximum length of sequences in displayed cause data. - -This sets the value of Clojure's `*print-length*` when pretty printing the -`ex-data` map for exception causes in the stacktrace that are instances of -`IExceptionInfo`. - -Be advised that setting \"print-length\" to `nil` will cause the attempted -printing of infinite data structures and that setting \"print-level\" to -nil cause the attempted printing of cyclical data structures." - :type 'listp - :group 'cider-stacktrace - :package-version '(cider . "0.20.0")) +(make-obsolete-variable 'cider-stacktrace-print-options 'cider-print-options "0.21") (defvar cider-stacktrace-detail-max 2 "The maximum detail level for causes.") @@ -665,7 +653,7 @@ others." "Report bug to the CIDER team.")) (insert "`.\n\n") (insert "\ - If these stacktraces are occuring frequently, consider using the + If these stacktraces are occurring frequently, consider using the button(s) below to suppress these types of errors for the duration of your current CIDER session. The stacktrace buffer will still be generated, but it will \"pop under\" your current buffer instead of diff --git a/elpa/cider-20190121.1852/cider-test.el b/elpa/cider-20191027.1704/cider-test.el similarity index 98% rename from elpa/cider-20190121.1852/cider-test.el rename to elpa/cider-20191027.1704/cider-test.el index 8549ac3a..36fba1a3 100644 --- a/elpa/cider-20190121.1852/cider-test.el +++ b/elpa/cider-20191027.1704/cider-test.el @@ -28,19 +28,20 @@ ;;; Code: +(require 'button) +(require 'cl-lib) +(require 'easymenu) +(require 'map) +(require 'seq) +(require 'subr-x) + (require 'cider-common) (require 'cider-client) (require 'cider-popup) (require 'cider-stacktrace) -(require 'subr-x) (require 'cider-compat) (require 'cider-overlays) -(require 'button) -(require 'cl-lib) -(require 'easymenu) -(require 'seq) - ;;; Variables (defgroup cider-test nil @@ -137,7 +138,7 @@ Add to this list to have CIDER recognize additional test defining macros." ;; Duplicates of keys below with C- for convenience (define-key map (kbd "C-r") #'cider-test-rerun-failed-tests) (define-key map (kbd "C-t") #'cider-test-run-test) - (define-key map (kbd "C-g") #'cider-test-rerun-test) + (define-key map (kbd "C-a") #'cider-test-rerun-test) (define-key map (kbd "C-n") #'cider-test-run-ns-tests) (define-key map (kbd "C-s") #'cider-test-run-ns-tests-with-filters) (define-key map (kbd "C-l") #'cider-test-run-loaded-tests) @@ -146,7 +147,7 @@ Add to this list to have CIDER recognize additional test defining macros." ;; 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) - (define-key map (kbd "g") #'cider-test-rerun-test) + (define-key map (kbd "a") #'cider-test-rerun-test) (define-key map (kbd "n") #'cider-test-run-ns-tests) (define-key map (kbd "s") #'cider-test-run-ns-tests-with-filters) (define-key map (kbd "l") #'cider-test-run-loaded-tests) @@ -278,14 +279,14 @@ prompt and whether to use a new window. Similar to `cider-find-var'." "Display stacktrace for the erring NS VAR test with the assertion INDEX." (let (causes) (cider-nrepl-send-request - (nconc `("op" "test-stacktrace" - "ns" ,ns - "var" ,var - "index" ,index) - (when (cider--pprint-fn) - `("pprint-fn" ,(cider--pprint-fn))) - (when cider-stacktrace-print-options - `("print-options" ,cider-stacktrace-print-options))) + (thread-last + (map-merge 'list + `(("op" "test-stacktrace") + ("ns" ,ns) + ("var" ,var) + ("index" ,index)) + (cider--nrepl-print-request-map fill-column)) + (seq-mapcat #'identity)) (lambda (response) (nrepl-dbind-response response (class status) (cond (class (setq causes (cons response causes))) @@ -558,7 +559,6 @@ The optional arg TEST denotes an individual test name." (defun cider-find-var-file (ns var) "Return the buffer visiting the file in which the NS VAR is defined. Or nil if not found." - (cider-ensure-op-supported "info") (when-let* ((info (cider-var-info (concat ns "/" var))) (file (nrepl-dict-get info "file"))) (cider-find-file file))) diff --git a/elpa/cider-20190121.1852/cider-tracing.el b/elpa/cider-20191027.1704/cider-tracing.el similarity index 100% rename from elpa/cider-20190121.1852/cider-tracing.el rename to elpa/cider-20191027.1704/cider-tracing.el diff --git a/elpa/cider-20190121.1852/cider-util.el b/elpa/cider-20191027.1704/cider-util.el similarity index 99% rename from elpa/cider-20190121.1852/cider-util.el rename to elpa/cider-20191027.1704/cider-util.el index c5a09634..989adca4 100644 --- a/elpa/cider-20190121.1852/cider-util.el +++ b/elpa/cider-20191027.1704/cider-util.el @@ -129,7 +129,8 @@ Ignores the REPL prompt. If LOOK-BACK is non-nil, move backwards trying to find a symbol if there isn't one at point." (or (when-let* ((str (thing-at-point 'symbol))) (unless (text-property-any 0 (length str) 'field 'cider-repl-prompt str) - (substring-no-properties str))) + ;; Remove font-locking and trailing . from constructors like Record. + (string-remove-suffix "." (substring-no-properties str)))) (when look-back (save-excursion (ignore-errors @@ -404,14 +405,14 @@ plugin or dependency with: (defvar cider-version) -(defconst cider-manual-url "https://docs.cider.mx/en/%s/" +(defconst cider-manual-url "https://docs.cider.mx/cider/%s" "The URL to CIDER's manual.") (defun cider--manual-version () "Convert the version to a ReadTheDocs-friendly version." (if (string-match-p "-snapshot" cider-version) - "latest" - "stable")) + "" + (concat cider-version "/"))) (defun cider-manual-url () "The CIDER manual's url." diff --git a/elpa/cider-20191027.1704/cider-xref.el b/elpa/cider-20191027.1704/cider-xref.el new file mode 100644 index 00000000..530b0d50 --- /dev/null +++ b/elpa/cider-20191027.1704/cider-xref.el @@ -0,0 +1,183 @@ +;;; cider-xref.el --- Xref functionality for Clojure -*- lexical-binding: t -*- + +;; Copyright © 2019 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: + +;; Xref (find usages) functionality for Clojure. The implementation is based on +;; ideas from this article https://metaredux.com/posts/2019/05/04/discovering-runtime-function-references-in-clojure.html. +;; +;; Keep in mind that you won't get references in namespaces that haven't been loaded yet. + +;;; Code: + +(require 'cider-doc) +(require 'cider-util) +(require 'subr-x) +(require 'cider-compat) + +(require 'cider-client) +(require 'cider-popup) +(require 'nrepl-dict) + +(require 'clojure-mode) +(require 'apropos) +(require 'button) + +(defconst cider-xref-buffer "*cider-xref*") + +(defcustom cider-xref-actions '(("display-doc" . cider-doc-lookup) + ("find-def" . cider--find-var) + ("lookup-on-clojuredocs" . cider-clojuredocs-lookup)) + "Controls the actions to be applied on the symbol found by an xref search. +The first action key in the list will be selected as default. If the list +contains only one action key, the associated action function will be +applied automatically. An action function can be any function that receives +the symbol found by the xref search as argument." + :type '(alist :key-type string :value-type function) + :group 'cider + :package-version '(cider . "0.22.0")) + +(defun cider-xref-doc (button) + "Display documentation for the symbol represented at BUTTON." + (cider-doc-lookup (button-get button 'apropos-symbol))) + +(defun cider-xref-result (result) + "Emit a RESULT into current buffer." + (let ((var-name (nrepl-dict-get result "name"))) + (cider-propertize-region (list 'apropos-symbol var-name + '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))) + (insert "\n") + (if-let* ((file (nrepl-dict-get result "file")) + (line (nrepl-dict-get result "line"))) + (progn + (insert (propertize var-name + 'font-lock-face 'font-lock-function-name-face) + " is defined in ") + (insert-text-button (cider--abbreviate-file-protocol file) + 'follow-link t + 'action (lambda (_x) + (cider-xref-source file line var-name))) + (insert ".")) + (insert "Definition location unavailable.")) + (insert "\n"))) + +(defun cider-xref-source (file line name) + "Find source for FILE, LINE and NAME." + (interactive) + (if file + (if-let* ((buffer (and (not (cider--tooling-file-p file)) + (cider-find-file file)))) + (cider-jump-to buffer (if line + (cons line nil) + name) + nil) + (user-error + (substitute-command-keys + "Can't find the source because it wasn't defined with `cider-eval-buffer'"))) + (error "No source location for %s" name))) + +(declare-function cider-mode "cider-mode") + +(defun cider-show-xref (summary results) + "Show SUMMARY and RESULTS in a pop-up buffer." + (with-current-buffer (cider-popup-buffer cider-xref-buffer 'select 'apropos-mode 'ancillary) + (let ((inhibit-read-only t)) + (if (boundp 'header-line-format) + (setq-local header-line-format summary) + (insert summary "\n\n")) + (dolist (result results) + (cider-xref-result result)) + (goto-char (point-min))))) + +;;;###autoload +(defun cider-xref-fn-refs (&optional ns symbol) + "Show all functions that reference the var matching NS and SYMBOL." + (interactive) + (cider-ensure-connected) + (cider-ensure-op-supported "fn-refs") + (if-let* ((ns (or ns (cider-current-ns))) + (symbol (or symbol (cider-symbol-at-point))) + (results (cider-sync-request:fn-refs ns symbol))) + (cider-show-xref (format "Showing %d functions that reference %s in currently loaded namespaces" (length results) symbol) results) + (message "No references found for %S in currently loaded namespaces" symbol))) + +;;;###autoload +(defun cider-xref-fn-deps (&optional ns symbol) + "Show all functions referenced by the var matching NS and SYMBOL." + (interactive) + (cider-ensure-connected) + (cider-ensure-op-supported "fn-deps") + (if-let* ((ns (or ns (cider-current-ns))) + (symbol (or symbol (cider-symbol-at-point))) + (results (cider-sync-request:fn-deps ns symbol))) + (cider-show-xref (format "Showing %d function dependencies for %s" (length results) symbol) results) + (message "No dependencies found for %S" symbol))) + +(defun cider-xref-act-on-symbol (symbol) + "Apply selected action on SYMBOL." + (let* ((first-action-key (car (car cider-xref-actions))) + (action-key (if (= 1 (length cider-xref-actions)) + first-action-key + (completing-read (format "Choose action to apply to `%s` (default %s): " + symbol first-action-key) + cider-xref-actions nil nil nil nil first-action-key))) + (action-fn (cdr (assoc action-key cider-xref-actions)))) + (if action-fn + (funcall action-fn symbol) + (user-error "Unknown action `%s`" action-key)))) + +;;;###autoload +(defun cider-xref-fn-refs-select (&optional ns symbol) + "Displays the references for NS and SYMBOL using completing read." + (interactive) + (cider-ensure-connected) + (cider-ensure-op-supported "fn-refs") + (if-let* ((ns (or ns (cider-current-ns))) + (symbol (or symbol (cider-symbol-at-point))) + (results (mapcar (lambda (d) (nrepl-dict-get d "name")) (cider-sync-request:fn-refs ns symbol))) + (summary (format "References for %s" symbol))) + (cider-xref-act-on-symbol (completing-read (concat summary ": ") results)) + (message "No references for %S found" symbol))) + +;;;###autoload +(defun cider-xref-fn-deps-select (&optional ns symbol) + "Displays the function dependencies for NS and SYMBOL using completing read." + (interactive) + (cider-ensure-connected) + (cider-ensure-op-supported "fn-deps") + (if-let* ((ns (or ns (cider-current-ns))) + (symbol (or symbol (cider-symbol-at-point))) + (results (mapcar (lambda (d) (nrepl-dict-get d "name")) (cider-sync-request:fn-deps ns symbol))) + (summary (format "Dependencies for %s" symbol))) + (cider-xref-act-on-symbol (completing-read (concat summary ": ") results)) + (message "No dependencies for %S found" symbol))) + +(provide 'cider-xref) + +;;; cider-xref.el ends here diff --git a/elpa/cider-20190121.1852/cider.el b/elpa/cider-20191027.1704/cider.el similarity index 89% rename from elpa/cider-20190121.1852/cider.el rename to elpa/cider-20191027.1704/cider.el index 3727b395..4d7839a0 100644 --- a/elpa/cider-20190121.1852/cider.el +++ b/elpa/cider-20191027.1704/cider.el @@ -11,8 +11,8 @@ ;; Steve Purcell ;; Maintainer: Bozhidar Batsov ;; URL: http://www.github.com/clojure-emacs/cider -;; Version: 0.21.0-snapshot -;; Package-Requires: ((emacs "25") (clojure-mode "5.9") (pkg-info "0.4") (queue "0.2") (spinner "1.7") (seq "2.16") (sesman "0.3.2")) +;; Version: 0.24.0-snapshot +;; Package-Requires: ((emacs "25") (clojure-mode "5.9") (parseedn "0.1") (pkg-info "0.4") (queue "0.2") (spinner "1.7") (seq "2.16") (sesman "0.3.2")) ;; Keywords: languages, clojure, cider ;; This program is free software: you can redistribute it and/or modify @@ -67,7 +67,8 @@ :prefix "cider-" :group 'applications :link '(url-link :tag "GitHub" "https://github.com/clojure-emacs/cider") - :link '(url-link :tag "Online Manual" "https://docs.cider.mx") + :link '(url-link :tag "Homepage" "https://cider.mx") + :link '(url-link :tag "Documentation" "https://docs.cider.mx") :link '(emacs-commentary-link :tag "Commentary" "cider")) (require 'cider-client) @@ -86,12 +87,12 @@ (require 'seq) (require 'sesman) -(defconst cider-version "0.21.0-snapshot" +(defconst cider-version "0.24.0-snapshot" "Fallback version used when it cannot be extracted automatically. Normally it won't be used, unless `pkg-info' fails to extract the version from the CIDER package or library.") -(defconst cider-codename "New York" +(defconst cider-codename "Lima" "Codename used to denote stable releases.") (defcustom cider-lein-command @@ -130,7 +131,7 @@ version from the CIDER package or library.") :package-version '(cider . "0.14.0")) (defcustom cider-boot-parameters - "cider.tasks/nrepl-server -b localhost wait" + "repl -s -b localhost wait" "Params passed to boot to start an nREPL server via `cider-jack-in'." :type 'string :group 'cider @@ -138,10 +139,14 @@ version from the CIDER package or library.") :package-version '(cider . "0.9.0")) (defcustom cider-clojure-cli-command - "clojure" + (if (and (eq system-type 'windows-nt) + (null (executable-find "clojure"))) + "powershell" + "clojure") "The command used to execute clojure with tools.deps (requires Clojure 1.9+). -Don't use clj here, as it doesn't work when spawned from Emacs due to -it using rlwrap." +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\"." :type 'string :group 'cider :safe #'stringp @@ -377,13 +382,13 @@ Throws an error if PROJECT-TYPE is unknown." ;; We inject the newest known version of nREPL just in case ;; your version of Boot or Leiningen is bundling an older one. (cider-add-to-alist 'cider-jack-in-dependencies - "nrepl" "0.5.3") + "nrepl" "0.6.0") (defvar cider-jack-in-cljs-dependencies nil "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.3.10") +(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.4.2") (defvar cider-jack-in-dependencies-exclusions nil "List of exclusions for jack in dependencies. @@ -399,11 +404,8 @@ Elements of the list are artifact name and list of exclusions to apply for the a (defconst cider-latest-clojure-version "1.10.0" "Latest supported version of Clojure.") -(defconst cider-required-middleware-version "0.20.0" - "The minimum CIDER nREPL version that's known to work properly with CIDER.") - -(defconst cider-latest-middleware-version "0.20.0" - "The latest CIDER nREPL version that's known to work properly with CIDER.") +(defconst cider-required-middleware-version "0.23.0-SNAPSHOT" + "The CIDER nREPL version that's known to work properly with CIDER.") (defcustom cider-jack-in-auto-inject-clojure nil "Version of clojure to auto-inject into REPL. @@ -432,7 +434,7 @@ that extend CIDER, not for users. For example, a refactoring package might want to inject some middleware only when within a project context.)") (put 'cider-jack-in-lein-plugins 'risky-local-variable t) (cider-add-to-alist 'cider-jack-in-lein-plugins - "cider/cider-nrepl" cider-latest-middleware-version) + "cider/cider-nrepl" cider-required-middleware-version) (defvar cider-jack-in-cljs-lein-plugins nil "List of Leiningen plugins to be injected at jack-in. @@ -649,13 +651,13 @@ Generally you should not disable this unless you run into some faulty check." (defun cider-verify-clojurescript-is-present () "Check whether ClojureScript is present." - (unless (cider-library-present-p "clojure/clojurescript") - (user-error "ClojureScript is not available. See https://docs.cider.mx/en/latest/clojurescript for details"))) + (unless (cider-library-present-p "cljs.core") + (user-error "ClojureScript is not available. See https://docs.cider.mx/cider/basics/clojurescript for details"))) (defun cider-verify-piggieback-is-present () "Check whether the piggieback middleware is present." - (unless (cider-library-present-p "cider/piggieback") - (user-error "Piggieback 0.3.x (aka cider/piggieback) is not available. See https://docs.cider.mx/en/latest/clojurescript for details"))) + (unless (cider-library-present-p "cider.piggieback") + (user-error "Piggieback 0.4.x (aka cider/piggieback) is not available. See https://docs.cider.mx/cider/basics/clojurescript for details"))) (defun cider-check-nashorn-requirements () "Check whether we can start a Nashorn ClojureScript REPL." @@ -670,38 +672,39 @@ Generally you should not disable this unless you run into some faulty check." (defun cider-check-figwheel-requirements () "Check whether we can start a Figwheel ClojureScript REPL." (cider-verify-piggieback-is-present) - (unless (cider-library-present-p "figwheel-sidecar/figwheel-sidecar") - (user-error "Figwheel-sidecar is not available. Please check https://docs.cider.mx/en/latest/clojurescript"))) + (unless (cider-library-present-p "figwheel-sidecar.repl") + (user-error "Figwheel-sidecar is not available. Please check https://docs.cider.mx/cider/basics/clojurescript for details"))) (defun cider-check-figwheel-main-requirements () "Check whether we can start a Figwheel ClojureScript REPL." (cider-verify-piggieback-is-present) - (unless (cider-library-present-p "bhauman/figwheel-main") - (user-error "Figwheel-main is not available. Please check https://docs.cider.mx/en/latest/clojurescript"))) + (unless (cider-library-present-p "figwheel.main") + (user-error "Figwheel-main is not available. Please check https://docs.cider.mx/cider/basics/clojurescript for details"))) (defun cider-check-weasel-requirements () "Check whether we can start a Weasel ClojureScript REPL." (cider-verify-piggieback-is-present) - (unless (cider-library-present-p "weasel/weasel") - (user-error "Weasel in not available. Please check https://docs.cider.mx/en/latest/clojurescript/#browser-connected-clojurescript-repl"))) + (unless (cider-library-present-p "weasel.repl.server") + (user-error "Weasel in not available. Please check https://docs.cider.mx/cider/basics/clojurescript/#browser-connected-clojurescript-repl for details"))) (defun cider-check-boot-requirements () "Check whether we can start a Boot ClojureScript REPL." (cider-verify-piggieback-is-present) - (unless (cider-library-present-p "adzerk/boot-cljs-repl") - (user-error "The Boot ClojureScript REPL is not available. Please check https://github.com/adzerk-oss/boot-cljs-repl/blob/master/README.md"))) + (unless (cider-library-present-p "adzerk.boot-cljs-repl") + (user-error "The Boot ClojureScript REPL is not available. Please check https://github.com/adzerk-oss/boot-cljs-repl/blob/master/README.md for details"))) (defun cider-check-shadow-cljs-requirements () "Check whether we can start a shadow-cljs REPL." - (unless (cider-library-present-p "thheller/shadow-cljs") - (user-error "The shadow-cljs ClojureScript REPL is not available"))) + (unless (cider-library-present-p "shadow.cljs.devtools.api") + (user-error "The shadow-cljs ClojureScript REPL is not available. Please check https://docs.cider.mx/cider/basics/clojurescript for details"))) (defun cider-normalize-cljs-init-options (options) "Normalize the OPTIONS string used for initializing a ClojureScript REPL." (if (or (string-prefix-p "{" options) (string-prefix-p "(" options) (string-prefix-p "[" options) - (string-prefix-p ":" options)) + (string-prefix-p ":" options) + (string-prefix-p "\"" options)) options (concat ":" options))) @@ -711,13 +714,32 @@ Generally you should not disable this unless you run into some faulty check." :safe (lambda (s) (or (null s) (stringp s))) :package-version '(cider . "0.18.0")) +(defun cider--shadow-parse-builds (hash) + "Parses the build names of a shadow-cljs.edn HASH map. +The default options of `browser-repl' and `node-repl' are also included." + (let* ((builds (when (hash-table-p hash) + (gethash :builds hash))) + (build-keys (when (hash-table-p builds) + (hash-table-keys builds)))) + (append build-keys '(browser-repl node-repl)))) + +(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) + (with-temp-buffer + (insert-file-contents shadow-edn) + (let ((hash (car (parseedn-read '((shadow/env . identity)))))) + (cider--shadow-parse-builds hash)))))) + (defun cider-shadow-select-cljs-init-form () "Generate the init form for a shadow-cljs select-only REPL. We have to prompt the user to select a build, that's why this is a command, not just a string." (let ((form "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s))") (options (or cider-shadow-default-options - (read-from-minibuffer "Select shadow-cljs build (e.g. dev): ")))) + (completing-read "Select shadow-cljs build: " + (cider--shadow-get-builds))))) (format form (cider-normalize-cljs-init-options options)))) (defun cider-shadow-cljs-init-form () @@ -726,7 +748,8 @@ We have to prompt the user to select a build, that's why this is a command, not just a string." (let* ((form "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch %s) (shadow/nrepl-select %s))") (options (or cider-shadow-default-options - (read-from-minibuffer "Select shadow-cljs build (e.g. dev): "))) + (completing-read "Select shadow-cljs build: " + (cider--shadow-get-builds)))) (build (cider-normalize-cljs-init-options options))) (format form build build))) @@ -739,23 +762,50 @@ Figwheel for details." :safe (lambda (s) (or (null s) (stringp s))) :package-version '(cider . "0.18.0")) +(defun cider--figwheel-main-get-builds () + "Extract build names from the .cljs.edn config files in the project root." + (when-let ((project-dir (clojure-project-dir))) + (let ((builds (directory-files project-dir nil ".*\\.cljs\\.edn"))) + (mapcar (lambda (f) (string-match "^\\(.*\\)\\.cljs\\.edn" f) + (match-string 1 f)) builds)))) + (defun cider-figwheel-main-init-form () "Produce the figwheel-main ClojureScript init form." (let ((form "(do (require 'figwheel.main) (figwheel.main/start %s))") - (options (string-trim - (or cider-figwheel-main-default-options - (read-from-minibuffer "Select figwheel-main build (e.g. :dev): "))))) - (format form (cider-normalize-cljs-init-options options)))) + (builds (cider--figwheel-main-get-builds))) + (cond + (cider-figwheel-main-default-options + (format form (cider-normalize-cljs-init-options (string-trim cider-figwheel-main-default-options)))) + + (builds + (format form (cider-normalize-cljs-init-options (completing-read "Select figwheel-main build: " builds)))) + + (t (user-error "No figwheel-main build files (.cljs.edn) were found"))))) + +(defcustom cider-custom-cljs-repl-init-form nil + "The form used to start a custom ClojureScript REPL. +When set it becomes the return value of the `cider-custom-cljs-repl-init-form' +function, which normally prompts for the init form. + +This defcustom is mostly intended for use with .dir-locals.el for +cases where it doesn't make sense to register a new ClojureScript REPL type." + :type 'string + :safe (lambda (s) (or (null s) (stringp s))) + :package-version '(cider . "0.23.0")) (defun cider-custom-cljs-repl-init-form () - "Prompt for a form that would start a ClojureScript REPL. + "The form used to start a custom ClojureScript REPL. +Defaults to the value of `cider-custom-cljs-repl-init-form'. +If it's nil the function will prompt for a form. The supplied string will be wrapped in a do form if needed." - (let ((form (read-from-minibuffer "Please, provide a form to start a ClojureScript REPL: "))) - ;; TODO: We should probably make this more robust (e.g. by using a regexp or - ;; parsing the form). - (if (string-prefix-p "(do" form) - form - (format "(do %s)" form)))) + (or + cider-custom-cljs-repl-init-form + (let ((form (read-from-minibuffer "Please, provide a form to start a ClojureScript REPL: "))) + ;; TODO: We should probably make this more robust (e.g. by using a regexp or + ;; parsing the form). + (if (string-prefix-p "(do" form) + form + (format "(do %s)" form))))) (defvar cider-cljs-repl-types '((nashorn "(do (require 'cljs.repl.nashorn) (cider.piggieback/cljs-repl (cljs.repl.nashorn/repl-env)))" @@ -763,6 +813,8 @@ The supplied string will be wrapped in a do form if needed." (figwheel "(do (require 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/start-figwheel!) (figwheel-sidecar.repl-api/cljs-repl))" cider-check-figwheel-requirements) (figwheel-main cider-figwheel-main-init-form cider-check-figwheel-main-requirements) + (figwheel-connected "(figwheel-sidecar.repl-api/cljs-repl)" + cider-check-figwheel-requirements) (node "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))" cider-check-node-requirements) (weasel "(do (require 'weasel.repl.websocket) (cider.piggieback/cljs-repl (weasel.repl.websocket/repl-env :ip \"127.0.0.1\" :port 9001)))" @@ -923,7 +975,8 @@ nil." (defun cider-jack-in-clj (params) "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, prompt for all these parameters." +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) @@ -940,7 +993,8 @@ With the prefix argument, prompt for all these parameters." "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, -prompt for all these parameters." +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)) (cider-jack-in-lein-plugins (append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins)) @@ -963,8 +1017,9 @@ prompt for all these parameters." "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, -prompt for all these parameters. When SOFT-CLJS-START is non-nil, start -cljs REPL only when the ClojureScript dependencies are met." +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)) (cider-jack-in-lein-plugins (append cider-jack-in-lein-plugins cider-jack-in-cljs-lein-plugins)) @@ -1103,9 +1158,9 @@ non-nil, don't start if ClojureScript requirements are not met." (defun cider--update-do-prompt (params) "Update :do-prompt in PARAMS." - (if (equal params '(4)) - (list :do-prompt t) - params)) + (cond ((equal params '(4)) (list :edit-jack-in-command t)) + ((equal params '(16)) (list :do-prompt t)) + (t params))) (defun cider--update-project-dir (params) "Update :project-dir in PARAMS." @@ -1154,6 +1209,19 @@ non-nil, don't start if ClojureScript requirements are not met." (or inferred-type (cider-select-cljs-repl))))))) +(defcustom cider-edit-jack-in-command nil + "When truthy allow the user to edit the command." + :type 'boolean + :safe #'booleanp + :version '(cider . "0.22.0")) + +(defun cider--powershell-encode-command (cmd-params) + "Base64 encode the powershell command and jack-in CMD-PARAMS for clojure-cli." + (let* ((quoted-params (replace-regexp-in-string "\"" "\"\"" cmd-params)) + (command (format "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--update-jack-in-cmd (params) "Update :jack-in-cmd key in PARAMS." (let* ((params (cider--update-do-prompt params)) @@ -1179,8 +1247,13 @@ non-nil, don't start if ClojureScript requirements are not met." (and (null project-dir) (eq cider-allow-jack-in-without-project 'warn) (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 cmd-params))) - (plist-put params :jack-in-cmd cmd))) + (let ((cmd (format "%s %s" command-resolved (if (string-equal command "powershell") + (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 t) + cmd)))) (user-error "`cider-jack-in' is not allowed without a Clojure project")))) (user-error "The %s executable isn't on your `exec-path'" command)))) @@ -1249,21 +1322,21 @@ canceled the action, signal quit." ;;;###autoload (defalias 'cider-jack-in #'cider-jack-in-clj) ;;;###autoload -(defalias 'cider-jack-in-clojure #'cider-jack-in-clj) +(define-obsolete-function-alias 'cider-jack-in-clojure 'cider-jack-in-clj "0.22") ;;;###autoload -(defalias 'cider-jack-in-clojurescript #'cider-jack-in-cljs) +(define-obsolete-function-alias 'cider-jack-in-clojurescript 'cider-jack-in-cljs "0.22") ;;;###autoload (defalias 'cider-connect #'cider-connect-clj) ;;;###autoload -(defalias 'cider-connect-clojure #'cider-connect-clj) +(define-obsolete-function-alias 'cider-connect-clojure 'cider-connect-clj "0.22") ;;;###autoload -(defalias 'cider-connect-clojurescript #'cider-connect-cljs) +(define-obsolete-function-alias 'cider-connect-clojurescript 'cider-connect-cljs "0.22") ;;;###autoload -(defalias 'cider-connect-sibling-clojure #'cider-connect-sibling-clj) +(define-obsolete-function-alias 'cider-connect-sibling-clojure 'cider-connect-sibling-clj "0.22") ;;;###autoload -(defalias 'cider-connect-sibling-clojurescript #'cider-connect-sibling-cljs) +(define-obsolete-function-alias 'cider-connect-sibling-clojurescript 'cider-connect-sibling-cljs "0.22") ;;; Helpers diff --git a/elpa/cider-20190121.1852/nrepl-client.el b/elpa/cider-20191027.1704/nrepl-client.el similarity index 98% rename from elpa/cider-20190121.1852/nrepl-client.el rename to elpa/cider-20191027.1704/nrepl-client.el index 85b78c61..fa0b6cac 100644 --- a/elpa/cider-20190121.1852/nrepl-client.el +++ b/elpa/cider-20191027.1704/nrepl-client.el @@ -108,11 +108,6 @@ :type 'hook :group 'nrepl) -(defcustom nrepl-file-loaded-hook nil - "List of functions to call when a load file has completed." - :type 'hook - :group 'nrepl) - (defcustom nrepl-force-ssh-for-remote-hosts nil "If non-nil, do not attempt a direct connection for remote hosts." :type 'boolean @@ -175,7 +170,7 @@ To be used for tooling calls (i.e. completion, eldoc, etc)") "Version information received from the describe op.") (defvar-local nrepl-aux nil - "Auxillary information received from the describe op.") + "Auxiliary information received from the describe op.") ;;; nREPL Buffer Names @@ -326,10 +321,7 @@ object is a root list or dict." (goto-char end) ;; normalise any platform-specific newlines (let* ((original (buffer-substring-no-properties beg end)) - ;; handle both \n\r and \r\n - (result (replace-regexp-in-string "\r\n\\|\n\r" "\n" original)) - ;; we don't handle single carriage returns, insert newline - (result (replace-regexp-in-string "\r" "\n" result))) + (result (replace-regexp-in-string "\r\n\\|\n\r\\|\r" "\n" original))) (cons nil (nrepl--push result stack)))))) ;; integer ((looking-at "i\\(-?[0-9]+\\)e") @@ -379,7 +371,9 @@ containing the remainder of the input strings which could not be decoded. RESPONSE-Q is the original queue with successfully decoded messages enqueued and with slot STUB containing a nested stack of an incompletely decoded message or nil if the strings were completely decoded." - (with-temp-buffer + (with-current-buffer (get-buffer-create " *nrepl-decoding*") + (fundamental-mode) + (erase-buffer) (if (queue-p string-q) (while (queue-head string-q) (insert (queue-dequeue string-q))) @@ -400,6 +394,7 @@ decoded message or nil if the strings were completely decoded." (setf (nrepl-response-queue-stub response-q) (cdr istack)) (queue-enqueue response-q (cadr istack)) (setf (nrepl-response-queue-stub response-q) nil)) + (erase-buffer) (cons string-q response-q)))) (defun nrepl-bencode (object) @@ -741,7 +736,8 @@ to the REPL." (defun nrepl-make-response-handler (buffer value-handler stdout-handler stderr-handler done-handler &optional eval-error-handler - content-type-handler) + content-type-handler + truncated-handler) "Make a response handler for connection BUFFER. A handler is a function that takes one argument - response received from the server process. The response is an alist that contains at least 'id' @@ -754,8 +750,8 @@ example, if 'value' key is present, the response is of type 'value', if Depending on the type, the handler dispatches the appropriate value to one of the supplied handlers: VALUE-HANDLER, STDOUT-HANDLER, STDERR-HANDLER, -DONE-HANDLER, EVAL-ERROR-HANDLER and -CONTENT-TYPE-HANDLER. +DONE-HANDLER, EVAL-ERROR-HANDLER, CONTENT-TYPE-HANDLER, and +TRUNCATED-HANDLER. Handlers are functions of the buffer and the value they handle, except for the optional CONTENT-TYPE-HANDLER which should be a function of the buffer, @@ -787,6 +783,10 @@ the corresponding type of response." (when stderr-handler (funcall stderr-handler buffer err))) (status + (when (and truncated-handler (member "nrepl.middleware.print/truncated" status)) + (let ((warning (format "\n... output truncated to %sB ..." + (file-size-human-readable cider-print-quota)))) + (funcall truncated-handler buffer warning))) (when (member "notification" status) (nrepl-dbind-response response (msg type) (nrepl-notify msg type))) @@ -1020,7 +1020,7 @@ been determined." (set-process-filter serv-proc 'nrepl-server-filter) (set-process-sentinel serv-proc 'nrepl-server-sentinel) (set-process-coding-system serv-proc 'utf-8-unix 'utf-8-unix) - (message "[nREPL] Starting server via %s..." + (message "[nREPL] Starting server via %s" (propertize cmd 'face 'font-lock-keyword-face)) serv-proc))) diff --git a/elpa/cider-20190121.1852/nrepl-dict.el b/elpa/cider-20191027.1704/nrepl-dict.el similarity index 97% rename from elpa/cider-20190121.1852/nrepl-dict.el rename to elpa/cider-20191027.1704/nrepl-dict.el index d77aa608..efa35a6c 100644 --- a/elpa/cider-20190121.1852/nrepl-dict.el +++ b/elpa/cider-20191027.1704/nrepl-dict.el @@ -38,6 +38,12 @@ "Create nREPL dict from KEY-VALS." (cons 'dict key-vals)) +(defun nrepl-dict-from-hash (hash) + "Create nREPL dict from HASH." + (let ((dict (nrepl-dict))) + (maphash (lambda (k v) (nrepl-dict-put dict k v)) hash) + dict)) + (defun nrepl-dict-p (object) "Return t if OBJECT is an nREPL dict." (and (listp object) -- 2.47.3