[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 6cb5747 166/224: Change `paredit-meta-doublequote'
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 6cb5747 166/224: Change `paredit-meta-doublequote' to avoid breaking the line. |
Date: |
Sat, 7 Aug 2021 09:22:42 -0400 (EDT) |
branch: elpa/paredit
commit 6cb5747b0973c36e0e21da4851f35a66c106a327
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Change `paredit-meta-doublequote' to avoid breaking the line.
This way, default M-" behaves more like default M-).
New command `paredit-meta-doublequote-and-newline' (no default key)
behaves like the old `paredit-meta-doublequote'.
---
paredit.el | 32 +++++++++++++++++++-------------
test.el | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 13 deletions(-)
diff --git a/paredit.el b/paredit.el
index 5389e8e..3e7cc5f 100644
--- a/paredit.el
+++ b/paredit.el
@@ -293,7 +293,7 @@ Paredit behaves badly if parentheses are unbalanced, so
exercise
"(frob grovel) ; full \"|lexical"))
("M-\"" paredit-meta-doublequote
("(foo \"bar |baz\" quux)"
- "(foo \"bar baz\"\n |quux)")
+ "(foo \"bar baz\"| quux)")
("(foo |(bar #\\x \"baz \\\\ quux\") zot)"
,(concat "(foo \"|(bar #\\\\x \\\"baz \\\\"
"\\\\ quux\\\")\" zot)")))
@@ -901,21 +901,27 @@ If in a character literal, do nothing. This prevents
accidentally
(paredit-insert-pair n ?\" ?\" 'paredit-forward-for-quote))))
(defun paredit-meta-doublequote (&optional n)
+ "Move to the end of the string.
+If not in a string, act as `paredit-doublequote'; if not prefix argument
+ is specified and the region is not active or `transient-mark-mode' is
+ disabled, the default is to wrap one S-expression, however, not zero."
+ (interactive "P")
+ (if (not (paredit-in-string-p))
+ (paredit-doublequote (or n (and (not (paredit-region-active-p)) 1)))
+ (goto-char (paredit-enclosing-string-end))))
+
+(defun paredit-meta-doublequote-and-newline (&optional n)
"Move to the end of the string, insert a newline, and indent.
-If not in a string, act as `paredit-doublequote'; if no prefix argument
- is specified and the region is not active or `transient-mark-mode' is
- disabled, the default is to wrap one S-expression, however, not
- zero."
+If not in a string, act as `paredit-doublequote'; if not prefix argument
+ is specified and the region is not active or `transient-mark-mode' is
+ disabled, the default is to wrap one S-expression, however, not zero."
(interactive "P")
(if (not (paredit-in-string-p))
- (paredit-doublequote (or n
- (and (not (paredit-region-active-p))
- 1)))
- (let ((start+end (paredit-string-start+end-points)))
- (goto-char (1+ (cdr start+end)))
- (newline)
- (lisp-indent-line)
- (paredit-ignore-sexp-errors (indent-sexp)))))
+ (paredit-doublequote (or n (and (not (paredit-region-active-p)) 1)))
+ (progn (goto-char (paredit-enclosing-string-end))
+ (newline)
+ (lisp-indent-line)
+ (paredit-ignore-sexp-errors (indent-sexp)))))
(defun paredit-forward-for-quote (end)
(let ((state (paredit-current-parse-state)))
diff --git a/test.el b/test.el
index a63f70e..d46aa13 100644
--- a/test.el
+++ b/test.el
@@ -1001,6 +1001,40 @@ Four arguments: the paredit command, the text of the
buffer
("((x) ;c\n (y)|)" error)
("((x) ;c\n (y))|" error)))
+(paredit-test 'paredit-meta-doublequote
+ '(("|(fo \"ba\\\" bz\" qx)" "\"|(fo \\\"ba\\\\\\\" bz\\\" qx)\"")
+ ("(|fo \"ba\\\" bz\" qx)" "(\"|fo\" \"ba\\\" bz\" qx)")
+ ("(f|o \"ba\\\" bz\" qx)" "(f \"|o\" \"ba\\\" bz\" qx)")
+ ;++ Should the space be left there after the `"'?
+ ("(fo| \"ba\\\" bz\" qx)" "(fo \"| \\\"ba\\\\\\\" bz\\\"\" qx)")
+ ("(fo |\"ba\\\" bz\" qx)" "(fo \"|\\\"ba\\\\\\\" bz\\\"\" qx)")
+ ("(fo \"|ba\\\" bz\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"b|a\\\" bz\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"ba|\\\" bz\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"ba\\|\" bz\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"ba\\\"| bz\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"ba\\\" |bz\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"ba\\\" b|z\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ("(fo \"ba\\\" bz|\" qx)" "(fo \"ba\\\" bz\"| qx)")
+ ;++ Should the space be left there after the `"'?
+ ("(fo \"ba\\\" bz\"| qx)" "(fo \"ba\\\" bz\" \"| qx\")")
+ ("(fo \"ba\\\" bz\" |qx)" "(fo \"ba\\\" bz\" \"|qx\")")
+ ("(fo \"ba\\\" bz\" q|x)" "(fo \"ba\\\" bz\" q \"|x\")")
+ ("(fo \"ba\\\" bz\" qx|)" "(fo \"ba\\\" bz\" qx \"|\")")
+ ("(fo \"ba\\\" bz\" qx)|" "(fo \"ba\\\" bz\" qx) \"|\"")
+
+ ;++ Full tests...
+ ("(foo |(bar #\\x \"baz \\\\ quux\") zot)"
+ "(foo \"|(bar #\\\\x \\\"baz \\\\\\\\ quux\\\")\" zot)")))
+
+;++ Copy tests from `paredit-meta-doublequote'...
+
+(paredit-test 'paredit-meta-doublequote-and-newline
+ '(("(foo \"bar |baz\" quux)"
+ "(foo \"bar baz\"\n |quux)")
+ ("(foo |(bar #\\x \"baz \\\\ quux\") zot)"
+ "(foo \"|(bar #\\\\x \\\"baz \\\\\\\\ quux\\\")\" zot)")))
+
(defun paredit-canary-indent-method (state indent-point normal-indent)
(check-parens)
nil)
- [nongnu] elpa/paredit b558286 138/224: Add character deletion tests to verify the new `paredit-in-char-p'., (continued)
- [nongnu] elpa/paredit b558286 138/224: Add character deletion tests to verify the new `paredit-in-char-p'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 73e664e 119/224: Add test for C-u ( with trailing comment and no trailing newline., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit aa42c19 140/224: Tweak a `paredit-reindent-defun' test slightly., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 36c9a82 142/224: Add regression test for `paredit-convolute-sexp' screw case., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4cb9112 144/224: Fix `kill-line' tests now that `show-trailing-whitespace' is nil., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit d2215ef 146/224: Add message to top of `paredit-test' reporting what we're testing., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit fc7c6aa 147/224: Add trivial check.sh to compile paredit and run tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 21ec511 154/224: Bump version: 23 beta -> 24 beta., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6484222 157/224: Add notes for paredit 23 to NEWS., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit dc96f75 161/224: Add clearer names for the enclosing string start/end points., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6cb5747 166/224: Change `paredit-meta-doublequote' to avoid breaking the line.,
ELPA Syncer <=
- [nongnu] elpa/paredit 9e5688e 167/224: Add some miscellaneous S-expression parsing utilities., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 56eff64 168/224: Add `paredit-indent-region' and move indentation utilities around., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 425e1a4 169/224: Improve indentation and column preservation in `paredit-splice'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 54317c8 171/224: Mark 24 as beta in NEWS., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit e0af01a 195/224: Make slurping and barfing support prefix arguments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit c39e485 201/224: Bump copyright date: 2013->2014., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4df6101 205/224: Bump copyright year to 2015., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 99829aa 214/224: Credit Alex Plotnick., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit acbe10f 216/224: Inherit input method when reading character for backslash escape., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 92aaa71 222/224: check.sh: Do not load Emacs init or site files, ELPA Syncer, 2021/08/07