]> git.eshelyaron.com Git - emacs.git/commitdiff
More effectually prevent defun list wrapping in C-x C-w
authorPo Lu <luangruo@yahoo.com>
Wed, 24 Apr 2024 03:45:31 +0000 (11:45 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 24 Apr 2024 17:43:44 +0000 (19:43 +0200)
* lisp/vc/log-edit.el (log-edit-fill-entry): Match and replace
with NBSPs the opening defun list also.

* test/lisp/vc/log-edit-tests.el
(log-edit-fill-entry-no-defun-list-wrapping): New test.

(cherry picked from commit 145a77808ebd36fffb2e9c0376f821f09733d045)

lisp/vc/log-edit.el
test/lisp/vc/log-edit-tests.el

index 1f766eea45573edba42f238fc46f5c387094870b..d61a108b1958a37d5d41d3830169760f2abfd695 100644 (file)
@@ -698,7 +698,15 @@ according to `fill-column'."
                     (save-excursion
                       (goto-char beg)
                       (when (re-search-forward
-                             "^[[:blank:]]*(.*\\([[:space:]]\\).*):"
+                             ;; Also replace spaces within defun lists
+                             ;; prefixed by a file name so that
+                             ;; fill-region never attempts to break
+                             ;; them, even if multiple items combine
+                             ;; with symbols to exceed the fill column
+                             ;; by the expressly permitted margin of 1
+                             ;; character.
+                             (concat "^\\([[:blank:]]*\\|\\* .*[[:blank:]]"
+                                     "\\)(.*\\([[:space:]]\\).*):")
                              end t)
                         (replace-regexp-in-region "[[:space:]]" " "
                                                   (setq space-beg
index 8373156587d73dc6c296590f1349504228af7ebd..db60d21f137573f0472225da79e9e5d7601e0563 100644 (file)
@@ -344,4 +344,22 @@ next line instead.")
       (let ((fill-column 20)) (log-edit-fill-entry))
       (should (equal (buffer-string) wanted)))))
 
+(ert-deftest log-edit-fill-entry-no-defun-list-wrapping ()
+  ;; This test verifies that the opening defun list of an entry is never
+  ;; broken, even in the event its length in total exceeds the fill
+  ;; column.
+  (let (string wanted)
+    (setq string "
+* src/androidfns.c (Fxw_display_color_p):
+(Fx_display_grayscale_p): Report color and/or grayscale properly.
+"
+          wanted "
+* src/androidfns.c (Fxw_display_color_p, Fx_display_grayscale_p):
+Report color and/or grayscale properly.
+")
+    (with-temp-buffer
+      (insert string)
+      (let ((fill-column 64)) (log-edit-fill-entry))
+      (should (equal (buffer-string) wanted)))))
+
 ;;; log-edit-tests.el ends here