[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit db82936 163/224: Make `paredit-forward' and `pared
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit db82936 163/224: Make `paredit-forward' and `paredit-backward' move out of strings. |
Date: |
Sat, 7 Aug 2021 09:22:41 -0400 (EDT) |
branch: elpa/paredit
commit db829365197d1400c229b5bedfd1a06c7754a30a
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Make `paredit-forward' and `paredit-backward' move out of strings.
---
paredit.el | 39 +++++++++++++++-----
test.el | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 151 insertions(+), 10 deletions(-)
diff --git a/paredit.el b/paredit.el
index fcf50b7..e2d3f78 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1755,22 +1755,41 @@ With a prefix argument, skip the balance check."
If there are no more S-expressions in this one before the closing
delimiter, move past that closing delimiter; otherwise, move forward
past the S-expression following the point."
- (paredit-handle-sexp-errors
- (forward-sexp)
- ;; Use `up-list' if outside a string in case there is whitespace
- ;; between the point and the end of the list.
- (if (paredit-in-string-p) (forward-char) (up-list))))
+ (cond ((paredit-in-string-p)
+ (let ((end (paredit-enclosing-string-end)))
+ ;; `forward-sexp' and `up-list' may move into the next string
+ ;; in the buffer. Don't do that; move out of the current one.
+ (if (paredit-handle-sexp-errors
+ (progn (paredit-handle-sexp-errors (forward-sexp)
+ (up-list))
+ (<= end (point)))
+ t)
+ (goto-char end))))
+ ((paredit-in-char-p)
+ (forward-char))
+ (t
+ (paredit-handle-sexp-errors (forward-sexp)
+ (up-list)))))
(defun-saving-mark paredit-backward ()
"Move backward an S-expression, or up an S-expression backward.
If there are no more S-expressions in this one before the opening
delimiter, move past that opening delimiter backward; otherwise, move
move backward past the S-expression preceding the point."
- (paredit-handle-sexp-errors
- (backward-sexp)
- ;; Use `backward-up-list' if outside a string in case there is
- ;; whitespace between the point and the beginning of the list.
- (if (paredit-in-string-p) (backward-char) (backward-up-list))))
+ (cond ((paredit-in-string-p)
+ (let ((start (paredit-enclosing-string-start)))
+ (if (paredit-handle-sexp-errors
+ (progn (paredit-handle-sexp-errors (backward-sexp)
+ (backward-up-list))
+ (<= (point) start))
+ t)
+ (goto-char start))))
+ ((paredit-in-char-p)
+ ;++ Corner case: a buffer of `\|x'. What to do?
+ (backward-char 2))
+ (t
+ (paredit-handle-sexp-errors (backward-sexp)
+ (backward-up-list)))))
;;; Why is this not in lisp.el?
diff --git a/test.el b/test.el
index ba71788..bf9d9bf 100644
--- a/test.el
+++ b/test.el
@@ -741,6 +741,128 @@ Four arguments: the paredit command, the text of the
buffer
("\"x|y\"" error)
("\"xy|\"" error)))
+(paredit-test 'paredit-forward
+ '(("|" "|")
+
+ ("|()" "()|" "()|")
+ ("(|)" "()|" "()|")
+ ("()|" "()|")
+
+ ("|( )" "( )|" "( )|")
+ ("(| )" "( )|" "( )|")
+ ("( |)" "( )|" "( )|")
+ ("( )|" "( )|")
+
+ ("|\"\"" "\"\"|" "\"\"|")
+ ("\"|\"" "\"\"|" "\"\"|")
+ ("\"\"|" "\"\"|")
+
+ ("|\")\"" "\")\"|" "\")\"|")
+ ("\"|)\"" "\")|\"" "\")\"|" "\")\"|")
+ ("\")|\"" "\")\"|" "\")\"|")
+ ("\")\"|" "\")\"|")
+
+ ("|\"()\"" "\"()\"|" "\"()\"|")
+ ("\"|()\"" "\"()|\"" "\"()\"|" "\"()\"|")
+ ("\"(|)\"" "\"()|\"" "\"()\"|" "\"()\"|")
+ ("\"()\"|" "\"()\"|")
+
+ ("|(\"x\" \"y\")" "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(|\"x\" \"y\")" "(\"x\"| \"y\")" "(\"x\" \"y\"|)"
+ "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"|x\" \"y\")" "(\"x|\" \"y\")" "(\"x\"| \"y\")" "(\"x\" \"y\"|)"
+ "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x|\" \"y\")" "(\"x\"| \"y\")" "(\"x\" \"y\"|)"
+ "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x\"| \"y\")" "(\"x\" \"y\"|)" "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x\" |\"y\")" "(\"x\" \"y\"|)" "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x\" \"|y\")" "(\"x\" \"y|\")" "(\"x\" \"y\"|)"
+ "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x\" \"y|\")" "(\"x\" \"y\"|)" "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x\" \"y\"|)" "(\"x\" \"y\")|" "(\"x\" \"y\")|")
+ ("(\"x\" \"y\")|" "(\"x\" \"y\")|")
+
+ ("|#\\(" "#\\(|" "#\\(|")
+ ("#|\\(" "#\\(|" "#\\(|")
+ ("#\\|(" "#\\(|" "#\\(|")
+ ("#\\(|" "#\\(|")
+
+ ("|#\\)" "#\\)|" "#\\)|")
+ ("#|\\)" "#\\)|" "#\\)|")
+ ("#\\|)" "#\\)|" "#\\)|")
+ ("#\\)|" "#\\)|")
+
+ ("|#\\\\" "#\\\\|" "#\\\\|")
+ ("#|\\\\" "#\\\\|" "#\\\\|")
+ ("#\\|\\" "#\\\\|" "#\\\\|")
+ ("#\\\\|" "#\\\\|")
+
+ ("|#\\;" "#\\;|" "#\\;|")
+ ("#|\\;" "#\\;|" "#\\;|")
+ ("#\\|;" "#\\;|" "#\\;|")
+ ("#\\;|" "#\\;|")))
+
+(paredit-test 'paredit-backward
+ '(("|" "|")
+
+ ("|()" "|()")
+ ("(|)" "|()" "|()")
+ ("()|" "|()" "|()")
+
+ ("|( )" "|( )")
+ ("(| )" "|( )" "|( )")
+ ("( |)" "|( )" "|( )")
+ ("( )|" "|( )" "|( )")
+
+ ("|\"\"" "|\"\"")
+ ("\"|\"" "|\"\"" "|\"\"")
+ ("\"\"|" "|\"\"" "|\"\"")
+
+ ("|\")\"" "|\")\"")
+ ("\"|)\"" "|\")\"" "|\")\"")
+ ("\")|\"" "|\")\"" "|\")\"")
+ ("\")\"|" "|\")\"" "|\")\"")
+
+ ("|\"()\"" "|\"()\"")
+ ("\"|()\"" "|\"()\"" "|\"()\"")
+ ("\"(|)\"" "\"|()\"" "|\"()\"" "|\"()\"")
+ ("\"()\"|" "|\"()\"" "|\"()\"")
+
+ ("|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(|\"x\" \"y\")" "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"|x\" \"y\")" "(|\"x\" \"y\")" "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x|\" \"y\")" "(\"|x\" \"y\")" "(|\"x\" \"y\")"
+ "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x\"| \"y\")" "(|\"x\" \"y\")" "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x\" |\"y\")" "(|\"x\" \"y\")" "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x\" \"|y\")" "(\"x\" |\"y\")" "(|\"x\" \"y\")"
+ "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x\" \"y|\")" "(\"x\" \"|y\")" "(\"x\" |\"y\")" "(|\"x\" \"y\")"
+ "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x\" \"y\"|)" "(\"x\" |\"y\")" "(|\"x\" \"y\")"
+ "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+ ("(\"x\" \"y\")|" "|(\"x\" \"y\")" "|(\"x\" \"y\")")
+
+ ("|#\\(" "|#\\(")
+ ("#|\\(" "|#\\(" "|#\\(")
+ ("#\\|(" "|#\\(" "|#\\(")
+ ("#\\(|" "|#\\(" "|#\\(")
+
+ ("|#\\)" "|#\\)")
+ ("#|\\)" "|#\\)" "|#\\)")
+ ("#\\|)" "|#\\)" "|#\\)")
+ ("#\\)|" "|#\\)" "|#\\)")
+
+ ("|#\\\\" "|#\\\\")
+ ("#|\\\\" "|#\\\\" "|#\\\\")
+ ("#\\|\\" "|#\\\\" "|#\\\\")
+ ("#\\\\|" "|#\\\\" "|#\\\\")
+
+ ("|#\\;" "|#\\;")
+ ("#|\\;" "|#\\;" "|#\\;")
+ ("#\\|;" "|#\\;" "|#\\;")
+ ("#\\;|" "|#\\;" "|#\\;")))
+
(defun paredit-canary-indent-method (state indent-point normal-indent)
(check-parens)
nil)
- [nongnu] elpa/paredit 88a5cf7 139/224: Be explicit about Transient Mark Mode in `paredit-wrap-*' tests., (continued)
- [nongnu] elpa/paredit 88a5cf7 139/224: Be explicit about Transient Mark Mode in `paredit-wrap-*' tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit d80a9db 141/224: Fail early in `paredit-convolute-sexp'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2ec6000 145/224: Fix error message in `paredit-test'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6f2677b 148/224: Tweak `paredit-convolute-sexp' a little and add some tests for it., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit d54ea28 149/224: Add a trivial shell script to generate paredit.html., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 540bc9c 153/224: Remove unnecessarily nasty text about reporting bugs., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b02f509 156/224: New file NEWS from paredit.release., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b647a1a 158/224: Bump copyright year on test.el to 2013., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f25cd3b 159/224: Add a zillion paredit-kill tests. Fix a tiny bug they revealed., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 460254d 162/224: Fix paredit-doublequote inside a string escape., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit db82936 163/224: Make `paredit-forward' and `paredit-backward' move out of strings.,
ELPA Syncer <=
- [nongnu] elpa/paredit 18cf19f 164/224: Implement `paredit-preserving-column'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5840f55 165/224: Preserve column better in `paredit-join'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 9838fe2 174/224: In check.sh, use $EMACS if set, defaulting to `emacs'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 3bdd840 175/224: Rework paredit-semicolon and add some tests for it., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 014cdfe 177/224: Handle shift selection in motion commands in recent GNU Emacs., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit be28e85 178/224: Mention shift selection for motion commands in NEWS., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 42a0494 179/224: Use $EMACS in genhtml.sh too., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 856d927 180/224: Use `paredit-preserving-column' in `paredit-reindent-defun'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a26c148 182/224: Bind M-[ to paredit-wrap-square., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4e5ba81 184/224: Make slurping `(|) foo' yield `(|foo)', not `(| foo)'., ELPA Syncer, 2021/08/07