Skip to content

Commit

Permalink
Let C-d and DEL delete the other spurious delimiters too.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor R Campbell committed Jan 28, 2014
1 parent c39e485 commit 67d6a4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
21 changes: 18 additions & 3 deletions paredit.el
Original file line number Diff line number Diff line change
Expand Up @@ -1228,11 +1228,18 @@ With a `C-u' prefix argument, simply delete a character forward,
(delete-char +1)) ; delimiters.
((eq ?\; (char-after))
(paredit-forward-delete-comment-start))
((eq (char-syntax (char-after)) ?\) )
(if (paredit-handle-sexp-errors
(save-excursion (forward-char) (backward-sexp) t)
nil)
(message "End of list!")
(progn
(message "Deleting spurious closing delimiter.")
(delete-char +1))))
;; Just delete a single character, if it's not a closing
;; delimiter. (The character literal case is already handled
;; by now.)
((not (eq (char-syntax (char-after)) ?\) ))
(delete-char +1))))
(t (delete-char +1))))

(defun paredit-forward-delete-in-string ()
(let ((start+end (paredit-string-start+end-points)))
Expand Down Expand Up @@ -1320,9 +1327,17 @@ With a `C-u' prefix argument, simply delete a character backward,
(delete-char +1)) ; delimiters.
((bolp)
(paredit-backward-delete-maybe-comment-end))
((eq (char-syntax (char-before)) ?\( )
(if (paredit-handle-sexp-errors
(save-excursion (backward-char) (forward-sexp) t)
nil)
(message "Beginning of list!")
(progn
(message "Deleting spurious closing delimiter.")
(delete-char -1))))
;; Delete it, unless it's an opening delimiter. The case of
;; character literals is already handled by now.
((not (eq (char-syntax (char-before)) ?\( ))
(t
;; Turn off the @#&*&!^&(%^ botch in GNU Emacs 24 that changed
;; `backward-delete-char' and `backward-delete-char-untabify'
;; semantically so that they delete the region in transient
Expand Down
8 changes: 6 additions & 2 deletions test.el
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ Four arguments: the paredit command, the text of the buffer
("|\\\\\\\\" "|\\\\" "|" error)
("\\\\|\\\\" "\\\\|" error)
("(|\\\\\\\\)" "(|\\\\)" "(|)" "|" error)
("(\\\\|\\\\)" "(\\\\|)" "(\\\\|)")))
("(\\\\|\\\\)" "(\\\\|)" "(\\\\|)")
("|(" "|" error)
("|)" "|" error)))

(paredit-test 'paredit-backward-delete
'(("fo|o" "f|o")
Expand All @@ -304,7 +306,9 @@ Four arguments: the paredit command, the text of the buffer
("\\\\\\\\|" "\\\\|" "|" error)
("\\\\|\\\\" "|\\\\" error)
("(\\\\\\\\|)" "(\\\\|)" "(|)" "|" error)
("(\\\\|\\\\)" "(|\\\\)" "(|\\\\)")))
("(\\\\|\\\\)" "(|\\\\)" "(|\\\\)")
("(|" "|" error)
(")|" "|" error)))

(dolist (command '(paredit-delete-region paredit-kill-region))
;++ Need to check whether `paredit-kill-region' updates the kill ring
Expand Down

0 comments on commit 67d6a4f

Please sign in to comment.