all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Alan Mackenzie <acm@muc.de>
Cc: Dmitry Gutov <dmitry@gutov.dev>, Po Lu <luangruo@yahoo.com>,
	emacs-devel@gnu.org
Subject: Re: master 78fc49407b8 1/3: Improve filling of ChangeLog entries
Date: Wed, 31 Jan 2024 16:46:42 +0000	[thread overview]
Message-ID: <CALDnm53bor0NYO5FJN7BbqW0+DTo-YpRA+M9A-Sxvrw35pOVyw@mail.gmail.com> (raw)
In-Reply-To: <ZbpoA6PQrafYtiqw@ACM>

On Wed, Jan 31, 2024 at 3:32 PM Alan Mackenzie <acm@muc.de> wrote:

> > Was there a way to write it more succinctly, using some higher-level
> > constructs? That is the subject.

Dmitry, sometimes you don't even need higher-level constructs.  You just
need not to freak out over cl-loop, breathe slowly, and expand it
to see what you get.

> I think the discussion is over the advantages and disadvantages of
> replacing obscure concise code with its equivalent in plain Lisp.

Alan, here's a version of log-edit--insert-filled-defuns derived from the one
we had a few days ago, and which really didn't have "countless bugs".
All "plain elisp" as far as I can tell.  Spans one fourth of Po's.  I got
it by simply cleaning up the macroexpansion.

(defun log-edit--insert-filled-defuns (func-names)
  "Insert FUNC-NAMES, following ChangeLog formatting."
  (if (not func-names)
      (insert ":")
    (unless (or (memq (char-before) '(?\n ?\s))
                (> (current-column) fill-column))
      (insert " "))
    (let* ((first-fun t) (def nil))
      (while (consp func-names)
        (setq def (pop func-names))
        (when (>
               (+ (current-column) (string-width def) (if first-fun 1 2)
                  (if (null func-names) 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 "):")))

Even if in Po's version the comments are not counted, this version is
still less than half the length, less variables, less 'if', no
'delete-char', no 'format', doesn't 'cons', and much more
closely resembles the original, passing all of Po's tests.  Probably
could use a comment to explain the line measuring arithmetic, or
made even simpler if one really wanted to, but I think it's just
short enough to be fine.

Uses 'pop' and 'unless'.  Dunno if that is "plain elisp" to you.
I've never seen that defined anywhere, don't know why you
get to say what it is, or why it's even a useful working concept.

For the other rewritten function it's much of the same
I've already shown how a one-line change would have fixed its bug
(taking for granted that is was even a bug):

-                  (beg (progn (goto-char beg) (line-beginning-position))))
+                  (beg (progn (goto-char beg) (skip-chars-backward "^
\n") (point))))



  reply	other threads:[~2024-01-31 16:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <170643232559.30479.16631610453249222615@vcs2.savannah.gnu.org>
     [not found] ` <20240128085846.187A2C1DAE4@vcs2.savannah.gnu.org>
2024-01-28 13:22   ` master 78fc49407b8 1/3: Improve filling of ChangeLog entries Dmitry Gutov
2024-01-28 13:37     ` Po Lu
2024-01-30 22:07     ` João Távora
2024-01-31  6:43       ` Po Lu
2024-01-31 10:28         ` João Távora
2024-01-31 11:19           ` Po Lu
2024-01-31 13:22             ` João Távora
2024-01-31 14:01               ` Po Lu
2024-01-31 14:30                 ` João Távora
2024-01-31 15:15                 ` Dmitry Gutov
2024-01-31 15:32                   ` Alan Mackenzie
2024-01-31 16:46                     ` João Távora [this message]
2024-01-31 18:29                       ` Alan Mackenzie
2024-01-31 17:05                     ` Dmitry Gutov
2024-01-31 18:45                       ` Alan Mackenzie
2024-01-31 20:39                         ` Dmitry Gutov
2024-01-29 20:13   ` Stefan Kangas
2024-01-30  1:26     ` Po Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALDnm53bor0NYO5FJN7BbqW0+DTo-YpRA+M9A-Sxvrw35pOVyw@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=acm@muc.de \
    --cc=dmitry@gutov.dev \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.