From: Eshel Yaron Date: Tue, 25 Feb 2025 19:38:12 +0000 (+0100) Subject: * lisp/emacs-lisp/lisp-mode.el (lisp-tidy-sexp): Fix infloop. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e436c58e6b6c9fefac7b85ff90858cec3c10d6ab;p=emacs.git * lisp/emacs-lisp/lisp-mode.el (lisp-tidy-sexp): Fix infloop. --- 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")