-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a command to delete history item at point #3574
base: master
Are you sure you want to change the base?
Conversation
On a side note, it looks like
|
Thanks for the PR!
Although it may be true, I sense that having per-project repl histories would be the best new direction - WDYT? |
Probably it's a matter of using our Makefile instead |
|
I can totally try to split the history on a per-project basis |
Maybe you're on a different Emacs version - we use 28 for linting. The Makefile has a comment indicating how to override the local Emacs.
Thanks! I assume it's never been like that / it's something we want? @bbatsov To me it makes sense because a given project's sexprs are often irrelevant / invalid (not compile-able) in another project. |
995f11b
to
d96930b
Compare
Absolutely. Thank you
It's done in the first commit (which is a bit hard to read…) |
I'd be fine by this, although I'm not sure how it can be made reliably.(e.g. what would you use as project id for remote connections?) I'll take a look at the proposed implementation. |
cider-repl.el
Outdated
The value of `cider-repl-input-history' and `cider-repl-history-file' are set by | ||
this function." | ||
(when-let* ((dir (clojure-project-dir)) | ||
(file (concat dir "/.cider-history"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd better to use expand-file-name
instead of concat
. Also - I'd move the file name to a constant.
@@ -1592,16 +1595,6 @@ If USE-CURRENT-INPUT is non-nil, use the current input." | |||
:type 'integer | |||
:safe #'integerp) | |||
|
|||
(defcustom cider-repl-history-file nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't just delete this - you'll have to add a deprecation warning for it, so people would know it's no longer being used. If we want to avoid breaking changes we'd probably want to keep the old behavior if this variable is set.
cider-repl.el
Outdated
@@ -194,6 +194,9 @@ CIDER 1.7." | |||
This property value must be unique to avoid having adjacent inputs be | |||
joined together.") | |||
|
|||
(defvar-local cider-repl-history-file nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to my other remark - you should probably use a different name for the buffer-local var, to avoid breaking changes.
I quickly went over the code and it looks reasonable overall, but it also introduces a breaking change that I think would be prudent to ignore. Probably it'd be best to keep the old behavior if someone set an file name explicitly and switch to the logging per project if they haven't. |
cider-repl.el
Outdated
The value of `cider-repl-input-history' and `cider-repl-history-file' are set by | ||
this function." | ||
(when-let* ((dir (clojure-project-dir)) | ||
(file (concat dir "/.cider-history"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should have one file per platform: clj, cljs, bb
Hello, Almost all comments have been addressed. I still have two things I would like your advice on:
|
106f764
to
41cccdf
Compare
Thanks much! It's looking great.
Most definitely.
If you don't mind I'll pick up this branch, fix some nits and then also add the 'platform' refinement. Then I'll squash everything, keeping you as the author. It's how I operate normally, to avoid long feedback loops. We can keep the PR open in the meantime. |
cider-repl-history.el
Outdated
@@ -576,6 +577,16 @@ text from the *cider-repl-history* buffer." | |||
(with-current-buffer cider-repl-history-repl-buffer | |||
(undo))) | |||
|
|||
(defun cider-repl-history-delete () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete-item-at-point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or entry)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Note that CIDER writes the history to the file when you kill the REPL | ||
buffer, which includes invoking `cider-quit`, or when you quit Emacs. | ||
Note that CIDER stores the history in a file named by | ||
`cider-repl-local-history-name` located at the root of your project if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this should be named cider-repl-project-history-file
or something along those lines, as I think local
history might be slightly misleading in this case. (and yeah - I realize there might not always be a project associated with a REPL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the implementation quite a bit and removed the notion of global
and local
I'll also add that currently CIDER doesn't have persistent history by default and I think it's a good idea to keep this behavior. Frankly, I really don't care much about history between sessions and I guess I'm not the only one, given there has been little demand to change the default behavior over the years. |
I didn't get this - what behavior should remain unchanged? |
I meant to write "don't care". I think this should be some opt-in, not a default. (just as storing the global history to file is) |
From my side it's something I've always missed (really), but it was more in the 'nice-to-have' area. There was always something more important 😄 Maybe we can keep it under a defcustom indeed, enabling it later after some months for gaining confidence in the solution. |
Yeah, that's fair. I'm just always a bit wary of serializing data to files (and reading it back) as often people run into issues with broken entries due to various reason. (probably less so in this case, given the simple nature of the history format, but I've had my fair share of issues with seemingly trivial serialization) |
So, what are we doing about this PR? |
I'll pick it up early December, sorry for the delay. |
@vemv Any updates on this front? |
Perhaps this weekend, sorry for the delay. |
@vemv Friendly reminder about this one. :-) I want us to start finalizing the scope of the next release. |
Sure, I'm finally closing a sprint which didn't leave a lot of OSS time available. |
Is there any way I can help? |
I can't allocate time currently so you can go ahead in any way that works / passes review from @bbatsov |
@Zzull Just address my previous comments and we're good to go. |
I changed the implementation so that CIDER stays without a persistent history by default.
to
I still haven't found a way to get the REPL type though. I described it earlier:
|
c539731
to
3c6780f
Compare
@@ -2,10 +2,14 @@ | |||
|
|||
## master (unreleased) | |||
|
|||
### New features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to rebase, as we cut a new CIDER release recently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
(defun cider-repl--find-dir-for-history () | ||
"Find the first suitable directory to store the project's history." | ||
(seq-find | ||
(lambda (dir) (and (not (null dir)) (not (tramp-tramp-file-p dir)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue with storing the history on a remote filesystem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know and I don't have access to a remote machine on which I can start CIDER on to try. I followed @vemv advice:
It may be better to pick the first, non-nil, non-tramp value of (list nrepl-project-dir clojure-project-dir default-directory)
This way we don't write files to remote TRAMP targets, which may surprise most people - or bring unforeseen issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There's not an easy way around this, so I guess we can skip it for the first version. I think the per-project history will be quite the improvement, even without being so granular. |
|
||
[source,lisp] | ||
---- | ||
(setq cider-repl-history-file "path/to/file") | ||
---- | ||
|
||
Note that CIDER writes the history to the file when you kill the REPL | ||
buffer, which includes invoking `cider-quit`, or when you quit Emacs. | ||
Note that CIDER stores the history in a file named by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably expand this to show a full configuration snippet, so it's clearer how people are supposed to set this up. Perhaps you can just have a bullet point for the project-specific configuration so it stands out a bit more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
To save the history on a per-project basis.
Because input history cannot be changed by another REPL anymore
I removed the commit introducing that change |
This PR adds a command to delete an history item at point.
The first commit is important because it makescider-repl-input-history
global. It was already sort of global before because the history was shared across REPLs and saved to a unique file but now it's downright adefvar
instead of adefvar-local
. I went in that direction because it felt like it was the simplest way of dealing with acknowledgment of deletion of an item across multiple REPLs.The first commit now stores histories on a per-project basis
Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
eldev test
)eldev lint
) which is based onelisp-lint
and includescheckdoc
, check-declare, packaging metadata, indentation, and trailing whitespace checks.Thanks!
If you're just starting out to hack on CIDER you might find this section of its
manual extremely useful.