[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-clojure be3e2e7 195/313: Introduce inf-clojure-reload
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-clojure be3e2e7 195/313: Introduce inf-clojure-reload |
Date: |
Wed, 11 Aug 2021 10:00:15 -0400 (EDT) |
branch: elpa/inf-clojure
commit be3e2e7c5ec9302cf1a7d5e39defc2ecc78bd9de
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Introduce inf-clojure-reload
It will evaluate (require 'ns :reload) or (require 'ns :reload-all) at the
REPL, depending on the arguments passed in. This works only from source
buffers at the moment (like all the other namespace commands).
---
CHANGELOG.md | 1 +
README.md | 1 +
inf-clojure.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87b78fe..31e1fa2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
* [#125](https://github.com/clojure-emacs/inf-clojure/pull/125): Avoid
throwing an error for frequent operations like completion.
* [#130](https://github.com/clojure-emacs/inf-clojure/pull/130): Support
loading directory locals in our buffers.
* [#129](https://github.com/clojure-emacs/inf-clojure/pull/129): Improve the
completion bounds detection (now with keywords).
+* [#132](https://github.com/clojure-emacs/inf-clojure/pull/132): Introduce
inf-clojure-reload.
### Bugs Fixed
diff --git a/README.md b/README.md
index 16f78b1..23fa630 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,7 @@ Clojure(Script) development:
* ElDoc
* Apropos
* Macroexpansion
+* Require `:reload`/`:reload-all`
* Support connecting to socket REPLs
* Support for Lumo
* Support for Planck
diff --git a/inf-clojure.el b/inf-clojure.el
index 382f223..385b149 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -131,6 +131,7 @@ mode. Default is whitespace followed by 0 or 1
single-letter colon-keyword
(define-key map "\C-c\C-c" #'inf-clojure-eval-defun) ; SLIME/CIDER
style
(define-key map "\C-c\C-b" #'inf-clojure-eval-buffer)
(define-key map "\C-c\C-r" #'inf-clojure-eval-region)
+ (define-key map "\C-c\M-r" #'inf-clojure-reload)
(define-key map "\C-c\C-n" #'inf-clojure-eval-form-and-next)
(define-key map "\C-c\C-z" #'inf-clojure-switch-to-repl)
(define-key map "\C-c\C-i" #'inf-clojure-show-ns-vars)
@@ -152,6 +153,7 @@ mode. Default is whitespace followed by 0 or 1
single-letter colon-keyword
["Eval buffer" inf-clojure-eval-buffer t]
"--"
["Load file..." inf-clojure-load-file t]
+ ["Reload file... " inf-clojure-reload t]
"--"
["Switch to REPL" inf-clojure-switch-to-repl t]
["Set REPL ns" inf-clojure-set-ns t]
@@ -372,6 +374,48 @@ If you are using REPL types, it will pickup the most
appropriate
(`planck inf-clojure-load-form-planck)
(_ inf-clojure-load-form)))
+(defcustom inf-clojure-reload-form "(require '\"%s\" :reload)"
+ "Format-string for building a Clojure expression to reload a file.
+Reload forces loading of all the identified libs even if they are
+already loaded.
+This format string should use `%s' to substitute a namespace and
+should result in a Clojure form that will be sent to the inferior
+Clojure to load that file."
+ :type 'string
+ :safe #'stringp
+ :package-version '(inf-clojure . "2.2.0"))
+
+;; :reload forces loading of all the identified libs even if they are
+ ;; already loaded
+;; :reload-all implies :reload and also forces loading of all libs that the
+;; identified libs directly or indirectly load via require or use
+
+(defun inf-clojure-reload-form (proc)
+ "Return the form to query the Inf-Clojure PROC for reloading a namespace.
+If you are using REPL types, it will pickup the most appropriate
+`inf-clojure-reload-form` variant."
+ (inf-clojure--set-repl-type proc)
+ inf-clojure-reload-form)
+
+(defcustom inf-clojure-reload-all-form "(require '\"%s\" :reload-all)"
+ "Format-string for building a Clojure expression to :reload-all a file.
+Reload-all implies :reload and also forces loading of all libs
+that the identified libs directly or indirectly load via require
+or use.
+This format string should use `%s' to substitute a namespace and
+should result in a Clojure form that will be sent to the inferior
+Clojure to load that file."
+ :type 'string
+ :safe #'stringp
+ :package-version '(inf-clojure . "2.2.0"))
+
+(defun inf-clojure-reload-all-form (proc)
+ "Return the form to query the Inf-Clojure PROC for :reload-all of a
namespace.
+If you are using REPL types, it will pickup the most appropriate
+`inf-clojure-reload-all-form` variant."
+ (inf-clojure--set-repl-type proc)
+ inf-clojure-reload-all-form)
+
(defcustom inf-clojure-prompt "^[^=> \n]+=> *"
"Regexp to recognize prompts in the Inferior Clojure mode."
:type 'regexp)
@@ -702,6 +746,28 @@ is present it will be used instead of the current file."
(when switch-to-repl
(inf-clojure-switch-to-repl t))))
+(defun inf-clojure-reload (arg)
+ "Send a query to the inferior Clojure for reloading the namespace.
+See variable `inf-clojure-reload-form' and
+`inf-clojure-reload-all-form'.
+
+The prefix argument ARG can change the behavior of the command:
+
+ - C-u M-x `inf-clojure-reload': prompts for a namespace name.
+ - M-- M-x `inf-clojure-reload': executes (require ... :reload-all).
+ - M-- C-u M-x `inf-clojure-reload': reloads all AND prompts."
+ (interactive "P")
+ (let* ((proc (inf-clojure-proc))
+ (invertp (or (equal arg "-") (equal arg '(-4))))
+ (promptp (or (equal arg '(4)) (equal arg '(-4))))
+ (ns (if promptp
+ (car (inf-clojure-symprompt "Namespace" (clojure-find-ns)))
+ (clojure-find-ns)))
+ (form (if (not invertp)
+ (inf-clojure-reload-form proc)
+ (inf-clojure-reload-all-form proc))))
+ (inf-clojure--send-string proc (format form ns))))
+
(defun inf-clojure-connected-p ()
"Return t if inferior Clojure is currently connected, nil otherwise."
(not (null inf-clojure-buffer)))
- [nongnu] elpa/inf-clojure e144b33 276/313: Improve the Makefile commands, (continued)
- [nongnu] elpa/inf-clojure e144b33 276/313: Improve the Makefile commands, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 917ee77 268/313: Improve the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 91f4121 280/313: Bump the copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 8eaf885 275/313: [Fix #152] Sanitize should only remove whitespace at the end of a command, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure ec4a85e 285/313: Bump copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 2046b12 298/313: Make inf-clojure-repl-p a bit more flexible, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure e1d7007 297/313: Touch up the previous commit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 9841b38 303/313: Remove some redundant code, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 3d31bee 313/313: Update my email, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 26a2076 305/313: Replace if + not with unless, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure be3e2e7 195/313: Introduce inf-clojure-reload,
ELPA Syncer <=
- [nongnu] elpa/inf-clojure 953feb0 198/313: Improve command sanitation code, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 7ed4f44 203/313: Remove emacs 24.3 and add 26 to Travis tests, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 010d859 219/313: Fix spelling issues (#156), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 7bf6f3d 209/313: README: Improve formatting., ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 575538e 230/313: Create FUNDING.yml, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure bd06d4f 229/313: A few updates to links and formatting in README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 49390d9 231/313: Bump the copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 799d937 250/313: Improve the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c30f90e 265/313: Ensure comint-truncate-buffer call is from the repl buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 784eb40 279/313: Remove unused require, ELPA Syncer, 2021/08/11