From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Propagating local variables? Date: Thu, 17 May 2018 10:27:56 -0400 Message-ID: <1148d91b-92a2-e970-e6cb-0fcc0a951c8c@gmail.com> References: <87in7mv5jn.fsf@xps13.shealevy.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1526567166 15495 195.159.176.226 (17 May 2018 14:26:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 17 May 2018 14:26:06 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 17 16:26:02 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fJJqz-0003sb-KR for ged-emacs-devel@m.gmane.org; Thu, 17 May 2018 16:26:01 +0200 Original-Received: from localhost ([::1]:58408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJJt6-00066b-Nb for ged-emacs-devel@m.gmane.org; Thu, 17 May 2018 10:28:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJJsw-000654-1l for emacs-devel@gnu.org; Thu, 17 May 2018 10:28:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fJJss-0005tJ-VH for emacs-devel@gnu.org; Thu, 17 May 2018 10:28:02 -0400 Original-Received: from mail-qt0-x230.google.com ([2607:f8b0:400d:c0d::230]:35437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fJJss-0005t5-Q0 for emacs-devel@gnu.org; Thu, 17 May 2018 10:27:58 -0400 Original-Received: by mail-qt0-x230.google.com with SMTP id f5-v6so6002732qth.2 for ; Thu, 17 May 2018 07:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=tIRypc98sJomWz8uBf4BRxSs+qNqdlWOyNJB0bCI0b8=; b=RTnaB+sqgBUXStgUxPnGP0OBHHma+a03jmMw8dO2OJz5h4FwoowmUZrGOK03ZTOTnF /8RHNwMNG/9BKnikYY0QUtM3T+MhJlxvW2O+xhdAHAvPHsG1fA6RQPWQ07kQbXgGdYuv RHYVgxwysXE+4LEc5nbLESiRjjVIUvsDVFKp2C3ugCC3aI/7XGkHXZpJK7NsIxJa0L9k clyfv1g2BCdpUf4F4f6nPIGSZOvVTuw9efYkz00AykLrao5liw/GAJVmETGHVBW5sBCJ aLRAcHHEu9n2tsvau+DlAZNxhfHa2q0baDvCH9fl95dKXmMhwMz1823hAR7vuxrrloww A/HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tIRypc98sJomWz8uBf4BRxSs+qNqdlWOyNJB0bCI0b8=; b=t7KgD5/h/rNnCIgud2aYXOq8yyKMuUtHrbeY2UDRHNTiCTCgdMsf5LkbKj3/E4HHDE M6Kp819HsH5b6D6gGaLAZOl4mRqxu26hau6Z+cvWoMW63qN7VkmTR9gsWRhvQBQ1PCrE Fzz0Gm2hmnVqruZnt70Mxve/4xyj+Xdg7tj+aw5+g1fZzJlqtBx7YpbtN4u1t5xjRjQ5 Plb8GmJGwMlVR/uNpktfLZWDpmKdSr+qt5jYYLMC9eboIRD00ibu1iLb17UQ+1HufZl8 7p/nlf7dRMmUm1BHT6+QNRptuYl7rjy/2nqMR1ri2sFVDnm5fP+s0CtghMQm6r9DoybR CW8g== X-Gm-Message-State: ALKqPweFmN9rsx0oclJfdE92glgI9xn80Wh0xXC0DqAn/N4Lv6a9W3to EGdidY7qJrK7aClQU+pkS7+lxM8W X-Google-Smtp-Source: AB8JxZotj++AbiaTXI40SiiUwPH0K3+ROzBIjhzO/oqxnJp3Z+6OmfjzWHfWnRcovOvFd2OCvFquag== X-Received: by 2002:a0c:944f:: with SMTP id i15-v6mr5213107qvi.215.1526567277744; Thu, 17 May 2018 07:27:57 -0700 (PDT) Original-Received: from [18.26.2.123] (26-2-123.dynamic.csail.mit.edu. [18.26.2.123]) by smtp.gmail.com with ESMTPSA id j7-v6sm3418744qth.35.2018.05.17.07.27.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 07:27:57 -0700 (PDT) In-Reply-To: <87in7mv5jn.fsf@xps13.shealevy.com> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:225365 Archived-At: 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.