GNU bug report logs - #71861
31.0.50; Keep better track of options to be :set-after others

Previous Next

Package: emacs;

Reported by: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>

Date: Sun, 30 Jun 2024 17:35:02 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: 71861 <at> debbugs.gnu.org
Cc: Philip Kaludercic <philipk <at> posteo.net>
Subject: bug#71861: 31.0.50; Keep better track of options to be :set-after others
Date: Sun, 30 Jun 2024 19:34:08 +0200
In help-gnu-emacs <877ceftlof.fsf <at> gmail.com>, we noted that user options
that depend on each other induce some manual work to properly keep in
sync.  The examples in that thread were:

* which-key-dont-use-unicode, consulted by
  * which-key-separator
  * which-key-ellipsis

* ls-lisp-emulation, consulted by
  * ls-lisp-ignore-case
  * ls-lisp-use-string-collate
  * ls-lisp-dirs-first
  * ls-lisp-verbosity

In these examples, each "sub-option" is defined with a :set-after clause
on the "meta-option", i.e. they are defined with:

  (defcustom SUB-OPTION
    (FORM META-OPTION)
    "[…]."
    […]
    :set-after '(META-OPTION)
    […])

Currently, for sub-options to be recomputed when users set the
corresponding meta-option, maintainers must add a :set clause to the
latter invoking custom-reevaluate-setting on the former: see e.g.

* which-key-dont-use-unicode's :set form:

  :set (lambda (sym val)
         (custom-set-default sym val)
         (mapc #'custom-reevaluate-setting
               '(which-key-separator
                 which-key-ellipsis)))

* ls-lisp-set-options, invoked by ls-lisp-emulation's :set form:

  (mapc 'custom-reevaluate-setting
          '(ls-lisp-ignore-case
            ls-lisp-dirs-first
            ls-lisp-verbosity
            ls-lisp-use-string-collate))

Assisting maintainers by automating some of that would be neat.  I have
some half-baked ideas on the topic, but I'll tuck them in a footnote¹
and let Philip tell us about his own 😉

¹

(a) (custom-add-dependencies sub-option meta-options) could be taught
to store the reverse dependency to help with bookkeeping, e.g.

  (dolist (meta-opt meta-options)
    (push sub-option (get meta-opt 'custom-watchers)))

This would allow maintainers of meta-options to retrieve all settings to
reevaluate, instead of having to spell out the whole list (which,
conceivably, they might not even know, e.g. if out-of-tree package x
decides to base their defaults on in-tree package y).

(b) To go further, assuming (a) is implemented, custom.el could be
taught to automatically

  (mapc #'custom-reevaluate-setting (get opt 'custom-watchers))

after setting opt?  Not sure if this is one step too far.  Should this
behaviour be opt-in somehow, for backward compatibility?  E.g. with a
new defcustom keyword for sub-options?

  :depends-on (META-OPTIONS…)

or a new form for :set-after?

  :set-after ((META-OPTION t)…)

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.42, cairo version 1.18.0) of 2024-06-23 built on amdahl30
Repository revision: 93088fc13c47fbab875f9ee173c0a66d623d91c6
Repository branch: master
Windowing system distributor 'SUSE LINUX', version 11.0.12401000
System Description: openSUSE Tumbleweed

Configured using:
 'configure --prefix=/home/peniblec/apps/.emacs.2024-06-23 --with-cairo
 --with-sqlite3 --with-xinput2'

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

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix




This bug report was last modified 337 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.