Skip to content
Permalink
Browse files

[Fix #2347] Remove direct manipulations of cider-ancillary-buffers

CIDER's popups had a way to track those automatically for a while,
it's time to leverage this consistently.
  • Loading branch information
bbatsov committed Jun 24, 2018
1 parent 1fa530a commit 13c76efcfc94f3c97183962f91146a851bd7a9d3
@@ -39,7 +39,6 @@
(require 'button)

(defconst cider-apropos-buffer "*cider-apropos*")
(add-to-list 'cider-ancillary-buffers cider-apropos-buffer)

(defcustom cider-apropos-actions '(("display-doc" . cider-doc-lookup)
("find-def" . cider--find-var)
@@ -116,9 +115,8 @@ and be case-sensitive (based on CASE-SENSITIVE-P)."

(defun cider-show-apropos (summary results query docs-p)
"Show SUMMARY and RESULTS for QUERY in a pop-up buffer, formatted for DOCS-P."
(with-current-buffer (cider-popup-buffer cider-apropos-buffer t)
(with-current-buffer (cider-popup-buffer cider-apropos-buffer 'select 'apropos-mode 'ancillary)
(let ((inhibit-read-only t))
(apropos-mode)
(if (boundp 'header-line-format)
(setq-local header-line-format summary)
(insert summary "\n\n"))
@@ -45,7 +45,6 @@
(require 'easymenu)

(defconst cider-browse-ns-buffer "*cider-ns-browser*")
(add-to-list 'cider-ancillary-buffers cider-browse-ns-buffer)

(defvar-local cider-browse-ns-current-ns nil)

@@ -157,7 +156,7 @@ Each item consists of a ns-var and the first line of its docstring."
(defun cider-browse-ns (namespace)
"List all NAMESPACE's vars in BUFFER."
(interactive (list (completing-read "Browse namespace: " (cider-sync-request:ns-list))))
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer 'select nil 'ancillary)
(cider-browse-ns--list (current-buffer)
namespace
(cider-browse-ns--items namespace))
@@ -167,7 +166,7 @@ Each item consists of a ns-var and the first line of its docstring."
(defun cider-browse-ns-all ()
"List all loaded namespaces in BUFFER."
(interactive)
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer 'select nil 'ancillary)
(let ((names (cider-sync-request:ns-list)))
(cider-browse-ns--list (current-buffer)
"All loaded namespaces"
@@ -45,10 +45,7 @@

;; The buffer names used by the spec browser
(defconst cider-browse-spec-buffer "*cider-spec-browser*")
(add-to-list 'cider-ancillary-buffers cider-browse-spec-buffer)

(defconst cider-browse-spec-example-buffer "*cider-spec-example*")
(add-to-list 'cider-ancillary-buffers cider-browse-spec-example-buffer)

;; Mode Definition

@@ -276,8 +273,7 @@ a more user friendly representation of SPEC-FORM."
"Browse SPEC."
(cider-ensure-connected)
(cider-ensure-op-supported "spec-form")
(with-current-buffer (cider-popup-buffer cider-browse-spec-buffer t)
(cider-browse-spec-view-mode)
(with-current-buffer (cider-popup-buffer cider-browse-spec-buffer 'select #'cider-browse-spec-view-mode 'ancillary)
(setq-local cider-browse-spec--current-spec spec)
(cider-browse-spec--draw-spec-buffer (current-buffer)
spec
@@ -305,8 +301,7 @@ property."
(cider-ensure-op-supported "spec-example")
(if-let* ((spec cider-browse-spec--current-spec))
(if-let* ((example (cider-sync-request:spec-example spec)))
(with-current-buffer (cider-popup-buffer cider-browse-spec-example-buffer t)
(cider-browse-spec-example-mode)
(with-current-buffer (cider-popup-buffer cider-browse-spec-example-buffer 'select #'cider-browse-spec-example-mode 'ancillary)
(setq-local cider-browse-spec--current-spec spec)
(let ((inhibit-read-only t))
(insert "Example of " (cider-font-lock-as-clojure spec))
@@ -337,7 +332,7 @@ Displays all specs when REGEX is nil."
(cider-ensure-connected)
(cider-ensure-op-supported "spec-list")
(let ((filter-regex (or regex "")))
(with-current-buffer (cider-popup-buffer cider-browse-spec-buffer t)
(with-current-buffer (cider-popup-buffer cider-browse-spec-buffer 'select nil 'ancillary)
(let ((specs (cider-sync-request:spec-list filter-regex)))
(cider-browse-spec--draw-list-buffer (current-buffer)
(if (string-empty-p filter-regex)
@@ -29,7 +29,6 @@
(require 'cider-compat)

(defvar cider-classpath-buffer "*cider-classpath*")
(add-to-list 'cider-ancillary-buffers cider-classpath-buffer)

(defvar cider-classpath-mode-map
(let ((map (make-sparse-keymap)))
@@ -92,7 +91,7 @@
(interactive)
(cider-ensure-connected)
(cider-ensure-op-supported "classpath")
(with-current-buffer (cider-popup-buffer cider-classpath-buffer t)
(with-current-buffer (cider-popup-buffer cider-classpath-buffer 'select nil 'ancillary)
(cider-classpath-list (current-buffer)
(mapcar (lambda (name)
(cider-classpath-properties name))
@@ -50,10 +50,6 @@ Should be set before loading CIDER."
:group 'cider
:package-version '(cider . "0.15.0"))

(defvar cider-ancillary-buffers nil
"A list ancillary buffers created by the various CIDER commands.
We track them mostly to be able to clean them up on quit.")

(defun cider--should-prompt-for-symbol (&optional invert)
"Return the value of the variable `cider-prompt-for-symbol'.
Optionally invert the value, if INVERT is truthy."
@@ -339,10 +339,7 @@ Don't restart the server or other connections within the same session. Use
(message "%s" (cider--connection-info (cider-current-repl))))
(define-obsolete-function-alias 'cider-display-connection-info 'cider-describe-current-connection "0.18.0")

(defvar cider-ancillary-buffers) ; defined in cider-common.el

(defconst cider-nrepl-session-buffer "*cider-nrepl-session*")
(add-to-list 'cider-ancillary-buffers cider-nrepl-session-buffer)

(defun cider-describe-nrepl-session ()
"Describe an nREPL session."
@@ -358,7 +355,7 @@ Don't restart the server or other connections within the same session. Use
((equal session-id (cider-nrepl-eval-session)) "Active eval")
((equal session-id (cider-nrepl-tooling-session)) "Active tooling")
(t "Unknown"))))
(with-current-buffer (cider-popup-buffer cider-nrepl-session-buffer)
(with-current-buffer (cider-popup-buffer cider-nrepl-session-buffer nil 'ancillary)
(read-only-mode -1)
(insert (format "Session: %s\n" session-id)
(format "Type: %s session\n" session-type)
@@ -260,12 +260,11 @@ opposite of what that option dictates."
(error "%s cannot be looked up on Grimoire" cider-docview-symbol)))

(defconst cider-doc-buffer "*cider-doc*")
(add-to-list 'cider-ancillary-buffers cider-doc-buffer)

(defun cider-create-doc-buffer (symbol)
"Populates *cider-doc* with the documentation for SYMBOL."
(when-let* ((info (cider-var-info symbol)))
(cider-docview-render (cider-make-popup-buffer cider-doc-buffer) symbol info)))
(cider-docview-render (cider-make-popup-buffer cider-doc-buffer nil 'ancillary) symbol info)))

(defun cider-doc-lookup (symbol)
"Look up documentation for SYMBOL."
@@ -36,7 +36,6 @@
;; ===================================

(defconst cider-inspector-buffer "*cider-inspect*")
(add-to-list 'cider-ancillary-buffers cider-inspector-buffer)

;;; Customization
(defgroup cider-inspector nil
@@ -244,7 +243,7 @@ Set the page size in paginated view to PAGE-SIZE."
;; Render Inspector from Structured Values
(defun cider-inspector--render-value (value)
"Render VALUE."
(cider-make-popup-buffer cider-inspector-buffer 'cider-inspector-mode)
(cider-make-popup-buffer cider-inspector-buffer 'cider-inspector-mode 'ancillary)
(cider-inspector-render cider-inspector-buffer value)
(cider-popup-buffer-display cider-inspector-buffer t)
(when cider-inspector-fill-frame (delete-other-windows))
@@ -36,7 +36,6 @@
(require 'cider-compat)

(defconst cider-macroexpansion-buffer "*cider-macroexpansion*")
(add-to-list 'cider-ancillary-buffers cider-macroexpansion-buffer)

(defcustom cider-macroexpansion-display-namespaces 'tidy
"Determines if namespaces are displayed in the macroexpansion buffer.
@@ -163,8 +162,7 @@ and point is placed after the expanded form."

(defun cider-create-macroexpansion-buffer ()
"Create a new macroexpansion buffer."
(with-current-buffer (cider-popup-buffer cider-macroexpansion-buffer t)
(clojure-mode)
(with-current-buffer (cider-popup-buffer cider-macroexpansion-buffer 'select 'clojure-mode 'ancillary)
(cider-mode -1)
(cider-macroexpansion-mode 1)
(current-buffer)))
@@ -81,6 +81,10 @@ If prefix argument KILL is non-nil, kill the buffer instead of burying it."

(defvar-local cider-popup-output-marker nil)

(defvar cider-ancillary-buffers nil
"A list ancillary buffers created by the various CIDER commands.
We track them mostly to be able to clean them up on quit.")

(defun cider-make-popup-buffer (name &optional mode ancillary)
"Create a temporary buffer called NAME using major MODE (if specified).
If ANCILLARY is non-nil, the buffer is added to `cider-ancillary-buffers'
@@ -37,7 +37,6 @@
(require 'pulse)

(defconst cider-repl-history-buffer "*cider-repl-history*")
(add-to-list 'cider-ancillary-buffers cider-repl-history-buffer)

(defgroup cider-repl-history nil
"A package for browsing and inserting the items in the CIDER command history."
@@ -93,7 +93,6 @@ cyclical data structures."
(defvar-local cider-stacktrace-positive-filters nil)

(defconst cider-error-buffer "*cider-error*")
(add-to-list 'cider-ancillary-buffers cider-error-buffer)

(defcustom cider-stacktrace-suppressed-errors '()
"Errors that won't make the stacktrace buffer 'pop-over' your active window.
@@ -77,8 +77,6 @@ Add to this list to have CIDER recognize additional test defining macros."

(defconst cider-test-report-buffer "*cider-test-report*"
"Buffer name in which to display test reports.")
(add-to-list 'cider-ancillary-buffers cider-test-report-buffer)


;;; Faces

@@ -294,7 +292,8 @@ prompt and whether to use a new window. Similar to `cider-find-var'."
(cider-stacktrace-render
(cider-popup-buffer cider-error-buffer
cider-auto-select-error-buffer
#'cider-stacktrace-mode)
#'cider-stacktrace-mode
'ancillary)
(reverse causes))))))))))

(defun cider-test-stacktrace ()

0 comments on commit 13c76ef

Please sign in to comment.
You can’t perform that action at this time.