Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ for presenting fontified documentation, including Javadoc.

### Changes

* [#603](https://github.com/clojure-emacs/cider/pull/603) New variable
`cider-show-error-buffer` to control the behavior of the error buffer. Obsoletes
`cider-popup-on-error`, `cider-popup-stacktraces` and
`cider-repl-popup-stacktraces`.
* `cider-nrepl` is now required. Without it pretty much nothing will work.
* Removed redundant command `cider-src`.
* Renamed `nrepl-log-events` variable to `nrepl-log-messages`.
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,28 @@ following snippet:
(setq cider-repl-pop-to-buffer-on-connect nil)
```

* Stop the error buffer from popping up while working in buffers other
than the REPL:
* Configure whether the error buffer with stacktraces should be automatically
shown on error:

- Don't show on error:

```el
(setq cider-popup-stacktraces nil)
```
(setq cider-show-error-buffer nil)
```

* Enable error buffer popping also in the REPL:
Independently of the value of `cider-show-error-buffer`, the error buffer is
always generated in the background. Use `cider-visit-error-buffer` to visit
this buffer.

- Selective strategies:

```el
(setq cider-repl-popup-stacktraces t)
(setq cider-show-error-buffer 'except-in-repl) ; or
(setq cider-show-error-buffer 'only-in-repl)
```

* To disable auto-selection of the error (stacktrace) buffer when it's displayed:

* To disable auto-selection of the error buffer when it's displayed:

```el
(setq cider-auto-select-error-buffer nil)
Expand Down
75 changes: 40 additions & 35 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,23 @@
:type 'boolean
:group 'cider)

(defcustom cider-popup-stacktraces t
"Non-nil means pop-up error stacktraces for evaluation errors.
Nil means show only an error message in the minibuffer. See also
`cider-repl-popup-stacktraces', which overrides this setting
for REPL buffers."
:type 'boolean
(defcustom cider-show-error-buffer t
"Control the popup behavior of cider stacktraces.
The following values are possible t or 'always, 'except-in-repl,
'only-in-repl. Any other value, including nil, will cause the stacktrace
not to be automatically shown.

Irespective of the value of this variable, the `cider-error-buffer' is
always generated in the background. Use `cider-visit-error-buffer' to
navigate to this buffer."
:type '(choice (const :tag "always" t)
(const except-in-repl)
(const only-in-repl)
(const :tag "never" nil))
:group 'cider)

(defcustom cider-popup-on-error t
"When `cider-popup-on-error' is set to t, stacktraces will be displayed.
When set to nil, stactraces will not be displayed, but will be available
in the `cider-error-buffer', which defaults to *cider-error*."
:type 'boolean
:group 'cider)
(define-obsolete-variable-alias 'cider-popup-stacktraces
'cider-show-error-buffer "0.7.0")

(defcustom cider-auto-select-error-buffer t
"Controls whether to auto-select the error popup buffer."
Expand Down Expand Up @@ -764,9 +767,8 @@ The handler simply inserts the result value in BUFFER."
buffer err))
'()
(lambda (buffer ex root-ex session)
(let ((cider-popup-on-error nil))
(funcall nrepl-err-handler
buffer ex root-ex session)))))
(funcall nrepl-err-handler
buffer ex root-ex session))))

(defun cider-interactive-eval-print-handler (buffer)
"Make a handler for evaluating and printing result in BUFFER."
Expand Down Expand Up @@ -804,8 +806,9 @@ The handler simply inserts the result value in BUFFER."
"Visit the `cider-error-buffer' (usually *cider-error*) if it exists."
(interactive)
(let ((buffer (get-buffer cider-error-buffer)))
(when buffer
(cider-popup-buffer-display buffer))))
(if buffer
(cider-popup-buffer-display buffer cider-auto-select-error-buffer)
(error "No %s buffer" cider-error-buffer))))

(defun cider-find-property (property &optional backward)
"Find the next text region which has the specified PROPERTY.
Expand Down Expand Up @@ -836,27 +839,29 @@ They exist for compatibility with `next-error'."
(goto-next-note-boundary))
(goto-next-note-boundary)))

(defun cider-default-err-op-handler (buffer ex root-ex session)
"Make an error handler for BUFFER, EX, ROOT-EX and SESSION with middleware support."
(let ((replp (with-current-buffer buffer (derived-mode-p 'cider-repl-mode))))
(when (or (and cider-repl-popup-stacktraces replp)
(and cider-popup-stacktraces (not replp)))
(let (causes)
(nrepl-send-request
(list "op" "stacktrace" "session" session)
(lambda (response)
(nrepl-dbind-response response (message name status)
(cond (message (setq causes (cons response causes)))
(status (when causes
(cider-stacktrace-render
(cider-popup-buffer cider-error-buffer
cider-auto-select-error-buffer)
(reverse causes))))))))))))

(defun cider-default-err-handler (buffer ex root-ex session)
"Make an error handler for BUFFER, EX, ROOT-EX and SESSION."
(cider-ensure-op-supported "stacktrace")
(cider-default-err-op-handler buffer ex root-ex session))
(let* ((replp (with-current-buffer buffer
(derived-mode-p 'cider-repl-mode)))
(showp (memq cider-show-error-buffer
(if replp
'(t always only-in-repl)
'(t always except-in-repl)))))
(let (causes)
(nrepl-send-request
(list "op" "stacktrace" "session" session)
(lambda (response)
(nrepl-dbind-response response (message name status)
(cond (message (setq causes (cons response causes)))
(status (when causes
(cider-stacktrace-render
(if showp
(cider-popup-buffer cider-error-buffer
cider-auto-select-error-buffer)
(cider-make-popup-buffer cider-error-buffer))
(reverse causes)))))))))))

(defvar cider-compilation-regexp
'("\\(?:.*\\(warning, \\)\\|.*?\\(, compiling\\):(\\)\\([^:]*\\):\\([[:digit:]]+\\)\\(?::\\([[:digit:]]+\\)\\)?\\(\\(?: - \\(.*\\)\\)\\|)\\)" 3 4 5 (1))
Expand Down Expand Up @@ -948,7 +953,6 @@ KILL-BUFFER-P is passed along."
"Create new popup buffer called NAME.
If SELECT is non-nil, select the newly created window"
(with-current-buffer (cider-make-popup-buffer name)
(setq buffer-read-only t)
(cider-popup-buffer-display (current-buffer) select)))

(defun cider-popup-buffer-display (popup-buffer &optional select)
Expand All @@ -975,6 +979,7 @@ If prefix argument KILL-BUFFER-P is non-nil, kill the buffer instead of burying
(erase-buffer)
(set-syntax-table clojure-mode-syntax-table)
(cider-popup-buffer-mode 1)
(setq buffer-read-only t)
(current-buffer)))

(defun cider-emit-into-popup-buffer (buffer value)
Expand Down
7 changes: 0 additions & 7 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@
"Face for the result of an evaluation in the REPL buffer."
:group 'cider-repl)

(defcustom cider-repl-popup-stacktraces nil
"Non-nil means pop-up error stacktraces in the REPL buffer.
Nil means show only an error message in the minibuffer. This variable
overrides `cider-popup-stacktraces' in REPL buffers."
:type 'boolean
:group 'cider-repl)

(defcustom cider-repl-pop-to-buffer-on-connect t
"Controls whether to pop to the REPL buffer on connect.

Expand Down