[Top][All Lists]

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

Re: region-active-p

From: Stephen J. Turnbull
Subject: Re: region-active-p
Date: Sat, 27 Oct 2007 06:53:19 +0900

Andreas Röhler writes:

 > > Right.  However, if zmacs-region-extent is non-nil, it is possible
 > > that (region-beginning) equals (region-end), 
 > If this is possible--my little check rather
 > contradicts

Try "C-SPC C-x C-x M-: (list (region-beginning) (region-end)
zemacs-region-extent) RET" and you will see it is quite possible.

 > --than I consider it as not congruent with its name "extent" or a
 > bug.

Please read the documentation on extents.  Extents are *objects* with
properties.  For example, zero-length extents are the usual way to
insert images in a window that are not attached to any particular
buffer text.  I see no particular reason why an extent of zero length
should be impossible; it's the obviously limiting case.

 > At stake are AFAIU tree different and hierarchical conditions:
 > 1 region exists but has no extent
 > 2 region has extent but is not visible
 > 3 region is visible

You're using "extent" as a property of the region.  However, in XEmacs
extents are Lisp_Objects, and the test for zmacs-region-extent is a
test for whether such an object is attached to the region.  In XEmacs
2 and 3 are almost the same, because the highlighting is carried by
the extent.  The region is visible if and only if the extent exists,
with the sole exception of zero-length regions.  (It would be possible
to make them visible by adding an image to them.)

 > For appropriate names I held something like
 > 1 region-exist-p
 > 2 region-extent-p

This is not compatible with XEmacs usage of the word "extent".  You
can use it as you like, of course, but if you choose to use it in this
way you will find it very difficult to communicate with XEmacs

 > 3 region-visible-p
 > In GNU Emacs these conditions are expressed by
 > 1 mark-active
 > 2 (and mark-active (not (eq (region-beginning) (region-end))))
 > 3 (and transient-mark-mode mark-active
 >      (not (eq (region-beginning) (region-end))))
 > XEmacs has AFAIS
 > 1 region-exist-p
 > 3 region-active-p

No.  1 and XEmacs's `region-exists-p' may be equivalent (but maybe
not: if zmacs-regions is non-nil, then region exists if and only if it
is active), but `region-active-p' is surely not equivalent to 3,
because an active region can have zero length in the buffer.  I'm not
sure whether this is more useful than the definition you suggest, but
that is the way XEmacs works.

Also, for a region to be active, the buffer containing it must be
current.  I'm not sure why this test is necessary in XEmacs, or
whether it would be useful in Emacs.

reply via email to

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