unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ergus <spacibba@aol.com>
To: Tassilo Horn <tsdh@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Customization list
Date: Fri, 12 Jul 2024 21:15:29 +0200	[thread overview]
Message-ID: <eicpauu5igxcq754365w245t3sqqpbmzgmgu37nhsd2lihsl7c@qkzgsed5grl6> (raw)
In-Reply-To: <87seweessj.fsf@gnu.org>

Hi Tassilo:

On Fri, Jul 12, 2024 at 01:47:08PM GMT, Tassilo Horn wrote:
>Ergus <spacibba@aol.com> writes:
>
>> Hi:
>>
>> After some years in emacs I still have issues when creating
>> customization variables:
>>
>> The examples in the documentation are very simple, but getting some
>> typical simple behaviors is a bit hard to get from them.
>>
>> Suppose I have a variable:
>>
>> (defcustom my-features '(feature1 feature2 feature3)
>>   :type ???)
>>
>> This is a variable that may have a list of possible determined values,
>> so I was expecting to get something like this in the customization menu:
>>
>> [x] feature1
>> [x] feature2
>> [x] feature3
>> [ ] feature4
>> [ ] feature5
>
>Hm, the checkboxiest I can get is
>
>--8<---------------cut here---------------start------------->8---
>(defcustom th/foo nil
>  "My docstring."
>  :type '(alist :key-type symbol
>                :value-type boolean
>                :options (feature1 feature2 feature3)))
>--8<---------------cut here---------------end--------------->8---
>
>which looks like
>
>--8<---------------cut here---------------start------------->8---
>Hide Th Foo:
>Alist:
>[X] Key: feature1
>    Boolean: Toggle  on (non-nil)
>[ ] Key: feature2
>    Boolean: Toggle  off (nil)
>[X] Key: feature3
>    Boolean: Toggle  on (non-nil)
>INS
>    State : EDITED, shown value does not take effect until you set or save it.
>   My docstring.
>--8<---------------cut here---------------end--------------->8---
>
>but then the value looks like
>
>  ((feature1 . t) (feature3 . t))
>
>and you must both activate each feature and toggle its value to t
>(non-nil) but that might be good enough.
>
Indeed, this may work. I am a bit surprised that such simple and useful
thing requires such extra work and doesn't exist already. Also I am not
a big fan of alists, but as you said, this may be good enough, or at
least what we have and have to live with.

The idea of having '(feature1 feature2 feature3) was to simplify also
the manual configuration in the init.el, make it intuitive, simpler to
explain in the doc, but also easier to write and undertsand than an
alist. Also simpler to use in the code with a simple memq.

Hopefully there is something already set that could produce my desired
effect.

Actually I saw that there is the tab-bar-select-tab-modifiers which
looks like what I want, but the code uses a set and a
custom-initialize-default and a lambda in the :set key

Hopefully Juri will comment something ;)

Very thanks in advance,
Ergus

>I think what you actually want is an extension to repeat with :options,
>e.g., (repeat symbol :options (feature1 feature2 feature3)).
>
>Another way would be:
>
>--8<---------------cut here---------------start------------->8---
>(defcustom th/foo nil
>  "My docstring."
>  :type '(repeat (choice (const feature1)
>                         (const feature2)
>                         (const feature3))))
>--8<---------------cut here---------------end--------------->8---
>
>which looks like
>
>--8<---------------cut here---------------start------------->8---
>Hide Th Foo:
>Repeat:
>INS DEL Choice: Value Menu feature1
>INS DEL Choice: Value Menu feature3
>INS
>    State : SET for current session only.
>   My docstring.
>--8<---------------cut here---------------end--------------->8---
>
>and given the wanted value: (feature1 feature3).  Of course, then you
>are allowed to specify each feature many times...
>
>Bye,
>  Tassilo
>



  reply	other threads:[~2024-07-12 19:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gf5p25utbjtl7yg4cvdjzzawaklttpsjeydijzqlrrj47nekxn.ref@ovebfpzoimrd>
2024-07-12 10:59 ` Customization list Ergus
2024-07-12 11:47   ` Tassilo Horn
2024-07-12 19:15     ` Ergus [this message]
2024-07-15  6:37       ` Joost Kremers

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=eicpauu5igxcq754365w245t3sqqpbmzgmgu37nhsd2lihsl7c@qkzgsed5grl6 \
    --to=spacibba@aol.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tsdh@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).