Skip to content

Commit efe3b84

Browse files
authored
Merge branch 'clojure-emacs:master' into fix-remote-enrich-classpath-init
2 parents 9808235 + 356c2bd commit efe3b84

File tree

14 files changed

+132
-86
lines changed

14 files changed

+132
-86
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
## master (unreleased)
44

5+
### New features
6+
- CIDER [History](https://docs.cider.mx/cider/repl/history.html): Add a command to delete history item at point.
7+
8+
### Changes
9+
10+
- Bump the injected nREPL version to [1.3.1](https://github.com/nrepl/nrepl/blob/master/CHANGELOG.md#131-2025-01-01).
11+
- Bump the injected `cider-nrepl` to [0.51.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0510-2025-01-01).
12+
- [#3574](https://github.com/clojure-emacs/cider/issues/3574): New value `per-project` for `cider-repl-history-file` to save the history on a per-project basis.
13+
14+
### Bugs fixed
15+
16+
- [#3763](https://github.com/clojure-emacs/cider/issues/3763): Fix `cider-docview-render` completion popup error when symbol being completed does not have a docstring.
17+
518
## 1.16.1 (2024-12-03)
619

720
### Changes

cider-doc.el

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,11 @@ in a COMPACT format is specified, FOR-TOOLTIP if specified."
428428
"doc-first-sentence-fragments" (nrepl-dict-get info "doc-first-sentence-fragments"))))
429429
(fetched-doc (nrepl-dict-get info "doc"))
430430
(doc (or rendered-fragments
431-
(if compact
432-
(cider-docstring--trim
433-
(cider-docstring--format fetched-doc))
434-
fetched-doc)
431+
(when fetched-doc
432+
(if compact
433+
(cider-docstring--trim
434+
(cider-docstring--format fetched-doc))
435+
fetched-doc))
435436
(unless compact
436437
"Not documented.")))
437438
(url (nrepl-dict-get info "url"))

cider-repl-history.el

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ call `cider-repl-history' again.")
220220
(defvar cider-repl-history-previous-overlay nil
221221
"Previous overlay within *cider-repl-history* buffer.")
222222

223-
224223
(defun cider-repl-history-get-history ()
225224
"Function to retrieve history from the REPL buffer."
226225
(if cider-repl-history-repl-buffer
@@ -576,6 +575,16 @@ text from the *cider-repl-history* buffer."
576575
(with-current-buffer cider-repl-history-repl-buffer
577576
(undo)))
578577

578+
(defun cider-repl-history-delete-entry-at-point ()
579+
"Delete history entry (at point)."
580+
(interactive)
581+
(let* ((orig (point))
582+
(str (cider-repl-history-current-string orig)))
583+
(with-current-buffer cider-repl-history-repl-buffer
584+
(delete str cider-repl-input-history))
585+
(cider-repl-history-update)
586+
(goto-char orig)))
587+
579588
(defun cider-repl-history-setup (repl-win repl-buf history-buf &optional regexp)
580589
"Setup.
581590
REPL-WIN and REPL-BUF are where to insert commands;
@@ -637,16 +646,17 @@ HISTORY-BUF is the history, and optional arg REGEXP is a filter."
637646
#'cider-repl-history-update-highlighted-entry
638647
nil t))
639648
(message
640-
(let ((entry (if (= 1 (length cider-command-history))
641-
"entry"
642-
"entries")))
649+
(let* ((history-length (length cider-command-history))
650+
(entry (if (= 1 history-length)
651+
"entry"
652+
"entries")))
643653
(concat
644654
(if (and (not regexp)
645655
cider-repl-history-display-duplicates)
646656
(format "%s %s in the command history."
647-
(length cider-command-history) entry)
657+
history-length entry)
648658
(format "%s (of %s) %s in the command history shown."
649-
(length items) (length cider-command-history) entry))
659+
(length items) history-length entry))
650660
(substitute-command-keys
651661
(concat " Type \\[cider-repl-history-quit] to quit. "
652662
"\\[describe-mode] for help.")))))
@@ -693,6 +703,7 @@ HISTORY-BUF is the history, and optional arg REGEXP is a filter."
693703
(define-key map (kbd "g") #'cider-repl-history-update)
694704
(define-key map (kbd "q") #'cider-repl-history-quit)
695705
(define-key map (kbd "U") #'cider-repl-history-undo-other-window)
706+
(define-key map (kbd "D") #'cider-repl-history-delete-entry-at-point)
696707
(define-key map (kbd "?") #'describe-mode)
697708
(define-key map (kbd "h") #'describe-mode)
698709
map))

cider-repl.el

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ CIDER 1.7."
194194
This property value must be unique to avoid having adjacent inputs be
195195
joined together.")
196196

197-
(defvar-local cider-repl-input-history '()
198-
"History list of strings read from the REPL buffer.")
199-
200-
(defvar-local cider-repl-input-history-items-added 0
201-
"Variable counting the items added in the current session.")
202-
203197
(defvar-local cider-repl-output-start nil
204198
"Marker for the start of output.
205199
Currently its only purpose is to facilitate `cider-repl-clear-buffer'.")
@@ -1468,13 +1462,15 @@ WIN, BUFFER and POS are the window, buffer and point under mouse position."
14681462
(defvar cider-repl-history-pattern nil
14691463
"The regexp most recently used for finding input history.")
14701464

1465+
(defvar cider-repl-input-history '()
1466+
"History list of strings read from the REPL buffer.")
1467+
14711468
(defun cider-repl--add-to-input-history (string)
14721469
"Add STRING to the input history.
14731470
Empty strings and duplicates are ignored."
14741471
(unless (or (equal string "")
14751472
(equal string (car cider-repl-input-history)))
1476-
(push string cider-repl-input-history)
1477-
(cl-incf cider-repl-input-history-items-added)))
1473+
(push string cider-repl-input-history)))
14781474

14791475
(defun cider-repl-delete-current-input ()
14801476
"Delete all text after the prompt."
@@ -1593,9 +1589,11 @@ If USE-CURRENT-INPUT is non-nil, use the current input."
15931589
:safe #'integerp)
15941590

15951591
(defcustom cider-repl-history-file nil
1596-
"File to save the persistent REPL history to."
1597-
:type 'string
1598-
:safe #'stringp)
1592+
"File to save the persistent REPL history to.
1593+
If this is set to a path the history will be global to all projects. If this is
1594+
set to `per-project', the history will be stored in a file (.cider-history) at
1595+
the root of each project."
1596+
:type '(choice string symbol))
15991597

16001598
(defun cider-repl--history-read-filename ()
16011599
"Ask the user which file to use, defaulting `cider-repl-history-file'."
@@ -1612,28 +1610,48 @@ It does not yet set the input history."
16121610
(read (current-buffer))))
16131611
'()))
16141612

1613+
(defun cider-repl--find-dir-for-history ()
1614+
"Find the first suitable directory to store the project's history."
1615+
(seq-find
1616+
(lambda (dir) (and (not (null dir)) (not (tramp-tramp-file-p dir))))
1617+
(list nrepl-project-dir (clojure-project-dir) default-directory)))
1618+
16151619
(defun cider-repl-history-load (&optional filename)
16161620
"Load history from FILENAME into current session.
16171621
FILENAME defaults to the value of `cider-repl-history-file' but user
16181622
defined filenames can be used to read special history files.
16191623
16201624
The value of `cider-repl-input-history' is set by this function."
16211625
(interactive (list (cider-repl--history-read-filename)))
1622-
(let ((f (or filename cider-repl-history-file)))
1623-
;; TODO: probably need to set cider-repl-input-history-position as well.
1624-
;; in a fresh connection the newest item in the list is currently
1625-
;; not available. After sending one input, everything seems to work.
1626-
(setq cider-repl-input-history (cider-repl--history-read f))))
1626+
(cond
1627+
(filename (setq cider-repl-history-file filename))
1628+
((equal 'per-project cider-repl-history-file)
1629+
(make-local-variable 'cider-repl-input-history)
1630+
(when-let ((dir (cider-repl--find-dir-for-history)))
1631+
(setq-local
1632+
cider-repl-history-file (expand-file-name ".cider-history" dir)))))
1633+
(when cider-repl-history-file
1634+
(condition-case nil
1635+
;; TODO: probably need to set cider-repl-input-history-position as
1636+
;; well. In a fresh connection the newest item in the list is
1637+
;; currently not available. After sending one input, everything
1638+
;; seems to work.
1639+
(setq
1640+
cider-repl-input-history
1641+
(cider-repl--history-read cider-repl-history-file))
1642+
(error
1643+
(message
1644+
"Malformed cider-repl-history-file: %s" cider-repl-history-file)))
1645+
(add-hook 'kill-buffer-hook #'cider-repl-history-just-save t t)
1646+
(add-hook 'kill-emacs-hook #'cider-repl-history-save-all)))
16271647

16281648
(defun cider-repl--history-write (filename)
16291649
"Write history to FILENAME.
16301650
Currently coding system for writing the contents is hardwired to
16311651
utf-8-unix."
1632-
(let* ((mhist (cider-repl--histories-merge cider-repl-input-history
1633-
cider-repl-input-history-items-added
1634-
(cider-repl--history-read filename)))
1652+
(let* ((end (min (length cider-repl-input-history) cider-repl-history-size))
16351653
;; newest items are at the beginning of the list, thus 0
1636-
(hist (cl-subseq mhist 0 (min (length mhist) cider-repl-history-size))))
1654+
(hist (cl-subseq cider-repl-input-history 0 end)))
16371655
(unless (file-writable-p filename)
16381656
(error (format "History file not writable: %s" filename)))
16391657
(let ((print-length nil) (print-level nil))
@@ -1658,15 +1676,12 @@ This function is meant to be used in hooks to avoid lambda
16581676
constructs."
16591677
(cider-repl-history-save cider-repl-history-file))
16601678

1661-
;; SLIME has different semantics and will not save any duplicates.
1662-
;; we keep track of how many items were added to the history in the
1663-
;; current session in `cider-repl--add-to-input-history' and merge only the
1664-
;; new items with the current history found in the file, which may
1665-
;; have been changed in the meantime by another session.
1666-
(defun cider-repl--histories-merge (session-hist n-added-items file-hist)
1667-
"Merge histories from SESSION-HIST adding N-ADDED-ITEMS into FILE-HIST."
1668-
(append (cl-subseq session-hist 0 n-added-items)
1669-
file-hist))
1679+
(defun cider-repl-history-save-all ()
1680+
"Save all histories."
1681+
(dolist (buffer (buffer-list))
1682+
(with-current-buffer buffer
1683+
(when (equal major-mode 'cider-repl-mode)
1684+
(cider-repl-history-just-save)))))
16701685

16711686

16721687
;;; REPL shortcuts
@@ -2051,13 +2066,7 @@ in an unexpected place."
20512066
(setq-local prettify-symbols-alist clojure--prettify-symbols-alist)
20522067
;; apply dir-local variables to REPL buffers
20532068
(hack-dir-local-variables-non-file-buffer)
2054-
(when cider-repl-history-file
2055-
(condition-case nil
2056-
(cider-repl-history-load cider-repl-history-file)
2057-
(error
2058-
(message "Malformed cider-repl-history-file: %s" cider-repl-history-file)))
2059-
(add-hook 'kill-buffer-hook #'cider-repl-history-just-save t t)
2060-
(add-hook 'kill-emacs-hook #'cider-repl-history-just-save))
2069+
(cider-repl-history-load)
20612070
(add-hook 'completion-at-point-functions #'cider-complete-at-point nil t)
20622071
(add-hook 'paredit-mode-hook (lambda () (clojure-paredit-setup cider-repl-mode-map)))
20632072
(cider-repl-setup-paredit))

cider.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ Throws an error if PROJECT-TYPE is unknown."
560560
"List of dependencies where elements are lists of artifact name and version.")
561561
(put 'cider-jack-in-dependencies 'risky-local-variable t)
562562

563-
(defcustom cider-injected-nrepl-version "1.3.0"
563+
(defcustom cider-injected-nrepl-version "1.3.1"
564564
"The version of nREPL injected on jack-in.
565565
We inject the newest known version of nREPL just in case
566566
your version of Boot or Leiningen is bundling an older one."
@@ -591,7 +591,7 @@ the artifact.")
591591
592592
Used when `cider-jack-in-auto-inject-clojure' is set to `latest'.")
593593

594-
(defconst cider-required-middleware-version "0.50.3"
594+
(defconst cider-required-middleware-version "0.51.0"
595595
"The CIDER nREPL version that's known to work properly with CIDER.")
596596

597597
(defcustom cider-injected-middleware-version cider-required-middleware-version

dev/docker-sample-project/project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
:dependencies [[org.clojure/clojure "1.11.1"]
33
[clj-http "3.12.3"]]
44
:source-paths ["src"]
5-
:plugins [[cider/cider-nrepl "0.50.3"]])
5+
:plugins [[cider/cider-nrepl "0.51.0"]])

dev/tramp-sample-project/project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
:dependencies [[org.clojure/clojure "1.11.1"]
33
[clj-http "3.12.3"]]
44
:source-paths ["src"]
5-
:plugins [[cider/cider-nrepl "0.50.3"]
5+
:plugins [[cider/cider-nrepl "0.51.0"]
66
[refactor-nrepl "3.9.0"]])

doc/modules/ROOT/pages/basics/middleware_setup.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ Use the convenient plugin for defaults, either in your project's
3232

3333
[source,clojure]
3434
----
35-
:plugins [[cider/cider-nrepl "0.50.3"]]
35+
:plugins [[cider/cider-nrepl "0.51.0"]]
3636
----
3737

3838
A minimal `profiles.clj` for CIDER would be:
3939

4040
[source,clojure]
4141
----
42-
{:repl {:plugins [[cider/cider-nrepl "0.50.3"]]}}
42+
{:repl {:plugins [[cider/cider-nrepl "0.51.0"]]}}
4343
----
4444

4545
WARNING: Be careful not to place this in the `:user` profile, as this way CIDER's
@@ -59,7 +59,7 @@ all of their projects using a `~/.boot/profile.boot` file like so:
5959
(require 'boot.repl)
6060
6161
(swap! boot.repl/*default-dependencies*
62-
concat '[[cider/cider-nrepl "0.50.3"]])
62+
concat '[[cider/cider-nrepl "0.51.0"]])
6363
6464
(swap! boot.repl/*default-middleware*
6565
conj 'cider.nrepl/cider-middleware)
@@ -76,11 +76,11 @@ run `cider-connect` or `cider-connect-cljs`.
7676

7777
[source,clojure]
7878
----
79-
:cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.50.3"}}
79+
:cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.51.0"}}
8080
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}
8181
8282
:cider-cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.339"}
83-
cider/cider-nrepl {:mvn/version "0.50.3"}
83+
cider/cider-nrepl {:mvn/version "0.51.0"}
8484
cider/piggieback {:mvn/version "0.5.3"}}
8585
:main-opts ["-m" "nrepl.cmdline" "--middleware"
8686
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}
@@ -99,7 +99,7 @@ NOTE: Make sure you're using https://github.com/clojurephant/clojurephant[Clojur
9999
----
100100
dependencies {
101101
devImplementation 'nrepl:nrepl:0.9.0'
102-
devImplementation 'cider:cider-nrepl:0.50.3'
102+
devImplementation 'cider:cider-nrepl:0.51.0'
103103
}
104104
105105
tasks.named('clojureRepl') {

doc/modules/ROOT/pages/basics/up_and_running.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ simple - CIDER simply passes the extra dependencies and nREPL configuration to
7373
your build tool in the command it runs to start the nREPL server. Here's how
7474
this looks for `tools.deps`:
7575

76-
$ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.3.0"} cider/cider-nrepl {:mvn/version "0.50.3"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'
76+
$ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.3.1"} cider/cider-nrepl {:mvn/version "0.51.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'
7777

7878
TIP: If you don't want `cider-jack-in` to inject dependencies automatically, set
7979
`cider-inject-dependencies-at-jack-in` to `nil`. Note that you'll have to setup
@@ -350,7 +350,7 @@ It is also possible for plain `clj`, although the command is somewhat longer:
350350

351351
[source,sh]
352352
----
353-
$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.50.3"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
353+
$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.51.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
354354
----
355355

356356
Alternatively, you can start nREPL either manually or using the facilities

doc/modules/ROOT/pages/cljs/shadow-cljs.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ And connect to it with `cider-connect`.
6262
...For that to work, `shadow-cljs.edn` contents like the following are assumed:
6363

6464
```clj
65-
:dependencies [[cider/cider-nrepl "0.50.3"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process)
65+
:dependencies [[cider/cider-nrepl "0.51.0"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process)
6666
[refactor-nrepl/refactor-nrepl "3.9.0"]] ;; refactor-nrepl is optional
6767

6868
:nrepl {:middleware [cider.nrepl/cider-middleware ;; it's advisable to explicitly add this middleware. It's automatically added by shadow-cljs (if available in the classpath), unless `:nrepl {:cider false}`

0 commit comments

Comments
 (0)