From: Grant Rettke <gcr@wisdomandwonder.com>
To: Emacs Help <help-gnu-emacs@gnu.org>
Subject: How to evaluate a function when a defcustom variable is either set or saved?
Date: Tue, 14 Jun 2016 20:13:10 -0500 [thread overview]
Message-ID: <CAAjq1mfHhjLiyACqXbRGOkBAkU0cTqCMYA_Ti6b_D77nbQ=ySA@mail.gmail.com> (raw)
Good evening,
The Easy Customization user guide [explains that] any changes you make will “not
take effect until you set or save [them]”. That makes sense.
After the set or save occurs, I would like to evaluate a function. The goal of
the function is to calculate some runtime values that need to be re-calculated
every time that the variable is changed. The desire to let the users easily
explore reconfiguration via the Easy Customize UI and run the configuration code
each time they make a change *without* restarting Emacs.
For example, it might look like this (fake on-change property added):
┌────
│ (defun on-test-string-change (old new)
│ "Testing."
│ (message "test-string just changed from %S to %S" old new))
│
│ (defcustom test-string "test"
│ "Practice"
│ :type 'string
│ :group 'test
│ :on-change #'on-test-string-change)
└────
Suppose the user enters the Easy Customization interface, makes a change, and
then saves or sets it; this would appear in the `Messages' buffer:
┌────
│ "test-string just changed from \"foo\" to \"bar\""
└────
I read the documentation for Easy Customize and didn’t find anything like this.
I read the code for `customize-set-value' and `customize-set-variable' and
didn’t find anything like that.
I searched for Emacs events that would apply and didn’t find any. The buffer
local variable and buffer contents after change events jumped out, but aren’t
the right thing for this.
Question
• How would one normally go about doing something like this?
• Is this a common topic when using the Easy Customization UI?
Sincerely,
Grant Rettke
[explains that]
https://www.gnu.org/software/emacs/manual/html_node/emacs/Changing-a-Variable.html#Changing-a-Variable
next reply other threads:[~2016-06-15 1:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 1:13 Grant Rettke [this message]
2016-06-15 4:39 ` How to evaluate a function when a defcustom variable is either set or saved? Drew Adams
2016-06-15 17:40 ` Grant Rettke
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='CAAjq1mfHhjLiyACqXbRGOkBAkU0cTqCMYA_Ti6b_D77nbQ=ySA@mail.gmail.com' \
--to=gcr@wisdomandwonder.com \
--cc=help-gnu-emacs@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.
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.