emacs-devel
[Top][All Lists]
Advanced

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

RE: Proposal to change cursor appearance to indicate region activation


From: Drew Adams
Subject: RE: Proposal to change cursor appearance to indicate region activation
Date: Sat, 20 Apr 2013 00:23:59 -0700

> By default in Emacs, when the region is active but empty, 
> there's no visual indication of this status.

See below.

> Neither is there indication of the active region if
> point is one less than mark and blink-cursor-mode is off.

Hm.  That's not what I see.

> Also, if point is greater than mark, the active region
> is highlighted, but the block cursor does an inverse-video
> highlight of the character following the region, which
> (speaking from experience) an Emacs newbie finds
> distracting, since it seems to indicate that that character
> is also part of the region

It's been a long since I was a newbie wrt transient-mark mode.  But I have a
hard time believing that inverse video has much, if anything, to do with it.

A block cursor itself is the cause of any such confusion, I think, regardless of
inverse video.  It sits on top of a char, so a priori it is ambiguous whether
the region includes that character or not.

Any editor would choose to be consistent here, whichever choice were made
(include it or not).  A newbie just has to discover which choice has been made.
;-)

And a moment's thought would anyway reach the conclusion that choosing to
include the char under the cursor would mean that the active region always has
at least one char (the one under the cursor).

> Adding to the confusion, the inverse-video 
> highlighted character actually is part of the region in the 
> case that point is less than mark.  Setting the cursor type to 
> bar when the region is active solves all those problems, and 
> I recommend it as the default for Emacs.

I don't see those as great problems.  But you could argue that I am already used
to the current way.

> (add-hook 'deactivate-mark-hook (lambda () (setq cursor-type t)))
> (add-hook 'activate-mark-hook (lambda () (setq cursor-type 'bar)))

I wouldn't have a problem with that being the default behavior, but I don't see
a crying need for it either.  You might also want to conditionalize the
activation part with (when transient-mark-mode (setq...)): there are still some
who are not transient-mark modists.

Making default behavior depend on such hooks makes it more difficult for users
(especially newbies) to change the behavior.  There could be ways around that,
wrapping the complexity in defcustoms or some such.  But as you present it, it
requires users to fiddle with Lisp a bit to make changes.

[I think you will find, BTW, that with recent Emacs 24 builds a `mouse-1' click
sometimes leaves the cursor as a bar and sometimes as a block.  A bug apparently
- it does not seem to happen with 24.3 or earlier.  Seems to depend on the line
clicked, for some reason.  At least that's what I see on MS Windows.]

> Simply setting the cursor type permanently to bar would solve 
> most of the problems, but still wouldn't indicate an active 
> empty region.  And a permanent bar cursor makes it hard to 
> find the cursor on screen if blink mode is off.  So I 
> recommend keeping the current default of a block cursor when 
> the region isn't active.

Yes.

A bar cursor does not particularly stand out as an indication of an empty active
region, however.  It might be better than no indication, but it is not really
going to prevent people from getting into the typical troubles from not
realizing that the region is active and empty.

FWIW, I use code[*] that indicates the size of the active region in the mode
line (using face `region').  It is an option (choice) whether it indicates an
empty active region also (useful or distracting, depending on your point of
view).

I also use a dynamically changing cursor[**] for other purposes than indicating
the active region:

* change color when using an input method
* change shape (to block, by default) when Emacs is idle
* change shape (to block, by default) when in overwrite mode or read-only

So in my case the cursor is a bar when I'm actually editing, regardless of
whether the region is active.  It is a block when Emacs is idle or the buffer is
read-only or in overwrite mode.

And I use `blink-cursor-mode', so the block cursor that appears when Emacs is
idle does not confuse wrt the active region.

In sum, your arguments are sound and your proposal is reasonable.  This is the
kind of simple observation and thinking that we need more of, IMHO.

But there are multiple ways to skin the cat.  I'm neutral on your proposal wrt
the resulting behavior, and slightly negative wrt the mechanism (hooks).

If we do what you suggest by default then it might be good to wrap the hook
stuff in defcustoms (e.g. :set sexps) or minor modes, so users don't need to
fiddle with Lisp to make simple behavior changes.  (No, it's not a big deal, but
why not make it easier?)

[*]
code: http://www.emacswiki.org/emacs-en/download/modeline-posn.el
description: http://www.emacswiki.org/ModeLinePosition

[**]
code: http://www.emacswiki.org/emacs-en/download/cursor-chg.el
description: http://www.emacswiki.org/ChangingCursorDynamically




reply via email to

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