]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'lisp-kill-line' with point before comment
authorEshel Yaron <me@eshelyaron.com>
Sun, 16 Mar 2025 17:02:35 +0000 (18:02 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 16 Mar 2025 17:02:35 +0000 (18:02 +0100)
lisp/emacs-lisp/lisp-mode.el

index 3d9dd12a2abc531489f904c2c7ab6885f0e5f3de..450782c1af5729c3e2d110551017d049a1df8022 100644 (file)
@@ -922,19 +922,21 @@ font-lock keywords will not be case sensitive."
       (if (beginning-of-defun--in-emptyish-line-p)
           (kill-line arg)
         (skip-syntax-forward " -")
-        (while (and (condition-case nil
-                        (progn
-                          (forward-sexp)
-                          (skip-syntax-forward " -")
-                          t)
-                      (scan-error nil))
-                    ;; We've skipped one sexp.
-                    ;; Are we still on the same line?
-                    (< (point) eol)
-                    ;; Does the line end with a comment?
-                    (or (not (equal (char-after) ?\;))
-                        ;; It does.  Stop after the comment.
-                        (prog1 nil (goto-char eol)))))
+        (if (equal (char-after) ?\;)
+            (goto-char eol)
+          (while (and (condition-case nil
+                          (progn
+                            (forward-sexp)
+                            (skip-syntax-forward " -")
+                            t)
+                        (scan-error nil))
+                      ;; We've skipped one sexp.
+                      ;; Are we still on the same line?
+                      (< (point) eol)
+                      ;; Does the line end with a comment?
+                      (or (not (equal (char-after) ?\;))
+                          ;; It does.  Stop after the comment.
+                          (prog1 nil (goto-char eol))))))
         (kill-region beg (point)))))))
 
 (defun lisp-tidy-sexp ()