-
-
Notifications
You must be signed in to change notification settings - Fork 649
[#1804] Remember location after cider-inspector-pop #1807
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,11 +114,41 @@ With a second prefix argument it prompts for an expression to eval and inspect." | |
(4 (cider-inspect-defun-at-point)) | ||
(16 (call-interactively #'cider-inspect-expr)))) | ||
|
||
(defvar cider-inspector-location-stack nil | ||
"A stack used to save point locations in inspector buffers. | ||
These locations are used to emulate save-excursion between | ||
`cider-inspector-push' and `cider-inspector-pop' operations.") | ||
|
||
(defvar cider-inspector-page-location-stack nil | ||
"A stack used to save point locations in inspector buffers. | ||
These locations are used to emulate save-excursion between | ||
`cider-inspector-next-page' and `cider-inspector-prev-page' operations.") | ||
|
||
(defvar cider-inspector-last-command nil | ||
"Contains the value of the most recently used `cider-inspector-*' command. | ||
This is used as an alternative to the built-in `last-command'. Whenever we | ||
invoke any command through M-x and its variants, the value of `last-command' | ||
is not set to the command it invokes.") | ||
|
||
;; Operations | ||
(defun cider-inspector--value-handler (_buffer value) | ||
(cider-make-popup-buffer cider-inspector-buffer 'cider-inspector-mode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is preventing us from creating a buffer-local var. It clears out all the state when creating a new buffer. I guess our this method could use an optional param which controls this behavior. But it would involve changes in a lot of places. Let's handle this in a separate PR ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I forgot about this. Yeah, guess we can revisit this later. I'll merge the PR in its current state. |
||
(cider-inspector-render cider-inspector-buffer value) | ||
(cider-popup-buffer-display cider-inspector-buffer t)) | ||
(cider-popup-buffer-display cider-inspector-buffer t) | ||
(with-current-buffer cider-inspector-buffer | ||
(when (eq cider-inspector-last-command 'cider-inspector-pop) | ||
(setq cider-inspector-last-command nil) | ||
;; Prevents error message being displayed when we try to pop | ||
;; from the top-level of a data struture | ||
(when cider-inspector-location-stack | ||
(goto-char (pop cider-inspector-location-stack)))) | ||
|
||
(when (eq cider-inspector-last-command 'cider-inspector-prev-page) | ||
(setq cider-inspector-last-command nil) | ||
;; Prevents error message being displayed when we try to | ||
;; go to a prev-page from the first page | ||
(when cider-inspector-page-location-stack | ||
(goto-char (pop cider-inspector-page-location-stack)))))) | ||
|
||
(defun cider-inspector--out-handler (_buffer value) | ||
(cider-emit-interactive-eval-output value)) | ||
|
@@ -157,12 +187,14 @@ current buffer's namespace." | |
|
||
(defun cider-inspector-pop () | ||
(interactive) | ||
(setq cider-inspector-last-command 'cider-inspector-pop) | ||
(cider-nrepl-send-request | ||
(list "op" "inspect-pop" | ||
"session" (cider-current-session)) | ||
(cider-inspector-response-handler (current-buffer)))) | ||
|
||
(defun cider-inspector-push (idx) | ||
(push (point) cider-inspector-location-stack) | ||
(cider-nrepl-send-request | ||
(list "op" "inspect-push" | ||
"idx" idx | ||
|
@@ -181,6 +213,7 @@ current buffer's namespace." | |
|
||
Does nothing if already on the last page." | ||
(interactive) | ||
(push (point) cider-inspector-page-location-stack) | ||
(cider-nrepl-send-request | ||
(list "op" "inspect-next-page" | ||
"session" (cider-current-session)) | ||
|
@@ -191,6 +224,7 @@ Does nothing if already on the last page." | |
|
||
Does nothing if already on the first page." | ||
(interactive) | ||
(setq cider-inspector-last-command 'cider-inspector-prev-page) | ||
(cider-nrepl-send-request | ||
(list "op" "inspect-prev-page" | ||
"session" (cider-current-session)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this should be a buffer-local variable.