-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mode: REPL history commands (M-p etc.) insert, not replace. #823
base: master
Are you sure you want to change the base?
Conversation
contrib/slime-repl.el
Outdated
(defun slime-repl-history-replace (direction &optional regexp) | ||
"Replace the current input with the next line in DIRECTION. | ||
(defun slime-repl-history-recall (direction &optional regexp) | ||
"Recall the next history entry in DIRECTION. | ||
Replace the current input with it if SLIME-REPL-HISTORY-RECALL-MODE | ||
is REPLACE, or just insert it at point if this mode is INSERT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this since it no longer necessarily replaces.
That is a somewhat confusing option to have, can you achieve the behavior you want by adding an advice for slime-repl-replace-input? |
For my own use, I don't really care whether you merge the PR; I can run my forked version. But I expect other Paredit users will appreciate this option. (If you do merge it, I will add a note here to help people discover the feature.) Also, if you try the |
FWIW, this has been proposed before: #184 I wonder if this feature could be offered as independent interactive commands? |
This refactors the functionality so that instead of one custom variable, 'slime-repl-history-recall-mode', there are now two, 'slime-repl-history-autosearch-mode' and 'slime-repl-history-paredit-compatibility', which can be set orthogonally. The former controls only the behavior of M-p when the input line is nonempty; the latter makes a few tweaks so that things work nicely for users of ParEdit and similar balanced-parenthesis packages.
I've done some refactoring which I hope will make this code both more flexible and easier for users to understand. Instead of a single customization variable,
While I was at this, I couldn't resist making it so that walking off either end of the history (unless you have history wrapping turned on) puts your input line back to the state it was in before you first typed The other thing ParEdit compatibility mode does is to make I did make one incompatible change to existing behavior. If you type some text and then hit I have made some effort to test this code, but I'm not sure it's ready for merging yet. |
Oh, thanks, @luismbo. I'm glad to have @rpgoldman also agitating for this feature. Of course there are multiple ways to implement it; if it's considered preferable to do it with key rebinding rather than customization variables, I can redo it. But it seems to me that customization variables will be easier for users to find. |
Resets search-in-progress when you run off the end of the history. Lets you start from the far end of the history with an initial M-n. Adds more special handling for the case where autosearch and paredit-compatibility are both on.
The REPL history commands (
M-p
/M-n
) do not work the way I prefer. After I've evaluated a top-level form, I frequently want to wrap it in some more calls and evaluate it again. (Yes, I know about the*
variables, but I don't always like to use them; the expression I want to wrap and re-evaluate may not be one of the last three I entered, or maybe I just don't want to deal with the context sensitivity.) What I like to be able to do is to type the new calls first, then pull up the desired form from the history, such that it's inserted at point, then hit Enter. I use Paredit, so I shouldn't even need to type any close-parens. For example, givenI want to be able to type
( b a r Space M-p Enter
to evaluate(bar (foo))
.The existing commands do not support this usage; if I type anything before doing
M-p
, that is automatically taken as a search string. I can disable that by doingC-Space C-u M-p
, but then I lose the close paren(s) following point that Paredit inserted for me; I have to put them back manually, which in my configuration requires typingC-q
before each one.The changes in this PR are to support my preferred usage model. They are conditioned on a new custom variable,
slime-repl-history-recall-mode
, which defaults toreplace
so that the standard behavior is unchanged. When it's set toinsert
, though, automatic searching is turned off, and recalled history elements are inserted at point without deleting any of the user's text. (Of course one can still useM-r
to search.)