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: Sat, 24 Jan 2015 00:25:56 +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 1422059327 9926 80.91.229.3 (24 Jan 2015 00:28:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Jan 2015 00:28:47 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 24 01:28:43 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 1YEoag-0004lS-UB for ged-emacs-devel@m.gmane.org; Sat, 24 Jan 2015 01:28:43 +0100 Original-Received: from localhost ([::1]:33638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEoaf-0004lS-SN for ged-emacs-devel@m.gmane.org; Fri, 23 Jan 2015 19:28:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEoaR-0004lN-HJ for emacs-devel@gnu.org; Fri, 23 Jan 2015 19:28:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEoaM-0000CH-C4 for emacs-devel@gnu.org; Fri, 23 Jan 2015 19:28:27 -0500 Original-Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:59469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEoaM-0000CB-3S for emacs-devel@gnu.org; Fri, 23 Jan 2015 19:28:22 -0500 Original-Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 28628A80AA; Sat, 24 Jan 2015 01:28:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter15-d.gandi.net Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id y4zTLcqW2ZRr; Sat, 24 Jan 2015 01:28:19 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 37432A80AB; Sat, 24 Jan 2015 01:28:16 +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::195 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:181702 Archived-At: Stefan Monnier wrote: > You still have a global minor mode (and its >> variable), and a separately-named buffer-local variable, so it's no >> simpler. > > It's a lot simpler because the buffer-local var is internal. What do you mean by =E2=80=9Finternal=E2=80=9D? Just the double-dash nami= ng convention? If by =E2=80=9Fsimpler=E2=80=9D you mean that no =E2=80=9F= external=E2=80=9D (no double-dash, and intended to be user-level) var has= to be used buffer-locally, then your solution isn't simpler; you still n= eed (setq-local dynamic-cursor-mode nil). See below. >> If (global) dynamic-cursor-mode is enabled, your code provides no way >> to prevent it from operating in a buffer in which cursor-type happens >> to be t. > > Of course it does: > > (add-hook 'foo-mode-hook (lambda () (setq-local dynamic-cursor-mode = nil))) I didn't know it was appropriate for any code other than the mode itself = to set a mode's variable. I thought it was supposed to be treated as read= -only by all other code. >> (setq-default cursor-type 'bar) >> A few days later in the same Emacs session... >> (dynamic-cursor-mode) > > No, because dynamic-cursor-mode can do (setq-default cursor-type t). > That's one of the advantages of a minor mode over a plain defcustom. You mean do that when dynamic-cursor-mode turns on? In that case, what if= I want to enable dynamic-cursor-mode buffer-locally, rather than globall= y? If I were to turn it on globally by doing (dynamic-cursor-mode), then it = would (once, at the time of turn-on) set the cursor type in all buffers t= hat are using the global value of cursor-type (i.e. that have no buffer-l= ocal value for it), which is the wrong thing to do, since I was only tryi= ng to enable dynamic-cursor-mode buffer-locally. If I were to instead do (setq-local dynamic-cursor-mode t), then would I = lose the supposed advantage of a minor mode over a plain defcustom, and t= he original failure mode I described would therefore remain. > The difference between a boolean defcustom and a global minor-mode is > pretty much that the global minor mode offers the "set triggers". But only in one direction: dynamic-cursor-mode can set cursor-type when t= he former is turned on (though this doesn't do what's needed, as describe= d above), but setting cursor-type can't turn off dynamic-cursor-mode (whi= ch is what's actually needed to enable defaulting dynamic-cursor-mode to = t without causing conflict). It still seems my original patch, except with the =E2=8C=9C-mode=E2=8C=9D= suffix removed and the default changed to nil, is the cleanest way to im= plement dynamic-cursor. Even if you want it to formally be a minor mode (= even though it has no advantage in this case), the cleanest implementatio= n is with the simple additions to de/activate-mark in my patches (all thr= ee patches have these same additions), and nothing in the minor mode itse= lf except the variable, which I'll set buffer-locally when necessary sinc= e you say that's appropriate.