* Customization list
[not found] <gf5p25utbjtl7yg4cvdjzzawaklttpsjeydijzqlrrj47nekxn.ref@ovebfpzoimrd>
@ 2024-07-12 10:59 ` Ergus
2024-07-12 11:47 ` Tassilo Horn
0 siblings, 1 reply; 4+ messages in thread
From: Ergus @ 2024-07-12 10:59 UTC (permalink / raw)
To: help-gnu-emacs
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
So, when the user adds or removes one of the choices, the variable gets
a final value associated.
I was trying to use different combination of choice, radio, set, repeat
and const, but there were some issues with each.
Is this very simple "custom menu" approach possible?
Is so, please, could you share some example (either inlined here or a
variable name existent in vanilla) with such behavior.
Thanks in advance,
Ergus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Customization list
2024-07-12 10:59 ` Customization list Ergus
@ 2024-07-12 11:47 ` Tassilo Horn
2024-07-12 19:15 ` Ergus
0 siblings, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2024-07-12 11:47 UTC (permalink / raw)
To: Ergus; +Cc: help-gnu-emacs
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.
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Customization list
2024-07-12 11:47 ` Tassilo Horn
@ 2024-07-12 19:15 ` Ergus
2024-07-15 6:37 ` Joost Kremers
0 siblings, 1 reply; 4+ messages in thread
From: Ergus @ 2024-07-12 19:15 UTC (permalink / raw)
To: Tassilo Horn; +Cc: help-gnu-emacs
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Customization list
2024-07-12 19:15 ` Ergus
@ 2024-07-15 6:37 ` Joost Kremers
0 siblings, 0 replies; 4+ messages in thread
From: Joost Kremers @ 2024-07-15 6:37 UTC (permalink / raw)
To: Ergus; +Cc: Tassilo Horn, help-gnu-emacs
On Fri, Jul 12 2024, Ergus wrote:
>>> 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
Hmm, looks like what you're after is the 'set' type. An example from one of my
packages:
```
(defcustom writeroom-global-effects '(writeroom-set-fullscreen
writeroom-set-alpha
writeroom-set-menu-bar-lines
writeroom-set-tool-bar-lines
writeroom-set-vertical-scroll-bars
writeroom-set-bottom-divider-width)
"List of global effects for `writeroom-mode'.
These effects are enabled when `writeroom-mode' is activated in
the first buffer and disabled when it is deactivated in the last
buffer."
:group 'writeroom
:type '(set (const :tag "Fullscreen" writeroom-set-fullscreen)
(const :tag "Disable transparency" writeroom-set-alpha)
(const :tag "Disable menu bar" writeroom-set-menu-bar-lines)
(const :tag "Disable tool bar" writeroom-set-tool-bar-lines)
(const :tag "Disable scroll bar" writeroom-set-vertical-scroll-bars)
(const :tag "Enable bottom window divider" writeroom-set-bottom-divider-width)
(const :tag "Add border" writeroom-set-internal-border-width)
(const :tag "Display frame on all workspaces" writeroom-set-sticky)
(repeat :inline t :tag "Custom effects" function)))
```
(See <https://github.com/joostkremers/writeroom-mode>.)
In the Customisation buffer, you'll get this:
```
Hide Writeroom Global Effects:
Set:
[ ] Fullscreen
[X] Disable transparency
[X] Disable menu bar
[X] Disable tool bar
[X] Disable scroll bar
[X] Enable bottom window divider
[ ] Add border
[ ] Display frame on all workspaces
[ ] Custom effects:
INS
State : CHANGED outside Customize.
List of global effects for ‘writeroom-mode’. Hide
These effects are enabled when ‘writeroom-mode’ is activated in
the first buffer and disabled when it is deactivated in the last
buffer.
Groups: Writeroom
```
You can tick each box to in/exclude the option, and you can tick the final box
to add custom options. Each option corresponds to a symbol that is added to or
removed from the list.
HTH
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-15 6:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
2024-07-15 6:37 ` Joost Kremers
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.