Comments (5)
Thanks for the accurate report!
Taking a look at the commit that introduced this 02c4e80 - originally all params were forwarded.
Surely that was unawarely broken later.
I'm on the fence as to whether to introduce a breaking change.
Looks like we have a neat option: detect the arity of the user-set cider-interactive-eval-override
, and only pass the last argument if cider-interactive-eval-override
is ready for it.
Demo:
ielm> (help-function-arglist (lambda (a b c)))
(a b c)
ielm> (help-function-arglist 'mapcar)
(arg1 arg2)
Would you be interested in creating a PR?
Cheers - V
from cider.
That's a great idea, I'll try to submit a PR that checks the number of arguments. Thanks for the pointer!
from cider.
There is a func-arity
that is even more convenient than help-function-arglist
for our use case:
(let* ((arities (func-arity cider-interactive-eval-override))
(min-arity (car arities))
(max-arity (cdr arities)))
(if (or (eq 'many max-arity)
(and (numberp min-arity)
(numberp max-arity)
(<= min-arity 4 max-arity)))
(funcall cider-interactive-eval-override form callback bounds additional-params)
(funcall cider-interactive-eval-override form callback bounds)))
But there is an issue. When using apply-partially
for example, the arglist becomes opaque, and from the outside, it'll look like the function takes any number of arguments (func-arity
would return (0 . many)
). I have found at least one example in the wild that would break because of this. I have thought of restricting functions using &rest arguments from accessing the new feature for the sake of backward compatibility, but then that would prevent other perfectly valid functions from working such as:
(defun println-override (form &rest extra-args)
(let ((cider-interactive-eval-override nil))
(apply 'cider-interactive-eval
(concat "(do (println :wrapped) " form ")")
extra-args)))
So maybe a better way is not to check the arities, but to try to call the arity-4 version anyway, and if an arity error occurs, fallback on the previous arity-3 call site:
(condition-case _
(funcall cider-interactive-eval-override form callback bounds additional-params)
(wrong-number-of-arguments
(funcall cider-interactive-eval-override form callback bounds)))
@vemv what do you think?
from cider.
Hi @chpill kudos for looking into it!
Yes, suporting a simple defun println-override (form &rest extra-args)
would be important.
So your proposal seems great.
from cider.
@vemv thanks a lot!
from cider.
Related Issues (20)
- Errors when auto complete called in Cljs repl HOT 2
- `sesman-use-friendly-sessions` not respected HOT 6
- Use pretty-print formatting inside cider-inspect HOT 1
- Support bookmarks to Cider REPLs HOT 2
- Spinner support while running tests
- can't use Clojure 1.12 `add-lib` when `cider-enrich-classpath` set to `t` HOT 8
- refresh ops shouldn't have a timeout HOT 3
- `cider-enable-flex-completion` is not a sufficient replacement for `cider-company-enable-fuzzy-completion` HOT 26
- "Not a tramp file name" when running cider-connect HOT 1
- `cider-locals` - false positives HOT 4
- Wrong previous-line behavior while overlay is active
- Stack overflow when using CIDER with datahike and sail HOT 5
- Integration tests are broken HOT 1
- False assumption in cider-popup-buffer-display (with fix) HOT 1
- Update cheatsheet HOT 5
- In CLJC mode, C-x C-e evaluates against multiple REPLs simultaneously HOT 1
- Test reporter can't handle interrupted test HOT 2
- Current way of displaying cheatsheet is inconvenient HOT 3
- Allow inspecting a class that is used as a ^TypeTag HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cider.