0

Apologies if this is poorly described, my emacs vocabulary is pretty limited.

I've set the following in my config:

(define-key evil-normal-state-map (kbd "C-=") 'cider-find-var))

cider-find-var always wants confirmation though. For example if I press C-= on the symbol usage I see this in the bottom left corner:

enter image description here

I have to press enter to confirm. How can I automatically confirm this every time? A generic solution that works with other function calls is preferred.

This is the help message for the function in question:

cider-find-var is an interactive compiled Lisp function in `cider-client.el'.

It is bound to C-=.

(cider-find-var &optional ARG VAR LINE)

Find definition for VAR at LINE.

Prompt according to prefix ARG and cider-prompt-for-symbol. A single or double prefix argument inverts the meaning of cider-prompt-for-symbol. A prefix of - or a double prefix argument causes the results to be displayed in a different window. The default value is thing at point.

0

2 Answers 2

2

I don't use cider, but looking at some of the documentation it looks like:

  • You can customize cider-prompt-for-symbol to set the default behavior for prompts.

  • When calling cider-find-var you can use a prefix argument to invert the default prompt behavior.

So it sounds like you could use M-x customize-option cider-prompt-for-symbol to change the default behavior.

You could also keep the default setting but change your key binding to provide the argument -- one way to do that is to bind the key to a lambda such as:

(define-key evil-normal-state-map (kbd "C-=") (lambda () (interactive) (cider-find-var t)))

That binds the key to a new function that calls cider-find-var with an argument t. From the function doc, a non-nil argument inverts the value of the the prompt option.

1
  • customize-option looks helpful, let me look into that
    – Dean
    Jun 6, 2016 at 19:13
2

Sometimes we want to find something in our clojure codebase that isn't readily at point (point is the emacs term for the location of your cursor). What is at point is the default that the command will search for. What you are thinking of as "confirmation" is an opportunity to enter a different var to search for from that which is at point.

This same functionality exists for cider documentation lookup as well. Sometimes you may want to lookup documentation for a function to see if it does what you want, without first adding the function to your codebase - or having to spend the time navigating to an existing usage.

This is a common convention in emacs, for example the built in emacs functions describe-function (C-h f) and describe-variable (C-h v) work this way, and you'll be well served by the versatility commands that follow this convention offer while working with elisp, or looking up emacs commands and settings.

Initially, cider did not follow this convention - but it has since adopted it. At first I found it a little uncomfortable, based on my preconceived expectations and I worried that it would hamper my efficiency. I quickly found just the opposite, I habituated the additional key press and have found the flexibility it offers very useful when I need it. I was also surprised to learn that navigating to what I was interested in usually took longer than typing the name - especially with the powers of tab-completion in the minibuffer thanks to the combination of auto-completion in company-mode and the helm narrowing framework.

I would encourage you to try and use it as designed - even if only for a few days, in the long run it will likely make you a more proficient emacs user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.