From d1b562b9c81c5582f943e2a8958fb96f9820f420 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 11 Apr 2011 22:53:16 +0000 Subject: 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 --- paredit.el | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'paredit.el') 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. -- cgit v1.2.1