Skip to content

Commit

Permalink
[Fix clojure-emacs#1239] Add cider-refresh-show-log-buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cichli committed Aug 16, 2015
1 parent bf72824 commit 993c173
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [#1220](https://github.com/clojure-emacs/cider/issues/1220): Treat keywords as symbols in lookup commands like `cider-find-var`.
* [#1241](https://github.com/clojure-emacs/cider/pull/1241): Passing a double prefix argument to `cider-refresh` will now clear the state of the namespace tracker used by the refresh middleware. This is useful for recovering from errors that a normal reload would not otherwise recover from, but may cause stale code in any deleted files to not be completely unloaded.
* New defcustom `cider-result-use-clojure-font-lock` allows you disable the use of Clojure font-locking for interactive results.
* [#1239](https://github.com/clojure-emacs/cider/issues/1239): New defcustom `cider-refresh-show-log-buffer`, controls the behaviour of the `*cider-refresh-log*` buffer when calling `cider-refresh`. When set to nil (the default), the log buffer will still be written to, but not displayed automatically. Instead, the most relevant information will be displayed in the echo area. When set to non-nil, the log buffer will be displayed every time `cider-refresh` is called.

### Changes

Expand Down
45 changes: 33 additions & 12 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ if the candidate is not namespace-qualified."

(defconst cider-refresh-log-buffer "*cider-refresh-log*")

(defcustom cider-refresh-show-log-buffer nil
"Controls when to display the refresh log buffer.
If non-nil, the log buffer will be displayed every time `cider-refresh' is
called.
If nil, the log buffer will still be written to, but will never be
displayed automatically. Instead, the most relevant information will be
displayed in the echo area."
:type '(choice (const :tag "always" t)
(const :tag "never" nil))
:group 'cider
:package-version '(cider . "0.10.0"))

(defcustom cider-refresh-before-fn nil
"Clojure function for `cider-refresh' to call before reloading.
Expand Down Expand Up @@ -2110,37 +2124,43 @@ opposite of what that option dictates."

(defun cider-refresh--handle-response (response log-buffer)
(nrepl-dbind-response response (out err reloading status error error-ns after before)
(cl-flet ((log (message &optional face)
(cider-emit-into-popup-buffer log-buffer message face)))
(cl-flet* ((log (message &optional face)
(cider-emit-into-popup-buffer log-buffer message face))

(log-echo (message &optional face)
(log message face)
(unless cider-refresh-show-log-buffer
(let ((message-truncate-lines t))
(message "cider-refresh: %s" (s-trim message))))))
(cond (out
(log out))

(err
(log err 'font-lock-warning-face))

((member "invoking-before" status)
(log (format "Calling %s\n" before) 'font-lock-string-face))
(log-echo (format "Calling %s\n" before) 'font-lock-string-face))

((member "invoked-before" status)
(log (format "Successfully called %s\n" before) 'font-lock-string-face))
(log-echo (format "Successfully called %s\n" before) 'font-lock-string-face))

(reloading
(log (format "Reloading %s\n" reloading) 'font-lock-string-face))
(log-echo (format "Reloading %s\n" reloading) 'font-lock-string-face))

((member "reloading" (nrepl-dict-keys response))
(log "Nothing to reload\n" 'font-lock-string-face))
(log-echo "Nothing to reload\n" 'font-lock-string-face))

((member "ok" status)
(log "Reloading successful\n" 'font-lock-string-face))
(log-echo "Reloading successful\n" 'font-lock-string-face))

(error-ns
(log (format "Error reloading %s\n" error-ns) 'font-lock-warning-face))
(log-echo (format "Error reloading %s\n" error-ns) 'font-lock-warning-face))

((member "invoking-after" status)
(log (format "Calling %s\n" after) 'font-lock-string-face))
(log-echo (format "Calling %s\n" after) 'font-lock-string-face))

((member "invoked-after" status)
(log (format "Successfully called %s\n" after) 'font-lock-string-face))))
(log-echo (format "Successfully called %s\n" after) 'font-lock-string-face))))

(with-selected-window (or (get-buffer-window cider-refresh-log-buffer)
(selected-window))
Expand All @@ -2163,10 +2183,11 @@ reload would not otherwise recover from. The trade-off of clearing is that
stale code from any deleted files may not be completely unloaded."
(interactive "p")
(cider-ensure-op-supported "refresh")
(let ((log-buffer (cider-popup-buffer-display (or (get-buffer cider-refresh-log-buffer)
(cider-make-popup-buffer cider-refresh-log-buffer))))
(let ((log-buffer (or (get-buffer cider-refresh-log-buffer)
(cider-make-popup-buffer cider-refresh-log-buffer)))
(clear? (>= arg 16))
(refresh-all? (>= arg 4)))
(when cider-refresh-show-log-buffer (cider-popup-buffer-display log-buffer))
(when clear? (nrepl-send-sync-request (list "op" "refresh-clear")))
(nrepl-send-request (append (list "op" (if refresh-all? "refresh-all" "refresh")
"print-length" cider-stacktrace-print-length
Expand Down

0 comments on commit 993c173

Please sign in to comment.