[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit f27c480 070/224: Implement `paredit-override-check
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit f27c480 070/224: Implement `paredit-override-check-parens-function'. |
Date: |
Sat, 7 Aug 2021 09:22:21 -0400 (EDT) |
branch: elpa/paredit
commit f27c480fdb1f525177036f93cab454a40197df4e
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Implement `paredit-override-check-parens-function'.
Ignore-this: 8fa60f5bd8c398aa31f91b26c4affb12
Set to `paredit-override-check-parens-interactively' if you want to
be prompted whether to enable Paredit Mode rather than to have `M-x
paredit-mode RET' simply barf if there are unbalanced parentheses.
(Someone suggested this to me months ago, but I have forgotten who.)
Assume we have `check-parens'. No more GNU Emacs 20.
darcs-hash:20110320185342-00fcc-30abf28738cf76cca1d16f02b2f26f3f46525c44
---
paredit.el | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/paredit.el b/paredit.el
index 726fd09..4c4f9e2 100644
--- a/paredit.el
+++ b/paredit.el
@@ -210,6 +210,10 @@ Signal an error if no clause matches."
(defvar paredit-mode-map (make-sparse-keymap)
"Keymap for the paredit minor mode.")
+(defvar paredit-override-check-parens-function
+ (lambda (condition) condition nil)
+ "Function to tell whether unbalanced text should inhibit Paredit Mode.")
+
;;;###autoload
(define-minor-mode paredit-mode
"Minor mode for pseudo-structurally editing Lisp code.
@@ -220,21 +224,18 @@ Paredit behaves badly if parentheses are imbalanced, so
exercise
fixing imbalanced parentheses instead.
\\<paredit-mode-map>"
:lighter " Paredit"
- ;; If we're enabling paredit-mode, the prefix to this code that
- ;; DEFINE-MINOR-MODE inserts will have already set PAREDIT-MODE to
- ;; true. If this is the case, then first check the parentheses, and
- ;; if there are any imbalanced ones we must inhibit the activation of
- ;; paredit mode. We skip the check, though, if the user supplied a
- ;; prefix argument interactively.
+ ;; Setting `paredit-mode' to false here aborts enabling Paredit Mode.
(if (and paredit-mode
(not current-prefix-arg))
- (if (not (fboundp 'check-parens))
- (paredit-warn "`check-parens' is not defined; %s"
- "be careful of malformed S-expressions.")
- (condition-case condition
- (check-parens)
- (error (setq paredit-mode nil)
- (signal (car condition) (cdr condition)))))))
+ (condition-case condition
+ (check-parens)
+ (error
+ (if (not (funcall paredit-override-check-parens-function condition))
+ (progn (setq paredit-mode nil)
+ (signal (car condition) (cdr condition))))))))
+
+(defun paredit-override-check-parens-interactively (condition)
+ (y-or-n-p (format "Enable Paredit Mode despite condition %S? " condition)))
(defun enable-paredit-mode ()
"Turn on pseudo-structural editing of Lisp code."
- [nongnu] branch elpa/paredit created (now 8330a41), ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit de45eb6 005/224: Changes for version 9., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 9464588 016/224: Changes for version 20., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 0ada66e 023/224: Update the compatibility and compiler warning suppression hacks for Emacs 22., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f7c26b9 027/224: Fix kill & yank errors with `paredit-lose-if-not-in-sexp' while barfing., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 929e547 038/224: Fix some opening remarks about enabling paredit mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 90c7eda 042/224: Revive `paredit-semicolon', with better behaviour., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a26a9a7 075/224: Permit joining adjacent lists without intervening whitespace., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f27c480 070/224: Implement `paredit-override-check-parens-function'.,
ELPA Syncer <=
- [nongnu] elpa/paredit 67caf7e 071/224: Eliminate fboundp check for `check-parens' in `paredit-check-region'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit ae53a2c 077/224: Show point in `paredit-semicolon' example., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 26a3ddb 085/224: Add `paredit-doublequote' examples at end of string and in comment., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 33463ae 102/224: Third argument to `indent-region' is not optional in GNU Emacs 21., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit c91bc2f 099/224: Fix bug in change to check structure in backward-delete of comment end., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 7e3b3f0 096/224: In `paredit-recenter-on-sexp', handle S-expressions larger than screen., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6918d89 108/224: Don't indent while the buffer is in intermediate broken states., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit adfccc5 123/224: Check `paredit-kill' in a comment more carefully., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 23afafc 128/224: Add some trivial tests for region deletion/killing commands., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2e61740 134/224: Fix docstring of `paredit-check-region-for-delete'., ELPA Syncer, 2021/08/07