[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 70d40b5 040/224: Refine scope of reindentation aft
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 70d40b5 040/224: Refine scope of reindentation after raise, splice, and insert-comment. |
Date: |
Sat, 7 Aug 2021 09:22:14 -0400 (EDT) |
branch: elpa/paredit
commit 70d40b5891cbd8eb4ff495a375bf330c97ce6ab5
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Refine scope of reindentation after raise, splice, and insert-comment.
Ignore-this: 6213d7fb22c1c4598b6956b161be2cac
darcs-hash:20100917202224-00fcc-610a9beb07c348babc652e7dee8519f01b06a6a3
---
paredit.el | 71 +++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 40 insertions(+), 31 deletions(-)
diff --git a/paredit.el b/paredit.el
index c1f3936..ce8ea88 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1091,7 +1091,7 @@ This is expected to be called only in
`paredit-comment-dwim'; do not
(save-excursion
(newline)
(lisp-indent-line)
- (paredit-ignore-sexp-errors (indent-sexp)))))
+ (paredit-indent-sexps))))
(t
;; Margin comment
(indent-to comment-column 1) ; 1 -> force one leading space
@@ -1643,16 +1643,23 @@ Inside a string, unescape all backslashes, or signal an
error if doing
(interactive "P")
(if (paredit-in-string-p)
(paredit-splice-string argument)
- (save-excursion
- (paredit-kill-surrounding-sexps-for-splice argument)
- (backward-up-list) ; Go up to the beginning...
(save-excursion
- (forward-sexp) ; Go forward an expression, to
- (backward-delete-char 1)) ; delete the end delimiter.
- (delete-char 1) ; ...to delete the open char.
- (paredit-ignore-sexp-errors
- (backward-up-list) ; Reindent, now that the
- (indent-sexp))))) ; structure has changed.
+ (paredit-kill-surrounding-sexps-for-splice argument)
+ (let ((end (point)))
+ (backward-up-list) ; Go up to the beginning...
+ (save-excursion
+ (forward-char 1) ; (Skip over leading whitespace
+ (paredit-skip-whitespace t end)
+ (setq end (point))) ; for the `delete-region'.)
+ (let ((indent-start nil) (indent-end nil))
+ (save-excursion
+ (setq indent-start (point))
+ (forward-sexp) ; Go forward an expression, to
+ (backward-delete-char 1) ; delete the end delimiter.
+ (setq indent-end (point)))
+ (delete-region (point) end) ; ...to delete the open char.
+ ;; Reindent only the region we preserved.
+ (indent-region indent-start indent-end))))))
(defun paredit-kill-surrounding-sexps-for-splice (argument)
(cond ((or (paredit-in-string-p)
@@ -1704,13 +1711,13 @@ With a prefix argument N, kill only the following N
S-expressions."
(- (prefix-numeric-value n))
'(16))))
-(defun paredit-raise-sexp (&optional n)
+(defun paredit-raise-sexp (&optional argument)
"Raise the following S-expression in a tree, deleting its siblings.
With a prefix argument N, raise the following N S-expressions. If N
is negative, raise the preceding N S-expressions.
If the point is on an S-expression, such as a string or a symbol, not
between them, that S-expression is considered to follow the point."
- (interactive "p")
+ (interactive "P")
(save-excursion
(cond ((paredit-in-string-p)
(goto-char (car (paredit-string-start+end-points))))
@@ -1719,21 +1726,19 @@ If the point is on an S-expression, such as a string or
a symbol, not
((paredit-in-comment-p)
(error "No S-expression to raise in comment.")))
;; Select the S-expressions we want to raise in a buffer substring.
- (let* ((bound (save-excursion (forward-sexp n) (point)))
- (sexps (if (and n (< n 0))
- (buffer-substring bound
- (paredit-point-at-sexp-end))
- (buffer-substring (paredit-point-at-sexp-start)
- bound))))
+ (let* ((n (prefix-numeric-value argument))
+ (bound (scan-sexps (point) n))
+ (sexps
+ (if (< n 0)
+ (buffer-substring bound (paredit-point-at-sexp-end))
+ (buffer-substring (paredit-point-at-sexp-start) bound))))
;; Move up to the list we're raising those S-expressions out of and
;; delete it.
(backward-up-list)
- (delete-region (point) (save-excursion (forward-sexp) (point)))
- (save-excursion (insert sexps)) ; Insert & reindent the sexps.
- (save-excursion (let ((n (abs (or n 1))))
- (while (> n 0)
- (paredit-forward-and-indent)
- (setq n (1- n))))))))
+ (delete-region (point) (scan-sexps (point) 1))
+ (let* ((indent-start (point))
+ (indent-end (save-excursion (insert sexps) (point))))
+ (indent-region indent-start indent-end)))))
(defun paredit-convolute-sexp (&optional n)
"Convolute S-expressions.
@@ -2075,14 +2080,18 @@ Assumes that `paredit-in-string-p' is false, so that it
need not handle
(and (eq (char-before argument) ?\\ )
(not (eq (char-before (1- argument)) ?\\ )))))
+(defun paredit-indent-sexps ()
+ "If in a list, indent all following S-expressions in the list."
+ (let ((start (point))
+ (end (paredit-handle-sexp-errors (progn (up-list) (point)) nil)))
+ (if end
+ (indent-region start end))))
+
(defun paredit-forward-and-indent ()
- "Move forward an S-expression, indenting it fully.
-Indent with `lisp-indent-line' and then `indent-sexp'."
- (forward-sexp) ; Go forward, and then find the
- (save-excursion ; beginning of this next
- (backward-sexp) ; S-expression.
- (lisp-indent-line) ; Indent its opening line, and
- (indent-sexp))) ; the rest of it.
+ "Move forward an S-expression, indenting it with `indent-region'."
+ (let ((start (point)))
+ (forward-sexp)
+ (indent-region start (point))))
(defun paredit-skip-whitespace (trailing-p &optional limit)
"Skip past any whitespace, or until the point LIMIT is reached.
- [nongnu] elpa/paredit 38690fe 209/224: Bump copyright year to 2016., (continued)
- [nongnu] elpa/paredit 38690fe 209/224: Bump copyright year to 2016., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 3889955 212/224: Don't reindent single-line edits in paredit-raise-sexp., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 961b02f 217/224: Ignore unused argument in paredit-override-check-parens-interactively, ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 27548db 220/224: Disable minibuffer message delays in tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b1c332a 218/224: Bump copyright year., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 09658a4 221/224: Trailing newline., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit dc60d93 029/224: Document the effect of a prefix argument to the `paredit-mode' command., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 190797e 030/224: Add warning to documentation of prefix arguments to `paredit-mode'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 41a0a34 033/224: Omit unused variable `orig' in `paredit-move-past-close-and-reindent'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 04e6f50 035/224: Put space between closing delimiters and opening double quotes., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 70d40b5 040/224: Refine scope of reindentation after raise, splice, and insert-comment.,
ELPA Syncer <=
- [nongnu] elpa/paredit 896c165 039/224: Implement variable `paredit-space-for-delimiter-predicates'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit e23adec 036/224: Omit vestigial debug message in `paredit-backward-slurp-into-string'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit c0a9160 041/224: Make `paredit-newline' keep invalid structure inside comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 05b2cad 043/224: Generalize `paredit-kill' to work inside any string-like object., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit e380e42 048/224: Implement `paredit-{for, back}ward-{up, down}'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 3ce96a4 050/224: Fix format arguments in `paredit-check-region-state-comment'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 73c481a 061/224: Simplify and clarify implementation of `paredit-backslash'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b51f220 055/224: In `paredit-newline', ignore parse errors during `indent-sexp'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 0011090 066/224: Fix bounds checking in `paredit-find-next-string-start'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit bd0e5ba 072/224: Don't mask errors during `buffer-string' in `paredit-unescape-string'., ELPA Syncer, 2021/08/07