Search code examples
emacsslimespacemacs

How do I efficiently close the buffer opened by `slime-describe-symbol`?


The issue:

  1. I have started a Common Lisp session with a *slime-repl sbcl* in its default vertical split.
  2. I am on a symbol, let's say cond, and press the key for slime-describe-symbol which in my case is ,hh as I am using spacemacs.
  3. This opens a buffer *slime-description* on top of the repl window.

I am now left in a situation where I have to:

  • move to the split on the right
  • switch buffer to the slime *slime-repl sbcl*
  • return to my original buffer

I have to do this every time I open a help file which seems strange as the designed workflow. I would expect this to be possible using a single keystroke.

What is the intended way of managing this?


Solution

  • In plain emacs the keyboard shortcut for moving to the other window is 'C-x o' (other window). I'd assume the easiest way to achieve the automatic cursor movement when describing a symbol would be to define your own custom elisp function by modifying slime-describe-symbol to move the cursor to the slime-description window and (re)bind the keyboard shortcut.

    On my machine:

    (defun my-slime-describe-symbol (symbol-name) "Describe the symbol at point." (interactive (list (slime-read-symbol-name "Describe symbol: "))) (when (not symbol-name) (error "No symbol given")) (slime-eval-describe `(swank:describe-symbol ,symbol-name)) (switch-to-buffer-other-window "*slime-description*"))

    and then define the keyboard shortcut to your liking:

    (define-key slime-mode-map (kbd "C-c C-d d") 'my-slime-describe-symbol) (define-key slime-mode-map (kbd "C-c C-d C-d") 'my-slime-describe-symbol)