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

Option to find definition in same window #2499

Closed
simon-katz opened this issue Oct 29, 2018 · 6 comments
Closed

Option to find definition in same window #2499

simon-katz opened this issue Oct 29, 2018 · 6 comments
Labels
enhancement good first issue A simple tasks suitable for first-time contributors

Comments

@simon-katz
Copy link
Contributor

simon-katz commented Oct 29, 2018

When I hit M-. or similar to find a definition, if the buffer containing the definition is already being displayed in another window of the current frame, CIDER switches to that window.

I find this annoying. I prefer that the current window always be used.

Would it be possible to have an option for this?

FWIW, I have a hack that gives me what I want. It arranges for cider-jump-to to call switch-to-buffer instead of pop-to-buffer:

(defvar *nomis/cider-jump-to/reuse-selected-window?* nil)

(let* ((advice-name '-nomis/cider/replace-pop-to-buffer-within-cider-jump-to))
  (advice-add 'cider-jump-to
              :around
              (lambda (orig-fun &rest args)
                (let* ((*nomis/cider-jump-to/reuse-selected-window?* t))
                  (apply orig-fun args)))
              `((name . ,advice-name)))
  (advice-add 'pop-to-buffer
              :around
              (lambda (orig-fun buffer &rest other-args)
                (if *nomis/cider-jump-to/reuse-selected-window?*
                    (switch-to-buffer buffer nil t)
                  (apply orig-fun buffer other-args)))
              `((name . ,advice-name))))
@mallt
Copy link
Contributor

mallt commented Dec 9, 2018

Removing the display-buffer-reuse-window action function in the cider-jump-to function should result in the desired behavior.

I guess the action functions could be controlled by a new customization variable, but then the behavior would be changed for all occurences of the cider-jump-to function and not only for the cider-find-var command.

@simon-katz
Copy link
Contributor Author

I think customization of the action functions would give me what I want.

BTW, maybe I should have mentioned that M-. in an Emacs Lisp buffer does do what I want.

@agzam
Copy link
Contributor

agzam commented Feb 13, 2019

interestingly I have an opposite problem. Docstring for cider-find-var states:

A prefix of ‘-‘ or a double prefix argument causes
the results to be displayed in a different window.

but I am failing to make it appear in other window. It's always in the same window.
Could it be solved simply by replacing
https://github.com/clojure-emacs/cider/blob/master/cider-common.el#L141
with (pop-to-buffer buffer 'display-buffer-pop-up-window)

@agzam
Copy link
Contributor

agzam commented Feb 14, 2019

Well, I submitted a tiny PR - locally it fixes things for me: opens in the same window by default, opens in the other window with prefix arg. #2583

@stale
Copy link

stale bot commented May 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale label May 8, 2019
@bbatsov bbatsov closed this as completed May 10, 2019
@bbatsov bbatsov reopened this Nov 25, 2019
@stale stale bot removed the stale label Nov 25, 2019
@bbatsov bbatsov added enhancement good first issue A simple tasks suitable for first-time contributors labels Nov 25, 2019
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 25, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

Provide an option to use existing buffer in current frame when there is one that
is showing the target buffer. (This is the old behaviour, but note that it does
not work well with `cider-pop-back` (M-,).

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 25, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

Provide an option to use existing buffer in current frame when there is one that
is showing the target buffer. (This is the old behaviour, but note that it does
not work well with `cider-pop-back` (M-,).

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 25, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

Provide an option to use existing buffer in current frame when there is one that
is showing the target buffer. (This is the old behaviour, but note that it does
not work well with `cider-pop-back` (M-,).

This fixes clojure-emacs#2499
@simon-katz
Copy link
Contributor Author

I've created a PR to address this at #2757

simon-katz added a commit to simon-katz/cider that referenced this issue Nov 25, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

Provide an option to use existing buffer in current frame when there is one that
is showing the target buffer. (This is the old behaviour, but note that it does
not work well with `cider-pop-back` (M-,).

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
simon-katz added a commit to simon-katz/cider that referenced this issue Nov 26, 2019
Provide a means to control what window to use when jumping to a definition with
`cider-jump-to`.

By default, always use current window.

This fixes clojure-emacs#2499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue A simple tasks suitable for first-time contributors
Projects
None yet
Development

No branches or pull requests

4 participants