Subject: bug#4136: 23.1; delete-pair

From: martin rudalics <[email-masked]>
Date: Tue, 18 Aug 2009 09:13:34 +0200

> We are in violent agreement.  I didn't claim that `delete-pair'
 > shouldn't check `insert-pair-alist'.  On the contrary, I think
 > `delete-pair' should verify if the character pair starting at the
 > current point is part of a pair according to `insert-pair-alist'.
 > "At the current point" - that's my point.  It shouldn't try
 > finding the opening character somewhere else.  So in your original
 > test case it should throw an error when the cursor is on some
 > whitespace that precedes an expression.

Ne hlebom jedinnym.  Why can't we be generous and provide something like
the attached?

martin
*** emacs-lisp/lisp.el.~1.102.~	2009-07-27 08:10:54.124527300 +0200
--- emacs-lisp/lisp.el	2009-08-18 08:52:42.734375000 +0200
***************
*** 527,537 ****
    (interactive "P")
    (insert-pair arg ?\( ?\)))
  
! (defun delete-pair ()
!   "Delete a pair of characters enclosing the sexp that follows point."
!   (interactive)
!   (save-excursion (forward-sexp 1) (delete-char -1))
!   (delete-char 1))
  
  (defun raise-sexp (&optional arg)
    "Raise ARG sexps higher up the tree."
--- 527,566 ----
    (interactive "P")
    (insert-pair arg ?\( ?\)))
  
! (defun delete-pair (&optional arg)
!   "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."