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: Alan Mackenzie
Subject: Re: master 78fc49407b8 1/3: Improve filling of ChangeLog entries
Date: Wed, 31 Jan 2024 18:29:47 +0000

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 via email to

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