all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: "João Távora" <joaotavora@gmail.com>
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 18:29:47 +0000	[thread overview]
Message-ID: <ZbqRm-d-z3RWMWj9@ACM> (raw)
In-Reply-To: <CALDnm53bor0NYO5FJN7BbqW0+DTo-YpRA+M9A-Sxvrw35pOVyw@mail.gmail.com>

Hello, João.

On Wed, Jan 31, 2024 at 16:46:42 +0000, João Távora wrote:
> 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 "):")))

Looks OK to me, apart from the doc string which is a bit vague and fails
to define FUNC-NAMES.  But it's better than a lot of existing doc
strings.

> 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.

Yes, provided that pop is working on a variable which is a list, not
some fancy "generalised variable".

> 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.

It's not defined, but we all know what it means, just as we know what
"good code" and "bad code" mean.  It's a useful concept, as it can be
contrasted with code full of cl-* functions and macros, pcase, and other
things which make reading and debugging difficult for a lot of people.

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2024-01-31 18:29 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
2024-01-31 18:29                       ` Alan Mackenzie [this message]
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=ZbqRm-d-z3RWMWj9@ACM \
    --to=acm@muc.de \
    --cc=dmitry@gutov.dev \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --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.