I don't use slime, but assuming it uses comint-mode then I would think the following might do the trick:
(defun my-slime-test-run ()
(interactive)
(delete-other-windows)
(split-window-below)
(with-selected-window (next-window)
(switch-to-buffer "slime-repl")
(goto-char (point-max))
(insert "(test-run)")
(comint-send-input)))
(global-set-key (kbd "<f3>") 'my-slime-test-run)
There is probably a better way to do this, but hopefully that gives you a little insight into how you can write elisp functions to carry out tasks in the editor (and note how the function reads very much like a set of editor instructions -- you can do a lot simply by converting the keystrokes you would use into equivalent code -- or even not writing code at all, and simply recording & saving keyboard macros).
Use C-hf name-of-the-function
RET to get documentation on any of the function/macro calls in that function.
For the keybinding, I used C-hkF3 to check how Emacs referred to that key, and then used that string as the argument to kbd
(and note how you can use that sequence to find the name of the function bound to any given key sequence, which you can then utilise in code if desired).
Many things are far less obvious if you don't already know them, but that's only to be expected with a code base as large as this (and dating back as long as this).
The great thing is that if you don't know what you're looking for, you can always search for function names matching patterns with C-uC-ha (and similarly for variables, values, libraries, and documentation; see M-: (info "(emacs) Apropos")
RET for more about this facility). Plus the info manuals (complete with indexes -- press I
or i
within any particular manual, or use the info-apropos
command to search all info manuals at once).
Truly one of the very best things you can do is to learn how to use the self-documenting nature of Emacs to find answers to the things you don't already know.
C-x 2
is not a mode; it just calls the functionsplit-window-below
. Admittedly the distinction could be considered slightly arbitrary -- mode functions have the same capabilities as any other function, and global minor modes likemenu-bar-mode
affect frames rather than buffers -- but modes mostly provide behaviours to individual buffers, and by convention they always have a function name ending in-mode
. Because modes are such an important part of Emacs, you'll avoid a little confusion if you don't refer to other functions using that terminology. - philsC-h t
. After that, you may find it helpful to search the Q&As here containing that term: stackoverflow.com/search?q=[emacs]+tutorial - philsC-h i
to get to the info reader; take careful note of the key bindings listed at the top of the main contents page, and remember thatd
always takes you back there. - phils