summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2011-04-11 22:53:16 +0000
committerTaylor R Campbell <campbell@mumble.net>2011-04-11 22:53:16 +0000
commitd1b562b9c81c5582f943e2a8958fb96f9820f420 (patch)
tree611fff63b44a34120f748d78360b88956fda0a67
parent4723fb37b2be84f6ccaac640f33cff893cb9bc3e (diff)
Fix `paredit-backslash' within a character literal.
Ignore-this: ce30323a4077d83acc1967af18604e40 Put the new escape after the one the point is on; don't split it. darcs-hash:20110411225316-00fcc-1c65c221a9878047104d5fed02a60f48f0641f7b
-rw-r--r--paredit.el38
1 files changed, 20 insertions, 18 deletions
diff --git a/paredit.el b/paredit.el
index b13ca92..611c9b6 100644
--- a/paredit.el
+++ b/paredit.el
@@ -966,25 +966,27 @@ If not in a string, act as `paredit-doublequote'; if no prefix argument
(defun paredit-backslash ()
"Insert a backslash followed by a character to escape."
(interactive)
+ (cond ((paredit-in-string-p) (paredit-backslash-interactive))
+ ((paredit-in-comment-p) (insert ?\\))
+ ((paredit-in-char-p) (forward-char) (paredit-backslash-interactive))
+ (t (paredit-backslash-interactive))))
+
+(defun paredit-backslash-interactive ()
(insert ?\\ )
- ;; 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)))
- ;; 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 "Character to escape: ")))
- (if (not (eq char ?\^?))
- (progn (message "Character to escape: %c" char)
- (insert char)
- (setq delete-p nil))))
- (if delete-p
- (progn (message "Deleting escape.")
- (backward-delete-char 1)))))))
+ ;; 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 "Character to escape: ")))
+ (if (not (eq char ?\^?))
+ (progn (message "Character to escape: %c" char)
+ (insert char)
+ (setq delete-p nil))))
+ (if delete-p
+ (progn (message "Deleting escape.")
+ (backward-delete-char 1))))))
(defun paredit-newline ()
"Insert a newline and indent it.