Fix focus behavior in CIDER mode for Emacs
Today I’ve fine tuned my Emacs setup which hasn’t evolved for a while. Digging into emacs24 packages, testing rainbow-delimiters, customizing company-mode, etc. As a Clojure beginner, I’m discovering joy of programming lisp-languages within my favorite
Then I’ve played with CIDER, a Clojure IDE and REPL for Emacs. As expected you can benefit form REPL model directly, plus many additional features, such as stacktraces analysis. One of my favorite feature is to get shortcut (
C-c C-d in my case) to display the documentation and signature of an input function.
The problem is that CIDER always decides to automatically move the focus to the attached buffer. This leads into boring keyboard combinations to switch back to the original buffer, even smart shortcuts such as
C-<up> don’t satisfy myself. There are configuration options to annihilate this behavior when throwing an error or the REPL prompts, but I didn't find anything to avoid this when accessing the documentation.
And here comes the patch! If you’re annoyed by this behavior, feel free to patch your setup:
diff --git a/emacs/emacs.d/elpa/cider-0.5.0/cider-interaction.el b/emacs/emacs.d/elpa/cider-0.5.0/cider-interaction.el
index 8f4b8cb..8bcccbf 100644
@@ -1153,7 +1153,7 @@ if there is no symbol at point, or if QUERY is non-nil."
(defun cider-doc-handler (symbol)
"Create a handler to lookup documentation for SYMBOL."
(let ((form (format "(clojure.repl/doc %s)" symbol))
- (doc-buffer (cider-popup-buffer cider-doc-buffer t)))
+ (doc-buffer (cider-popup-buffer cider-doc-buffer nil)))
Of course, you may create your own variable to customize focus strategy, but I’ve never seen a very long documentation which could justify moving focus to another buffer.