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

clojure-find-ns: never raise errors #654

Merged
merged 3 commits into from
Aug 23, 2023
Merged

Conversation

vemv
Copy link
Member

@vemv vemv commented Aug 22, 2023

See also clojure-emacs/cider#2849 for a use case and discussion.

One can see quite a few usages of clojure-find-ns in CIDER. Those assume a possible nil value, e.g.:

https://github.com/clojure-emacs/cider/blob/0e76b141054f091fa1a21fea7f2a5604b2f7f8d4/cider-client.el#L129-L130

...so the proposed change would be aligned with the existing usage.

Cheers - V

@vemv vemv requested review from bbatsov and dpsutton August 22, 2023 16:11
@bbatsov
Copy link
Member

bbatsov commented Aug 22, 2023

I'm not opposed to the change, but it is a breaking change regardless. Might be better to either introduce some extra param (e.g. suppress-errors) or a different function with a similar name that doesn't raise errors.

@vemv vemv force-pushed the clojure-find-ns--nil-safe branch from fc260f3 to 4bf10fc Compare August 22, 2023 21:04
@vemv vemv force-pushed the clojure-find-ns--nil-safe branch from 4bf10fc to b89e378 Compare August 22, 2023 21:07
@vemv
Copy link
Member Author

vemv commented Aug 22, 2023

I find unintentional errors to not quite be an API (they can be considered bugs that are subject to be fixed at any point), however I've applied the feedback 👍

It's green again

clojure-mode.el Outdated
@@ -2142,23 +2142,30 @@ DIRECTION is `forward' or `backward'."
(setq candidate (string-remove-prefix "'" (thing-at-point 'symbol))))))))
candidate))

(defun clojure-find-ns ()
"Return the namespace of the current Clojure buffer.
(defun clojure-find-ns (&optional favor-nil)
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 suppress-errors is a better name for this.

@vemv
Copy link
Member Author

vemv commented Aug 23, 2023

Done!

clojure-mode.el Outdated
@@ -2142,23 +2142,30 @@ DIRECTION is `forward' or `backward'."
(setq candidate (string-remove-prefix "'" (thing-at-point 'symbol))))))))
candidate))

(defun clojure-find-ns ()
"Return the namespace of the current Clojure buffer.
(defun clojure-find-ns (&optional supress-errors)
Copy link
Member

Choose a reason for hiding this comment

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

It's actually "suppress" (double p). Btw, on second thought "ignore-errors" might be an even better name, but I'm fine with both options.

Copy link
Member Author

Choose a reason for hiding this comment

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

Arrgh :)

Amended. I left it at suppress because there's already a construct named ignore-errors (probably Elisp would have been fine with it. Humans not so much?)

@vemv vemv force-pushed the clojure-find-ns--nil-safe branch from f928de5 to 0d79a6f Compare August 23, 2023 10:45
@bbatsov bbatsov merged commit 27cd085 into master Aug 23, 2023
@bbatsov bbatsov deleted the clojure-find-ns--nil-safe branch August 23, 2023 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants