From e436c58e6b6c9fefac7b85ff90858cec3c10d6ab Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 25 Feb 2025 20:38:12 +0100 Subject: [PATCH] * lisp/emacs-lisp/lisp-mode.el (lisp-tidy-sexp): Fix infloop. --- lisp/emacs-lisp/lisp-mode.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 76cb059a2a7..8ae1e7f4e04 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -937,9 +937,13 @@ font-lock keywords will not be case sensitive." (scan-error nil)) (when (< fill-column (current-column)) (backward-sexp) - (delete-horizontal-space) - (insert "\n")) - (indent-according-to-mode) + (if (equal (point) (save-excursion (back-to-indentation) (point))) + ;; First expression in this line, a newline won't help. + ;; Give up and move back forward. + (forward-sexp) + ;; Break line. + (delete-horizontal-space) + (insert "\n"))) (delete-horizontal-space) (cond ((eq (char-after) ?\;) @@ -949,7 +953,9 @@ font-lock keywords will not be case sensitive." (t (insert " ")))) (delete-all-space) (when (eq (char-after) ?\;) - (comment-indent)))) + (comment-indent)) + (indent-region (car (reverse (nth 9 (syntax-ppss)))) + (progn (up-list) (point))))) (defun lisp-slurp-forward (n) (interactive "p") -- 2.39.5