]> git.eshelyaron.com Git - emacs.git/commitdiff
Make the invocation of combine-change-calls in comment-region valid
authorAlan Mackenzie <acm@muc.de>
Sun, 15 Nov 2020 13:23:15 +0000 (13:23 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 15 Nov 2020 13:23:15 +0000 (13:23 +0000)
This fixes bug #44581.  The problem was that whitespace outside of the (BEG
END) region was being deleted, and this made the invocation of
combine-change-calls with (BEG END) invalid.

* lisp/newcomment.el (comment-region-default): Amend the second argument to
combine-change-calls.

lisp/newcomment.el

index e111ae8e22516d859c915a21c7fd5d694bddc9d7..3eb158dc2c8841b509c01345fafc234024a08ac0 100644 (file)
@@ -1292,7 +1292,15 @@ changed with `comment-style'."
 
 (defun comment-region-default (beg end &optional arg)
   (if comment-combine-change-calls
-      (combine-change-calls beg end (comment-region-default-1 beg end arg))
+      (combine-change-calls beg
+          ;; A new line might get inserted and whitespace deleted
+          ;; after END for line comments.  Ensure the next argument is
+          ;; after any and all changes.
+          (save-excursion
+            (goto-char end)
+            (forward-line)
+            (point))
+        (comment-region-default-1 beg end arg))
     (comment-region-default-1 beg end arg)))
 
 ;;;###autoload