From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kelly Dean Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Run hook when variable is set Date: Mon, 02 Feb 2015 05:40:59 +0000 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 1422855760 32273 80.91.229.3 (2 Feb 2015 05:42:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2015 05:42:40 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 02 06:42:39 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 1YI9mR-0004FE-AJ for ged-emacs-devel@m.gmane.org; Mon, 02 Feb 2015 06:42:39 +0100 Original-Received: from localhost ([::1]:53105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YI9mQ-0006Do-FN for ged-emacs-devel@m.gmane.org; Mon, 02 Feb 2015 00:42:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YI9m4-0006B0-7E for emacs-devel@gnu.org; Mon, 02 Feb 2015 00:42:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YI9ly-0000Fw-M1 for emacs-devel@gnu.org; Mon, 02 Feb 2015 00:42:13 -0500 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:42845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YI9ly-0000Fo-GK for emacs-devel@gnu.org; Mon, 02 Feb 2015 00:42:10 -0500 Original-Received: from mfilter5-d.gandi.net (mfilter5-d.gandi.net [217.70.178.132]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id ED1B841C05C; Mon, 2 Feb 2015 06:42:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter5-d.gandi.net Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter5-d.gandi.net (mfilter5-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id N7v-KJnlnQje; Mon, 2 Feb 2015 06:42:07 +0100 (CET) X-Originating-IP: 66.220.3.179 Original-Received: from localhost (gm179.geneticmail.com [66.220.3.179]) (Authenticated sender: kelly@prtime.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id C643641C062; Mon, 2 Feb 2015 06:42:04 +0100 (CET) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4b98:c:538::197 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:182231 Archived-At: Stefan Monnier wrote: >> Without it, code which would be simply: >> (let-with-hook ((hooked-var foo)) >> (body)) > >> would have to become: >> (setq tmp hooked-var) >> (setq-with-hook hooked-var foo) >> (body) >> (setq-with-hook hooked-var tmp) > >> That's cumbersome. > > No, if you really need it, it's a simple (cl-letf (((get-var) foo)) ...= ). I'm lost. > I think I'd rather have something yet a bit simpler: > - extend the `constant' bit to allow a "hooked" value, for efficiency. > Provide a function to set/unset this "hooked" annotation. > - when setting a hooked var, call a global Elisp function IIUC, you mean you want a centralized handler for all hooked vars, rather= than enabling use of separate functions for different symbols like varho= ok does. >> That would fail in this case: >> (setq-default cursor-type 'bar) >> Later in the same Emacs session... >> (dynamic-cursor-mode) > > As I already said, enabling dynamic-cursor-mode should set cursor-type = to t. Come on. I acknowledged that just two lines later in my message. Please d= on't imply that I ignored it. >> then it won't work. If you instead do: >> (make-local-variable 'dynamic-cursor-mode) >> (dynamic-cursor-mode) >> then DCM is enabled only locally, > > Not really. Such usage is unsupported. Users who do that get what the= y > deserve. Even though in the very next paragraph I showed a simple way to handle it= properly even using your preferred way of implementing DCM? IOW, you would intentionally omit that proper handling just for the sake = of aggravating users who want to control DCM buffer-locally? >> This has the edge case that if the mark happens to be active when you = set >> cursor-type to 'bar, then the setting doesn't stick; > > That's right. I'm not worried about that either. Well yeah, I guess you can just declare it to not be a bug. This reminds me of the joke: How many Microsoft programmers does it take = to change a lightbulb? Answer: none. They just change the standard to darkness. And what about the fact that your way of implementing DCM shows the mode = as enabled, even though it effectively isn't, if the user set a non-stand= ard cursor-type in his init file? I guess you think that's user-friendly = too. Splitting =C2=ABtechnically enabled=C2=BB from =C2=ABactually in effect=C2= =BB results in a bad API too. For any other mode foo, if you want to know= whether the mode is in effect, there's a variable to tell you, so the on= ly expression you need is simply: foo But for your version of DCM, there's no such variable, so you would requi= re the special-case expression: (and dynamic-cursor-mode (or (eq cursor-type t) (and dynamic-cursor-mode--set (eq cursor-type 'bar))))