mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-12 09:28:24 +00:00
Make delete-pair only delete pairs that are part of insert-pair-alist
* lisp/emacs-lisp/lisp.el (delete-pair): Only delete pairs that are part of `insert-pair-alist' (bug#4136).
This commit is contained in:
parent
73f77558cc
commit
10696d0ac5
@ -735,12 +735,37 @@ This command assumes point is not in a string or comment."
|
||||
(insert-pair arg ?\( ?\)))
|
||||
|
||||
(defun delete-pair (&optional arg)
|
||||
"Delete a pair of characters enclosing ARG sexps following point.
|
||||
A negative ARG deletes a pair of characters around preceding ARG sexps."
|
||||
(interactive "p")
|
||||
(unless arg (setq arg 1))
|
||||
(save-excursion (forward-sexp arg) (delete-char (if (> arg 0) -1 1)))
|
||||
(delete-char (if (> arg 0) 1 -1)))
|
||||
"Delete a pair of characters enclosing ARG sexps that follow point.
|
||||
A negative ARG deletes a pair around the preceding ARG sexps instead."
|
||||
(interactive "P")
|
||||
(if arg
|
||||
(setq arg (prefix-numeric-value arg))
|
||||
(setq arg 1))
|
||||
(if (< arg 0)
|
||||
(save-excursion
|
||||
(skip-chars-backward " \t")
|
||||
(save-excursion
|
||||
(let ((close-char (char-before)))
|
||||
(forward-sexp arg)
|
||||
(unless (member (list (char-after) close-char)
|
||||
(mapcar (lambda (p)
|
||||
(if (= (length p) 3) (cdr p) p))
|
||||
insert-pair-alist))
|
||||
(error "Not after matching pair"))
|
||||
(delete-char 1)))
|
||||
(delete-char -1))
|
||||
(save-excursion
|
||||
(skip-chars-forward " \t")
|
||||
(save-excursion
|
||||
(let ((open-char (char-after)))
|
||||
(forward-sexp arg)
|
||||
(unless (member (list open-char (char-before))
|
||||
(mapcar (lambda (p)
|
||||
(if (= (length p) 3) (cdr p) p))
|
||||
insert-pair-alist))
|
||||
(error "Not before matching pair"))
|
||||
(delete-char -1)))
|
||||
(delete-char 1))))
|
||||
|
||||
(defun raise-sexp (&optional arg)
|
||||
"Raise ARG sexps higher up the tree."
|
||||
|
@ -136,8 +136,7 @@
|
||||
(text-mode)
|
||||
(insert "\"foo\"")
|
||||
(goto-char (point-min))
|
||||
(delete-pair)
|
||||
(should (string-equal "fo\"" (buffer-string)))))
|
||||
(should-error (delete-pair))))
|
||||
|
||||
(ert-deftest lisp-delete-pair-quotes-text-mode-syntax-table ()
|
||||
"Test \\[delete-pair] with modified Text Mode syntax for #15014."
|
||||
|
Loading…
Reference in New Issue
Block a user