-
-
Notifications
You must be signed in to change notification settings - Fork 230
add squeeze paredit action #2893
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
base: dev
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for calva-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
isMulti: boolean, | ||
onRange: (doc: EditableDocument, range: [number, number]) => Promise<void> = async () => {} | ||
) { | ||
// TODO: support multi-cursor |
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.
Currently, our squeeze function don't support multi-cursor like killLeft
@@ -2690,6 +2696,11 @@ | |||
"key": "ctrl+alt+r ctrl+alt+q", | |||
"when": "calva:keybindingsEnabled && editorLangId == clojure && editorTextFocus && paredit:keyMap =~ /original|strict/" | |||
}, | |||
{ | |||
"command": "paredit.squeeze", | |||
"key": "ctrl+alt+r ctrl+alt+r", |
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.
Default shortcuts is hard. But we do have defaults for almost (maybe all) Paredit commands. I'm thinking that since there is a cut in there, maybe ctrl+alt+r ctrl+alt+x
. Though I also note the ctrl+alt+x
is free. The default for splice is ctrl+alt+s
, this is sort of splice + cut. So maybe ctrl+alt+x ctrl+alt+s
. If we don't see any other “... + cut” on the horizon, then just ctrl+alt+x
may do.
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 thought you liked ctrl+alt+r ctrl+alt+r
... but apparently not.
#2892 (comment)
IMO, ctrl+alt+x
or ctrl+alt+c
are quite awkward to press, so I prefer either ctrl+alt+r ctrl+alt+r
or ctrl+alt+r ctrl+alt+k
.
r
stands as a two-key shortcut for generic rewrap. k
comes from "kill," though it may no longer actually perform a kill operation. :)
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.
We could go without binding it to something default, and users can bind it to whatever is convenient for them.
export async function squeezeSexpr( | ||
doc: EditableDocument, | ||
onRange: (doc: EditableDocument, range: [number, number]) => Promise<void>, | ||
start = doc.selections[0].active | ||
) { | ||
const startC = doc.getTokenCursor(start); | ||
|
||
startC.backwardList(); | ||
if (startC.backwardUpList()) { | ||
const outerStart = startC.offsetStart; | ||
|
||
const endC = doc.getTokenCursor(startC.offsetStart); | ||
endC.forwardSexp(); | ||
const outerEnd = endC.offsetStart; | ||
endC.previous(); | ||
const innerEnd = endC.offsetStart; | ||
|
||
startC.downList(); | ||
const innerStart = startC.offsetStart; | ||
|
||
await onRange(doc, [innerStart, innerEnd]); | ||
|
||
return doc.model.edit([new ModelEdit('changeRange', [outerStart, outerEnd, ''])], {}); | ||
} | ||
} |
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.
Did you consider sharing the code for finding the text to replace with spliceSexp
? I'm not saying we should, but it may be a good idea?
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.
OK! I try it.
What has changed?
Fixes #2892
My Calva PR Checklist
I have:
dev
branch. (Or have specific reasons to target some other branch.)published
. (Sorry for the nagging.)[Unreleased]
entry inCHANGELOG.md
, linking the issue(s) that the PR is addressing.npm run prettier-format
)npm run eslint
before creating your PR, or runnpm run eslint-watch
to eslint as you go).