From: Lars Ingebrigtsen <larsi@gnus.org>
To: Oleksandr Gavenko <gavenkoa@gmail.com>
Cc: 22703@debbugs.gnu.org
Subject: bug#22703: 24.5; PROPOSAL: Is there a way to update available choices for defcustom variable?
Date: Thu, 01 Aug 2019 14:44:22 +0200 [thread overview]
Message-ID: <87ftmlm4wp.fsf@mouse.gnus.org> (raw)
In-Reply-To: <871t8cfrfc.fsf@gavenkoa.example.com> (Oleksandr Gavenko's message of "Tue, 16 Feb 2016 20:20:23 +0200")
Oleksandr Gavenko <gavenkoa@gmail.com> writes:
> Recently I ask question:
>
> http://emacs.stackexchange.com/questions/20350/defcustom-values-for-selecting-from-function-call
>
> because I didn't understand show to build code from that I read in docs.
>
> While answer to question help me to build my first "customize" code it miss
> main point and I think because the way Emacs customize API works, so nobody
> even think about doing as I asked.
>
> I have values:
>
> (defvar my/python-checker-alist
> '((pylint . (my/python-pylint-command my/python-pylint-args))
> (pep8 . (my/python-pep8-command my/python-pep8-args))
> (pyflakes . (my/python-pyflakes-command my/python-pyflakes-args)))
> "Known Python source code checkers.")
>
> and want to build `defcustom' definition based on that values:
>
> (choice (const . pylint) (const . pep8) (const . pyflakes))
>
> (defcustom my/python-default-checker 'pyflakes
> "Default Python source code checker. See `my/python-checker-alist' for full alist."
> :group 'my/python
> :type (cons 'choice (mapcar (lambda (e) (cons 'const (car e))) my/python-checker-alist)) )
>
> I am worrying is there a mechanic that **automatically** update `:type' value when
> user visit:
>
> M-x customize-group
> M-x customize-variable
>
> with my variable?
>
> Official info states:
>
> The argument of ‘:type’ is evaluated, but only once when the
> ‘defcustom’ is executed, so it isn’t useful for the value to vary.
>
> If someone potentially extend my/python-checker-alist his addition would be
> invisible in my/python-default-checker.
>
> I thing it is wrong to ask someone not only to update possible values:
>
> (with-eval-after-load 'my/python
> (add-to-list 'my/python-checker-alist ...))
>
> but also somehow to update default values (for my/python-default-checker)
> synchronously.
>
> Are there standard convention for such situation?
(I'm going through old bug reports that have unfortunately not gotten
any responses.)
Yes, the person extending the defcustom can call
`custom-declare-variable' with the new :type, too. This should be
mentioned in the doc string for `defcustom', I think, and I'm making
that change on the Emacs trunk now.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
prev parent reply other threads:[~2019-08-01 12:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 18:20 bug#22703: 24.5; PROPOSAL: Is there a way to update available choices for defcustom variable? Oleksandr Gavenko
2019-08-01 12:44 ` Lars Ingebrigtsen [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ftmlm4wp.fsf@mouse.gnus.org \
--to=larsi@gnus.org \
--cc=22703@debbugs.gnu.org \
--cc=gavenkoa@gmail.com \
/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.
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.