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] Proposal to change cursor appearance to indicate region activation Date: Fri, 23 Jan 2015 11:07:38 +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 1422011338 962 80.91.229.3 (23 Jan 2015 11:08:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Jan 2015 11:08:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 23 12:08:52 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 1YEc6e-0001xR-3n for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 12:08:52 +0100 Original-Received: from localhost ([::1]:58145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEc6d-0004A7-7B for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 06:08:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEc6a-0004A1-JI for emacs-devel@gnu.org; Fri, 23 Jan 2015 06:08:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEc6X-0005Wy-9A for emacs-devel@gnu.org; Fri, 23 Jan 2015 06:08:48 -0500 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:37770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEc6W-0005W7-P6 for emacs-devel@gnu.org; Fri, 23 Jan 2015 06:08:44 -0500 Original-Received: from mfilter28-d.gandi.net (mfilter28-d.gandi.net [217.70.178.159]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 3F4B541C083; Fri, 23 Jan 2015 12:08:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter28-d.gandi.net Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter28-d.gandi.net (mfilter28-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id D88PmMSucA4T; Fri, 23 Jan 2015 12:08:38 +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 117E141C078; Fri, 23 Jan 2015 12:08:36 +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:181661 Archived-At: Stefan Monnier wrote: >> +(defun maybe-disable--dynamic-cursor () >> + (unless (eq (default-value 'cursor-type) >> + (eval (car (get 'cursor-type 'standard-value)))) >> + (global-dynamic-cursor-mode 0))) > > Hmm... that's rather ugly. I agree. > I was thinking of rather doing something like: > > (defvar-local dynamic-cursor-mode--set nil > "If non-nil, we've temporarily modified the cursor.") > >> + (if dynamic-cursor-mode (setq cursor-type t)) > (when dynamic-cursor-mode > (if (and dynamic-cursor-mode--set (eq cursor-type 'bar)) > (setq cursor-type t)) > (setq dynamic-cursor-mode--set nil)) > > and > >> + (if dynamic-cursor-mode (setq cursor-type 'bar)) > (if (and dynamic-cursor-mode (eq cursor-type t)) > (setq cursor-type 'bar dynamic-cursor-mode--set t)) That's even uglier! ;-) You still have a global minor mode (and its varia= ble), and a separately-named buffer-local variable, so it's no simpler. A= nd the logic is more complex. And it appears it would fail in the example case I gave in my previous me= ssage: (setq-default cursor-type 'bar) A few days later in the same Emacs session... (dynamic-cursor-mode) The user would reasonably think the failure is a bug in dynamic-cursor-mo= de; after all, the point of the mode is to control the cursor. I guess you could fix that failure, but make sure it doesn't then fail if= the user set some other cursor type (e.g. 'hbar) instead of 'bar. I agree that there shouldn't be a buffer-local minor mode for dynamic-cur= sor; it's overkill, since all it's used for is the variable. But the glob= al minor mode that you want is also overkill for the same reason. I sugge= st using a defcustom and just dropping the potentially-misleading =E2=8C=9C= -mode=E2=8C=9D suffix, and maybe adding a =E2=8C=9Cuse-=E2=8C=9D or =E2=8C= =9Cenable-=E2=8C=9D prefix, analogous to the other variables I cited. > So you don't need a buffer-local activation of dynamic-cursor-mode. I still would need it. If (global) dynamic-cursor-mode is enabled, your c= ode provides no way to prevent it from operating in a buffer in which cur= sor-type happens to be t. I agree that having a pair of minor modes is gross. The cleanest way to d= o it is with a defcustom (for which I can do (setq-local dynamic-cursor n= il) when necessary) with no =E2=8C=9C-mode=E2=8C=9D suffix, and since Ema= cs lacks triggers on variable writes, simply have the default be nil in o= rder to avoid the ugliness that would be needed to avoid conflict with ot= her uses of cursor-type. Then dynamic-cursor's control of cursor-type won= 't surprise or annoy users, because they only get it if they choose to en= able it. Modifying the =C2=ABset=C2=BB family of functions to provide triggers wou= ld be the ideal solution, as I described in my previous message. E.g. hav= e a 'triggers property for each symbol, storing a list of functions to ru= n when the symbol (i.e. dynamic variable) is set, analogous to a hook. Th= en dynamic-cursor could default to t, with no ugliness needed to avoid co= nflict.