From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: [PATCH] Proposal to change cursor appearance to indicate region activation Date: Fri, 23 Jan 2015 09:49:52 -0800 (PST) Message-ID: <626fd015-a9c2-4d4b-ab8e-439db8bd03d3@default> 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 1422035428 9782 80.91.229.3 (23 Jan 2015 17:50:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Jan 2015 17:50:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kelly Dean , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 23 18:50:27 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 1YEiNH-0005wp-FG for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 18:50:27 +0100 Original-Received: from localhost ([::1]:60677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiNG-0004Er-Ny for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 12:50:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiMq-00046n-W1 for emacs-devel@gnu.org; Fri, 23 Jan 2015 12:50:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEiMl-0007Sj-Qy for emacs-devel@gnu.org; Fri, 23 Jan 2015 12:50:00 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:26081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiMl-0007SZ-L4 for emacs-devel@gnu.org; Fri, 23 Jan 2015 12:49:55 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t0NHnspC028208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Jan 2015 17:49:55 GMT Original-Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0NHnrfl025837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 23 Jan 2015 17:49:53 GMT Original-Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0NHnqLP024544; Fri, 23 Jan 2015 17:49:52 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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:181689 Archived-At: > > I was thinking of rather doing something like:... >=20 > That's even uglier! ;-) You still have a global minor mode (and its > variable), and a separately-named buffer-local variable, so it's no > simpler. And the logic is more complex. >=20 > And it appears it would fail in the example case I gave in my previous > message: (setq-default cursor-type 'bar) > A few days later in the same Emacs session... (dynamic-cursor-mode) >=20 > 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. >=20 > 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. >=20 > I agree that there shouldn't be a buffer-local minor mode for dynamic- > cursor; it's overkill, since all it's used for is the variable. But the > global minor mode that you want is also overkill for the same reason. I > suggest 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. >=20 > > So you don't need a buffer-local activation of dynamic-cursor-mode. >=20 > 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 cursor- > type happens to be t. >=20 > 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 nil= ) > when necessary) with no =E2=8C=9C-mode=E2=8C=9D suffix, and since Emacs l= acks triggers on > variable writes, simply have the default be nil in order to avoid the > ugliness that would be needed to avoid conflict with other uses of cursor= - > type. Then dynamic-cursor's control of cursor-type won't surprise or anno= y > users, because they only get it if they choose to enable it. >=20 > 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. have a 'trigg= ers > property for each symbol, storing a list of functions to run when the sym= bol > (i.e. dynamic variable) is set, analogous to a hook. Then dynamic-cursor > could default to t, with no ugliness needed to avoid conflict. I have not followed this in detail. You've seen the approach I use in `cursor-chg.el': just a global minor mode. I'm wondering what else is needed - what the use case is. Are you trying to find a good way to let users opt out of automatic cursor changing for particular buffers, i.e., disable the global nature of the mode for some buffers? If so, is that really an important feature? I would think that needing to turn off the mode for a particular buffer would be pretty rare, and could be accommodated just by toggling the (global) mode temporarily when in such a buffer. That toggling could be manual (probably sufficient, I'm thinking) or automatic (e.g. on a mode hook for the buffer or on `change-major-mode-hook').