-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Added function for switching back from an inf-clojure buffer #200
Conversation
Looks good to me overall. Just mention this in the changelog and I we can merge this. |
Thanks! I did already, if I should change it let me know. I did notice I forgot to update |
As far as I know it's good to go, let me know if there's anything else. |
This attempts to track a buffer you came from. This seems inherently weak as there are only certain times we mark the buffer we came from. Seems like most times it will be nil or stale. Can we do something like what CIDER does and look through the For reference, CIDER's version: (defun cider-switch-to-last-clojure-buffer ()
"Switch to the last Clojure buffer.
The default keybinding for this command is
the same as variable `cider-switch-to-repl-buffer',
so that it is very convenient to jump between a
Clojure buffer and the REPL buffer."
(interactive)
(if (derived-mode-p 'cider-repl-mode)
(let* ((a-buf)
(the-buf (let ((repl-type (cider-repl-type-for-buffer)))
(seq-find (lambda (b)
(unless (with-current-buffer b (derived-mode-p 'cider-repl-mode))
(when-let* ((type (cider-repl-type-for-buffer b)))
(unless a-buf
(setq a-buf b))
(or (eq type 'multi)
(eq type repl-type)))))
(buffer-list)))))
(if-let* ((buf (or the-buf a-buf)))
(if cider-repl-display-in-current-window
(pop-to-buffer-same-window buf)
(pop-to-buffer buf))
(user-error "No Clojure buffer found")))
(user-error "Not in a CIDER REPL buffer"))) But the gist is |
@dpsutton I was only intending to update it when it was swapped with C-c C-z / |
@JasonKDarby exactly. The current implementation would take you back to the last buffer that you used |
one day I'll learn how to read and pass args in emacs
@dpsutton I think this works, I've tried it out with two windows. Let me know if there's anything else to do on this. I love inf-clojure. |
thanks @JasonKDarby . this is a great addition. |
This addresses #168 by creating
inf-clojure--recent-buffer
to keep track of the buffer the repl was switched to from. It's set on bothinf-clojure
andinf-clojure-switch-to-repl
which hopefully means it can never be unintentionallynil
. Ifinf-clojure-switch-to-recent-buffer
is called andinf-clojure--recent-buffer
ISnil
the message"inf-clojure: No recent buffer known."
is sent.This only tracks the most recent buffer among all repls, it will not manage multiple references in the case of multiple repls.
I'm by no means an elisp expert, if there are improvements to be made I'm happy to hear them. I'm gonna try to take on more changes, I love having an opportunity to contribute!
Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
M-x checkdoc
warningsThanks!