Subject: bug#26187: Bug in indent-sexp

From: Gdobbins <[email-masked]>
Date: Sun, 19 Mar 2017 21:18:09 -0400

The refactor of indent-sexp in commit 3ee3995d105ff02f0fac540757431d36cb45c6c7 broke the assumption

;; If ENDPOS is nil, it is safe not to scan before point
;; since every line we indent is more deeply nested than point is.

thereby breaking functionality in paredit. The attached patch fixes this.

-- Graham Dobbins

From aac47fbcdc6175ead9caf9f903f24100a2805ccc Mon Sep 17 00:00:00 2001
From: Graham Dobbins <[email-masked]>
Date: Sun, 19 Mar 2017 21:06:18 -0400
Subject: [PATCH] * lisp/emacs-lisp/lisp-mode.el (indent-sexp): Fix null endpos
 case

---
 lisp/emacs-lisp/lisp-mode.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index eb07c18b03..d6293c0304 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1083,7 +1083,8 @@ indent-sexp
          (init-depth (car state))
          (next-depth init-depth)
          (last-depth init-depth)
-         (last-syntax-point (point)))
+         (last-syntax-point (point))
+         (real-endpos endpos))
     (unless endpos
       ;; Get error now if we don't have a complete sexp after point.
       (save-excursion (forward-sexp 1)
@@ -1116,6 +1117,8 @@ indent-sexp
                 last-depth (- last-depth next-depth)
                 next-depth init-depth))
         (forward-line 1)
+        (when (and (not real-endpos) (<= next-depth init-depth))
+          (goto-char endpos))
         (when (< (point) endpos)
           (let ((depth-delta (- next-depth last-depth)))
             (cond ((< depth-delta 0)
-- 
2.12.0