- (let ((deleted-paren-pos
- (save-excursion
- (beginning-of-line)
- ;; Account for edge case when point has no sexp before it
- ;;
- ;; This is primarily to avoid funny behavior when there
- ;; is no sexp between bob and point.
- (if (not (adjust-parens-check-prior-sexp))
- nil
- ;; If the sexp at point is a list,
- ;; delete its closing paren
- (when (eq (scan-lists (point) 1 0)
- (scan-sexps (point) 1))
- (forward-sexp)
- (delete-char -1)
- (point))))))
+ (let* ((deleted-paren-char nil)
+ (deleted-paren-pos
+ (save-excursion
+ (beginning-of-line)
+ ;; Account for edge case when point has no sexp before it
+ ;;
+ ;; This is primarily to avoid funny behavior when there
+ ;; is no sexp between bob and point.
+ (if (not (adjust-parens-check-prior-sexp))
+ nil
+ ;; If the sexp at point is a list,
+ ;; delete its closing paren
+ (when (eq (scan-lists (point) 1 0)
+ (scan-sexps (point) 1))
+ (forward-sexp)
+ (setq deleted-paren-char (char-before))
+ (delete-char -1)
+ (point))))))
+ ;; Invariant: deleted-paren-pos nil iff deleted-paren-char nil