[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 30f564d 051/224: Add utilities for `check-parens'
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 30f564d 051/224: Add utilities for `check-parens' restricted to a region. |
Date: |
Sat, 7 Aug 2021 09:22:17 -0400 (EDT) |
branch: elpa/paredit
commit 30f564df98cad42fb61cd021c10b1caf47cf7b62
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Add utilities for `check-parens' restricted to a region.
Ignore-this: e5cd5cbea4e5866aec9e657902fd9663
darcs-hash:20100920205549-00fcc-0855cb26399bc060cb863c14bc794166505b9982
---
paredit.el | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/paredit.el b/paredit.el
index 1660bbb..f32ae46 100644
--- a/paredit.el
+++ b/paredit.el
@@ -986,16 +986,7 @@ If in a comment and if followed by invalid structure, call
(cond ((paredit-in-string-p)
(newline))
((paredit-in-comment-p)
- (if (paredit-handle-sexp-errors
- ;; Check for anything that would break structure in
- ;; the comment.
- (save-restriction
- (narrow-to-region (point) (point-at-eol))
- (save-excursion
- (while (< (point) (point-max))
- (forward-sexp)))
- t)
- nil)
+ (if (paredit-region-ok-p (point) (point-at-eol))
(progn (newline-and-indent) (indent-sexp))
(indent-new-comment-line)))
(t
@@ -1613,15 +1604,7 @@ If the text of the region is imbalanced, signal an error
instead.
With a prefix argument, disregard any imbalance."
(interactive "r")
(if (not current-prefix-arg)
- ;; Check that the region is balanced.
- (save-restriction
- (narrow-to-region beginning end)
- (if (fboundp 'check-parens)
- (check-parens)
- (save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (forward-sexp))))))
+ (paredit-check-region beginning end))
(setq this-command 'kill-ring-save)
(kill-ring-save beginning end))
@@ -2472,7 +2455,7 @@ If no parse state is supplied, compute one from the
beginning of the
;; else an integer (the current comment nesting)
(and (nth 4 (or state (paredit-current-parse-state)))
t))
-
+
(defun paredit-point-at-sexp-boundary (n)
(cond ((< n 0) (paredit-point-at-sexp-start))
((= n 0) (point))
@@ -2495,6 +2478,30 @@ If no parse state is supplied, compute one from the
beginning of the
(paredit-in-comment-p)
(paredit-in-char-p))
(error "Invalid context for command `%s'." command)))
+
+(defun paredit-check-region (start end)
+ (save-restriction
+ (narrow-to-region start end)
+ (if (fboundp 'check-parens)
+ (check-parens)
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (forward-sexp))))))
+
+(defun paredit-region-ok-p (start end)
+ (paredit-handle-sexp-errors
+ (progn
+ (save-restriction
+ (narrow-to-region start end)
+ ;; Can't use `check-parens' here -- it signals the wrong kind
+ ;; of errors.
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (forward-sexp))))
+ t)
+ nil))
;;;; Initialization
- [nongnu] elpa/paredit 8ab1694 022/224: Change `paredit-comment-on-line-p' to use `comment-search-forward'., (continued)
- [nongnu] elpa/paredit 8ab1694 022/224: Change `paredit-comment-on-line-p' to use `comment-search-forward'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit e121b92 024/224: Clarify `paredit-insert-comment' and change its criteria for code comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 451ea5e 025/224: Add magic autoload comment for `paredit-mode'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a386bdf 031/224: Call `end-of-defun' in `paredit-reindent-defun'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 0d7a39d 032/224: Un-deprecate `enable-paredit-mode' and `disable-paredit-mode'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit db3a581 037/224: Switch copying terms to GPLv3+., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit ab99e93 044/224: Simplify definition of `paredit-kill-line-in-string'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5bfc873 047/224: Fix `paredit-copy-as-kill' within strings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit d265584 045/224: Fix `paredit-kill' on whitespace character literal with margin comment., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 7b31864 046/224: Check `eolp' before using `char-after' in `paredit-kill'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 30f564d 051/224: Add utilities for `check-parens' restricted to a region.,
ELPA Syncer <=
- [nongnu] elpa/paredit d3723a0 059/224: Tweak second page. Remove rants and IRC reference., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 89aa6fb 057/224: Eliminate non-interactive use of `goto-line'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b9f46b5 060/224: Rework third page to make it much more readable., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 24d2ade 053/224: Bump version: 22 beta -> 22., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 79fd488 058/224: Bump copyright year to 2011., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit c655f5c 052/224: Change header and footer to conform to elisp guidelines., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2b094af 065/224: Bind M-? to `paredit-convolute-sexp'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4d6f3fc 090/224: Fix `imbalanced' -> `unbalanced' in `paredit-kill-region' docstring., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 52670b7 079/224: Fix spacing in `paredit-newline' example., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit bd439e3 083/224: Avoid trailing space when `paredit-comment-dwim' inserts code comments., ELPA Syncer, 2021/08/07