diff options
| author | Taylor R Campbell <campbell@mumble.net> | 2011-03-20 17:14:04 +0000 | 
|---|---|---|
| committer | Taylor R Campbell <campbell@mumble.net> | 2011-03-20 17:14:04 +0000 | 
| commit | 73c481aad0af84f01649d8f1616c0d022aca9c42 (patch) | |
| tree | 1dcef39d636645791b9629d929f646580c1c2cb9 | |
| parent | b9f46b509bc144f31c8ac707a83d8cfba0b47096 (diff) | |
Simplify and clarify implementation of `paredit-backslash'.
Ignore-this: a59b556bdad0266cec90303f6864738e
darcs-hash:20110320171404-00fcc-87038309e85fdc70dbbb48714769decf4317e3bb
| -rw-r--r-- | paredit.el | 41 | 
1 files changed, 14 insertions, 27 deletions
| @@ -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 | 
