calva icon indicating copy to clipboard operation
calva copied to clipboard

Add squeeze paredit action

Open conao3 opened this issue 5 months ago • 2 comments

puni; Emacs modern paredit alternative has puni-squeeze. This action kills all S-expressions enclosed by the cursor and removes the surrounding parentheses. It provides users with a simple, consistent, and predictable method for changing parentheses types. I consider this action an extremely useful innovation that surpasses the current rewrap method, and I would like to implement it in Calva.

foo (bar|) baz
;; Call `puni-squeeze'
foo | baz
;; Type in a pair of brackets
foo [|] baz
;; Call `yank'
foo [bar|] baz

Note

Current Calva has too many "rewrap" commands.

  • Calva Paredit: Rewrap "": C-M-r C-M-q
  • Calva Paredit: Rewrap (): C-M-r C-M-p
  • Calva Paredit: Rewrap []: C-M-r C-M-s
  • Calva Paredit: Rewrap {}: C-M-r C-M-c
  • Calva Paredit: Rewrap #{}: C-M-r C-M-h

After including paredit.squeeze action, user just do 3 action;

  1. Do paredit.squeeze (suggest C-M-r C-M-k; indicate "kill" current sibling S-exps)
  2. Add paren as you want in normal way (and paredit insert corresponding close paren)
  3. Do paste in normal way; boom, you finally achieve "rewrap" S-exps.

conao3 avatar Jul 13 '25 08:07 conao3