emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/paredit 73c481a 061/224: Simplify and clarify implementati


From: ELPA Syncer
Subject: [nongnu] elpa/paredit 73c481a 061/224: Simplify and clarify implementation of `paredit-backslash'.
Date: Sat, 7 Aug 2021 09:22:19 -0400 (EDT)

branch: elpa/paredit
commit 73c481aad0af84f01649d8f1616c0d022aca9c42
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>

    Simplify and clarify implementation of `paredit-backslash'.
    
    Ignore-this: a59b556bdad0266cec90303f6864738e
    
    darcs-hash:20110320171404-00fcc-87038309e85fdc70dbbb48714769decf4317e3bb
---
 paredit.el | 41 ++++++++++++++---------------------------
 1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/paredit.el b/paredit.el
index 35265bc..2f6a0f1 100644
--- a/paredit.el
+++ b/paredit.el
@@ -932,35 +932,22 @@ If not in a string, act as `paredit-doublequote'; if no 
prefix argument
   "Insert a backslash followed by a character to escape."
   (interactive)
   (insert ?\\ )
-  ;; This funny conditional is necessary because PAREDIT-IN-COMMENT-P
-  ;; assumes that PAREDIT-IN-STRING-P already returned false; otherwise
-  ;; it may give erroneous answers.
+  ;; Can't call `paredit-in-comment-p' unless `paredit-in-string-p'
+  ;; gives false.  Read this as simply (not (paredit-in-comment-p)).
   (if (or (paredit-in-string-p)
           (not (paredit-in-comment-p)))
-      (let ((delp t))
-        (unwind-protect (setq delp
-                              (call-interactively 'paredit-escape))
-          ;; We need this in an UNWIND-PROTECT so that the backlash is
-          ;; left in there *only* if PAREDIT-ESCAPE return NIL normally
-          ;; -- in any other case, such as the user hitting C-g or an
-          ;; error occurring, we must delete the backslash to avoid
-          ;; leaving a dangling escape.  (This control structure is a
-          ;; crock.)
-          (if delp (backward-delete-char 1))))))
-
-;;; This auxiliary interactive function returns true if the backslash
-;;; should be deleted and false if not.
-
-(defun paredit-escape (char)
-  ;; I'm too lazy to figure out how to do this without a separate
-  ;; interactive function.
-  (interactive "cEscaping character...")
-  (if (eq char 127)                     ; The backslash was a typo, so
-      t                                 ; the luser wants to delete it.
-    (insert char)                       ; (Is there a better way to
-    nil))                               ; express the rubout char?
-                                        ; ?\^? works, but ugh...)
-
+      ;; Read a character to insert after the backslash.  If anything
+      ;; goes wrong -- the user hits delete (entering the rubout
+      ;; `character'), aborts with C-g, or enters non-character input
+      ;; -- then delete the backslash to avoid a dangling escape.
+      (let ((delete-p t))
+        (unwind-protect
+            (let ((char (read-char "Escaping character...")))
+              (if (not (eq char ?\^?))
+                  (progn (insert char) (setq delete-p nil))))
+          (if delete-p
+              (backward-delete-char 1))))))
+
 (defun paredit-newline ()
   "Insert a newline and indent it.
 This is like `newline-and-indent', but it not only indents the line



reply via email to

[Prev in Thread] Current Thread [Next in Thread]