emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 78fc49407b8 1/3: Improve filling of ChangeLog entries


From: João Távora
Subject: Re: master 78fc49407b8 1/3: Improve filling of ChangeLog entries
Date: Tue, 30 Jan 2024 22:07:18 +0000
User-agent: Gnus/5.13 (Gnus v5.13)

Dmitry Gutov <dmitry@gutov.dev> writes:

> On 28/01/2024 10:58, Po Lu via Mailing list for Emacs changes wrote:
>> (log-edit-fill-entry): Abandon pcase and cl-lib.
>
> That seems like a gratuitous change.

Seems like this much simpler patch would have done the job.  If cl-loop
is so toxic, even macroexpanding these trivial ones away yields much
less code and much simpler code.  Tests are a welcome addition though.

João

diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index 72867f14d2f..0ce21c5c473 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -578,15 +578,17 @@ log-edit--insert-filled-defuns
     (unless (or (memq (char-before) '(?\n ?\s))
                 (> (current-column) fill-column))
       (insert " "))
-    (cl-loop for first-fun = t then nil
-             for def in func-names do
-             (when (> (+ (current-column) (string-width def)) fill-column)
-               (unless first-fun
-                 (insert ")"))
-               (insert "\n"))
-             (insert (if (memq (char-before) '(?\n ?\s))
-                         "(" ", ")
-                     def))
+    (cl-loop with first-fun = t
+             for (def . more) on func-names do
+             (when (> (+ (current-column) (string-width def)
+                         (if first-fun 1 2)
+                         (if (null more) 1 0))
+                      fill-column)
+               (unless first-fun (insert ")"))
+               (unless (eq (char-before) ?\n) (insert "\n"))
+               (setq first-fun t))
+             (insert (if first-fun "(" ", ") def)
+             (setq first-fun nil))
     (insert "):")))
 
 (defun log-edit-fill-entry (&optional justify)
@@ -611,10 +613,11 @@ log-edit-fill-entry
               (copy-marker (match-end 1)))
          ;; Fill prose between log entries.
          do (let ((fill-indent-according-to-mode t)
-                  (end (if defuns-beg (match-beginning 0) end))
-                  (beg (progn (goto-char beg) (line-beginning-position))))
+                  (end (if defuns-beg (match-beginning 0) end)))
+              (goto-char beg)
+              (skip-chars-backward "^ \t\n")
               (when (<= (line-end-position) end)
-                (fill-region beg end justify)))
+                (fill-region (point) end justify)))
          while defuns-beg
          for defuns = (progn (goto-char defuns-beg)
                              (change-log-read-defuns end))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]