From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Propagating local variables?
Date: Thu, 17 May 2018 10:27:56 -0400 [thread overview]
Message-ID: <1148d91b-92a2-e970-e6cb-0fcc0a951c8c@gmail.com> (raw)
In-Reply-To: <87in7mv5jn.fsf@xps13.shealevy.com>
On 2018-05-17 08:18, Shea Levy wrote:
> 2. How do we actually ensure the variables are propagated? I wrote the
> inherit-local package to do the propagation, but there's no obvious
> hook point to call it (thus the advice around generate-new-buffer)
We now have variable watchers:
> add-variable-watcher is a built-in function in ‘C source code’.
>
> (add-variable-watcher SYMBOL WATCH-FUNCTION)
>
> Cause WATCH-FUNCTION to be called when SYMBOL is set.
>
> It will be called with 4 arguments: (SYMBOL NEWVAL OPERATION WHERE).
> SYMBOL is the variable being changed.
> NEWVAL is the value it will be changed to.
> OPERATION is a symbol representing the kind of change, one of: ‘set’,
> ‘let’, ‘unlet’, ‘makunbound’, and ‘defvaralias’.
> WHERE is a buffer if the buffer-local value of the variable is being
> changed, nil otherwise.
>
> All writes to aliases of SYMBOL will call WATCH-FUNCTION too.
These could probably be used for that purpose:
- add watchers to the symbols of each shared variable
- create a buffer local list of dependent buffers to the parent buffer
- every time one of the watched variable changes, propagate the changes to the dependent buffers of the buffer it was changed in
It would be fairly understandable, too, since adding a watcher to a variable adds an informative message to that variable's docstring.
Of course, this assumes that the set of variables that you want to propagate is small and known beforehand. As an alternative, a buffer-local-variable-change-hook might be a useful addition?
Clément.
next prev parent reply other threads:[~2018-05-17 14:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 19:37 Propagating local variables? John Wiegley
2018-05-16 3:42 ` Roland Winkler
2018-05-16 17:34 ` Stefan Monnier
2018-05-16 18:59 ` John Wiegley
2018-05-16 20:49 ` Stefan Monnier
2018-05-16 22:46 ` John Wiegley
2018-05-17 14:45 ` Stefan Monnier
2018-05-16 21:02 ` Roland Winkler
2018-05-17 3:00 ` Richard Stallman
2018-05-17 5:16 ` John Wiegley
2018-05-18 2:32 ` Richard Stallman
2018-05-18 4:28 ` John Wiegley
2018-05-18 20:15 ` Shea Levy
2018-05-19 3:19 ` Richard Stallman
2018-05-19 15:09 ` John Shahid
2018-05-20 3:19 ` Richard Stallman
2018-05-17 12:18 ` Shea Levy
2018-05-17 14:27 ` Clément Pit-Claudel [this message]
2018-05-18 2:33 ` Richard Stallman
2018-05-18 3:18 ` Stefan Monnier
2018-05-19 12:06 ` Philipp Stephani
2018-05-20 19:09 ` Clément Pit-Claudel
2018-05-19 12:11 ` Philipp Stephani
2018-05-19 19:12 ` Stefan Monnier
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=1148d91b-92a2-e970-e6cb-0fcc0a951c8c@gmail.com \
--to=cpitclaudel@gmail.com \
--cc=emacs-devel@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.