Skip to content

Introduce inf-clojure-reload #132

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2018

Conversation

arichiardi
Copy link
Contributor

@arichiardi arichiardi commented Jan 31, 2018

It will evaluate (require 'ns :reload) or (require 'ns :reload-all) at the
REPL, depending on the arguments passed in.

  • 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."

This works only from source buffers at the moment (like all the other namespace commands).


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our [contribution guidelines][1]
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

Thanks!

inf-clojure.el Outdated

- C-u M-x `inf-clojure-reload': prompts for a namespace name.
- M-- M-x `inf-clojure-reload': inverts the default reload command
- M-- C-u M-x `inf-clojure-reload': inverts default AND prompts for a namespace name."
Copy link
Contributor Author

@arichiardi arichiardi Jan 31, 2018

Choose a reason for hiding this comment

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

There is probably better syntax for this documentation

Copy link
Member

Choose a reason for hiding this comment

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

http://ergoemacs.org/emacs/inline_doc.html

Anyways, this will do for now.

Copy link
Member

Choose a reason for hiding this comment

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

Btw, having 3 ways to invoke something becomes pretty confusing very fast - normally people do just single and double prefix arguments. I think the default inversion is a bit too much. I'd just drop this and the config and do two commands probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just that they are so similar that you usually think of it as same. That is the reason why the same key binding is used.

The inversion of the default can be indeed dropped and we can just always default for reload. With M-- reload-all.
I have used this for a week now and found it good enough.

inf-clojure.el Outdated
- M-- C-u M-x `inf-clojure-reload': inverts default AND prompts for a namespace name."
(interactive "P")
(let* ((proc (inf-clojure-proc))
(invert? (or (equal current-prefix-arg "-") (equal current-prefix-arg '(-4))))
Copy link
Member

Choose a reason for hiding this comment

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

arg is your prefix argument, so no need to use current-prefix-argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change

inf-clojure.el Outdated
(interactive "P")
(let* ((proc (inf-clojure-proc))
(invert? (or (equal current-prefix-arg "-") (equal current-prefix-arg '(-4))))
(prompt? (or (equal current-prefix-arg '(4)) (equal current-prefix-arg '(-4))))
Copy link
Member

Choose a reason for hiding this comment

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

Remember we don't use ? in Emacs - it's p there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right!

inf-clojure.el Outdated
@@ -702,6 +746,35 @@ is present it will be used instead of the current file."
(when switch-to-repl
(inf-clojure-switch-to-repl t))))

(defcustom inf-clojure-reload-default t
Copy link
Member

Choose a reason for hiding this comment

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

Why not 'reload and 'reload-all? Boolean predicate for this seems pretty confusing to me. It's better to use a symbol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will probably drop this

@arichiardi
Copy link
Contributor Author

@bbatsov I have just noticed that there is a similar key binding in clojure-mode so please don't merge this I want to change it to C-c M-r.

inf-clojure.el Outdated
@@ -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-cM-r" #'inf-clojure-reload)
Copy link
Member

Choose a reason for hiding this comment

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

I think you missed a \ here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah will fix today thanks!

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).
@bbatsov bbatsov merged commit be3e2e7 into clojure-emacs:master Feb 18, 2018
@arichiardi arichiardi deleted the reload-command branch February 19, 2018 04:08
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants