From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] (Updated) Run hook when variable is set Date: Sat, 07 Feb 2015 10:09:38 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1423321791 19752 80.91.229.3 (7 Feb 2015 15:09:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Feb 2015 15:09:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kelly Dean Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 07 16:09:47 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YK710-0005kY-Og for ged-emacs-devel@m.gmane.org; Sat, 07 Feb 2015 16:09:47 +0100 Original-Received: from localhost ([::1]:53445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YK710-0005IU-4y for ged-emacs-devel@m.gmane.org; Sat, 07 Feb 2015 10:09:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YK70x-0005HN-1A for emacs-devel@gnu.org; Sat, 07 Feb 2015 10:09:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YK70t-0005mu-Sd for emacs-devel@gnu.org; Sat, 07 Feb 2015 10:09:42 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:39356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YK70t-0005lw-ML for emacs-devel@gnu.org; Sat, 07 Feb 2015 10:09:39 -0500 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t17F9cgq018827; Sat, 7 Feb 2015 10:09:38 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 15B5DFAA; Sat, 7 Feb 2015 10:09:38 -0500 (EST) In-Reply-To: (Kelly Dean's message of "Sat, 07 Feb 2015 12:27:06 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5210=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5210> : inlines <2048> : streams <1386306> : uri <1849057> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182609 Archived-At: > Your goal is to avoid the =C2=ABif=C2=BB at the end. In order to do that,= you'd need two functions: > (defun set-internal-1 (args) > (block nil > (if (constant-p) > (if hooked ; Mutually exclusive with actual constant > (progn > (set-internal-1-and-run-varhook args) > (return)) > (if (forbidden-p) > (error "setting constant") > (return)))) > (do-some-stuff) > (and-many-more-lines-of-stuff) > (set-some-variable))) > (defun set-internal-1-and-run-varhook (args) > (do-some-stuff) > (and-many-more-lines-of-stuff) > (set-some-variable) > (run-varhook)) No, the idea was rather to do: (defun set-internal-1 (args) (block nil ; Because Elisp isn't CL (if (constant-or-hooked-p) (if (constant-p) (if (forbidden-p) (error "setting constant") (return)) (funcall symbol-watch-function ..args..)) (do-some-stuff) (and-many-more-lines-of-stuff) (set-some-variable)))) > I'd like to bikeshed the function names a bit more. Handler functions for > varhook are already capable of not only reading variables, but also writi= ng > them. And now, writing (or blocking of writing) is actually going to be o= ne > of the intended use cases. That means =E2=80=9Fwatch=E2=80=9D is a mislea= ding way of > describing it; watching (which implies only reading) is only one of the > things that a handler might do. I think watchpoints usually have the functionality of catching the modifications, being able to see the "before-change value" and being able to replace the assignment with something else. So "watch" makes a lot of sense to me. > BTW, why is the order of the first two arguments to advice-add reversed f= rom > add-function? And the words in their names too. Don't ask, Stefan