[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Proposal to change cursor appearance to indicate region acti

From: Kelly Dean
Subject: Re: [PATCH] Proposal to change cursor appearance to indicate region activation
Date: Sat, 24 Jan 2015 00:25:56 +0000

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 ‟internal”? Just the double-dash naming convention? If by 
‟simpler” you mean that no ‟external” (no double-dash, and intended to be 
user-level) var has to be used buffer-locally, then your solution isn't 
simpler; you still need (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 globally?

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 that are 
using the global value of cursor-type (i.e. that have no buffer-local value for 
it), which is the wrong thing to do, since I was only trying 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 the 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 the 
former is turned on (though this doesn't do what's needed, as described above), 
but setting cursor-type can't turn off dynamic-cursor-mode (which is what's 
actually needed to enable defaulting dynamic-cursor-mode to t without causing 

It still seems my original patch, except with the ⌜-mode⌝ suffix removed and 
the default changed to nil, is the cleanest way to implement dynamic-cursor. 
Even if you want it to formally be a minor mode (even though it has no 
advantage in this case), the cleanest implementation is with the simple 
additions to de/activate-mark in my patches (all three patches have these same 
additions), and nothing in the minor mode itself except the variable, which 
I'll set buffer-locally when necessary since you say that's appropriate.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]