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] Run hook when variable is set Date: Mon, 02 Feb 2015 10:57:39 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1422892669 25774 80.91.229.3 (2 Feb 2015 15:57:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2015 15:57:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kelly Dean Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 02 16:57:48 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 1YIJNk-0000g7-38 for ged-emacs-devel@m.gmane.org; Mon, 02 Feb 2015 16:57:48 +0100 Original-Received: from localhost ([::1]:55239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIJNj-0001cV-BP for ged-emacs-devel@m.gmane.org; Mon, 02 Feb 2015 10:57:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIJNg-0001cP-Cv for emacs-devel@gnu.org; Mon, 02 Feb 2015 10:57:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIJNd-0005HC-0v for emacs-devel@gnu.org; Mon, 02 Feb 2015 10:57:44 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:20934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIJNc-0005H6-TW for emacs-devel@gnu.org; Mon, 02 Feb 2015 10:57:40 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am8PAOwQflRsoX+8/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAgEBAQECAVYjBQsLGBwSFBgNJBOINwnWWQEBCAIBH5A8MweESAWEbIYVkjGDOIw7ggqBeIQZITCCRwEBAQ X-IPAS-Result: Am8PAOwQflRsoX+8/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAgEBAQECAVYjBQsLGBwSFBgNJBOINwnWWQEBCAIBH5A8MweESAWEbIYVkjGDOIw7ggqBeIQZITCCRwEBAQ X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="109456607" Original-Received: from 108-161-127-188.dsl.teksavvy.com (HELO ceviche.home) ([108.161.127.188]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Feb 2015 10:57:39 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 588A466100; Mon, 2 Feb 2015 10:57:39 -0500 (EST) In-Reply-To: (Kelly Dean's message of "Mon, 02 Feb 2015 05:40:59 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:182261 Archived-At: OK, let's drop this whole idea. Too much arguing for a negligible feature already available via other packages. Stefan >>>>> "Kelly" =3D=3D Kelly Dean writes: > Stefan Monnier wrote: >>> Without it, code which would be simply: >>> (let-with-hook ((hooked-var foo)) >>> (body)) >>=20 >>> would have to become: >>> (setq tmp hooked-var) >>> (setq-with-hook hooked-var foo) >>> (body) >>> (setq-with-hook hooked-var tmp) >>=20 >>> That's cumbersome. >>=20 >> 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 > varhook does. >>> That would fail in this case: >>> (setq-default cursor-type 'bar) >>> Later in the same Emacs session... >>> (dynamic-cursor-mode) >>=20 >> As I already said, enabling dynamic-cursor-mode should set cursor-type t= o t. > Come on. I acknowledged that just two lines later in my message. Please > don'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, >>=20 >> Not really. Such usage is unsupported. Users who do that get what they >> 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 s= et >>> cursor-type to 'bar, then the setting doesn't stick; >>=20 >> 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-standar= d cursor-type in his init file? I guess you think that's user-friendly too. > Splitting =ABtechnically enabled=BB from =ABactually in effect=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 only expression y= ou 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))))