emacsparedit

How to barf double quotes


I've got this as an initial state:

"first" second

Placing the cursor anywhere within the double quotes and pressing C-→ (in Emacs) gives me:

"first second"

Is there a "one-click" way to "barf" double quotes (i.e. to get back from the second state to the first)? I expected double quotes to work analogously to parenthesis barfing, but pressing C-← (while still having the cursor on the first word) doesn't seem to work (as it would in the case of parenthesis).

A potentially related question: Is there a way to remove the double quotes without prior making the length of their "span" zero.

Emacs 25.2 (9.0)

Major mode: Lisp

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption Column-Number Eldoc File-Name-Shadow Font-Lock Global-Eldoc Global-Font-Lock Global-Hl-Line Global-Linum Global-Rainbow-Delimiters Ido-Ubiquitous Line-Number Linum Mouse-Wheel Paredit Projectile Projectile-Global Rainbow-Delimiters Recentf Save-Place Shell-Dirtrack Show-Paren Tooltip Transient-Mark


Solution

  • There's no one-key command to do it. But you can get close: if the point is at the | in "first| second", you can do M-S C-M-d M-s:

    1. M-S (paredit-split-sexp) to split it into "first"| " second",
    2. C-M-d (paredit-forward-down) to descend into tho following string giving "first" "| second", and then
    3. M-s (paredit-splice-sexp) to splice the content of the string giving "first" | second.

    To clean up the spaces you can then do M-SPC (just-one-space).

    "first| second" M-S (paredit-split-sexp) "first"| " second" C-M-d (paredit-forward-down) "first" "| second"` M-s (paredit-splice-sexp) "first" | second M-SPC (just-one-space) "first" |second