Skip to content
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

Show progress when evaluating files using cider-load-all-files #3714

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cider-eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -1839,9 +1839,15 @@ all ns aliases and var mappings from the namespace before reloading it."
Useful when the running nREPL on remote host.
When UNDEF-ALL is non-nil or called with \\[universal-argument], removes
all ns aliases and var mappings from the namespaces being reloaded"
(interactive "DLoad files beneath directory: \nP")
(mapcar (lambda (file) (cider-load-file file undef-all))
(directory-files-recursively directory "\\.clj[cs]?$")))
(interactive "DRecursively load files in directory: \nP")
(let* ((files (directory-files-recursively directory "\\.clj[cs]?$"))
(reporter (make-progress-reporter "Loading files" 0 (length files))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should mention the directory name in the message as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in every reporter message, there is already a name for the loaded file (the file argument of (progress-reporter-update reporter (1+ idx) file)), so I think there is no need to change anything.

(seq-do-indexed (lambda (file idx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have probably used a dolist here, but I'm old-school. :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's a chore to manually manipulate the counter, and I couldn't pass up such a sweet function!

(let ((inhibit-message t))
(cider-load-file file undef-all))
(progress-reporter-update reporter (1+ idx) file))
files)
(progress-reporter-done reporter)))

(defalias 'cider-eval-file #'cider-load-file
"A convenience alias as some people are confused by the load-* names.")
Expand Down
Loading