Subject: 28.1; `make-autoload' doesn't respect `:group' of `defgroup'

From: taku0 <[email-masked]>
Date: Fri, 23 Sep 2022 14:16:09 +0900

When `;;;###autoload' magic comment is attached to a `defgroup' with `:group',
`make-autoload' doesn't add the group to the parent group.

Example:

With the following code in swift-mode.el, I expect the `swift' group appears
under `languages' group even if the `swift-mode' package isn't loaded yet:

    ;;;###autoload
    (defgroup swift nil
      "Major-mode for Apple's Swift programming language."
      :group 'languages)

We have two problems to fix:

* `make-autoload' should emit `(custom-add-load 'languages 'swift-mode)'.
* `cus-load' should not override existing `custom-loads'.

I have included the following workarounds in `swift-mode' for now:
https://github.com/swift-emacs/swift-mode/blob/7552428931b5b8fe8b40e835484dc9d669bf2e87/swift-mode.el#L52-L57

    ;; WORKAROUND: `update-directory-autoloads' does not handle `:group'.
    ;;;###autoload (custom-add-load 'languages 'swift-mode)

    ;; WORKAROUND: `cus-load' overrides `custom-loads'
    ;;;###autoload (with-eval-after-load 'cus-load
    ;;;###autoload   (custom-add-load 'languages 'swift-mode))

Thanks,
taku0.

In GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0)
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: NixOS 22.05 (Quokka)

Configured using:
 'configure
 --prefix=/nix/store/bbx5czfbx2drp5f19gxbivn6fcx1iyd4-emacs-28.1
 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft
 --with-cairo'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: ja_JP.UTF-8
  value of $XMODIFIERS: @im=uim
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
/run/current-system/sw/share/emacs/site-lisp/site-start hides /nix/store/bbx5czfbx2drp5f19gxbivn6fcx1iyd4-emacs-28.1/share/emacs/site-lisp/site-start

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils seq byte-opt gv bytecomp
byte-compile cconv japan-util iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 56999 7728)
 (symbols 48 6798 1)
 (strings 32 18661 1737)
 (string-bytes 1 647490)
 (vectors 16 15535)
 (vector-slots 8 283325 14019)
 (floats 8 21 41)
 (intervals 56 342 0)
 (buffers 992 11))