[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 14:20:16 +0900 |
Richard Stallman writes:
> > If there is no extension, just the mark set,
> > `zmacs-region-extent' is nil and `region-active-p'
> > returns nil therefor.
>
> Right. However, if zmacs-region-extent is non-nil, it is possible
> that (region-beginning) equals (region-end), in which case there is
> (usually) no point in operating on the region. It is that check that
> Richard is asking about AFAICS.
>
> That really puzzles me.
`region-active-p' does not check that the region has non-zero length.
My point is that whether it makes sense to operate on a region of
length zero depends on the operation, so `region-active-p' doesn't try
to decide.
Note that Andreas and I are talking at cross-purposes to some extent,
because his usage of "extent", although impeccable as English, differs
from XEmacs terminology where it denotes a specific type of
Lisp_Object, approximately an Emacs overlay. This confused me, and
I'm probably not responding to him in a way that's useful to him or
you.
> It seems to say that in the following XEmacs code
>
> (defun fill-paragraph-or-region (arg)
> "Fill the current region, if it's active; otherwise, fill the
> paragraph.
> See `fill-paragraph' and `fill-region' for more information."
> (interactive "*P")
> (if (region-active-p)
> (call-interactively 'fill-region)
> (call-interactively 'fill-paragraph)))
>
> with an active but empty region, region-active-p sometimes returns t
> and sometimes returns nil. (This is because zmacs-region-extent might
> be nil, or might be t and empty.)
>
> Do I understand correctly?
No, if the region is active but empty (by which I mean having zero
length), `region-active-p' will return non-nil and `fill-region' will
be called.
An active region exists if and only if `zmacs-region-extent' contains
an extent object. Code that activates the region does so by setting
`zmacs-region-extent' to an extent whose endpoints are point and mark,
and whose face property is 'zmacs-region. Deactivation is done by
setting `zmacs-region-extent' to nil.
- Re: region-active-p, (continued)
- Re: region-active-p, Stephen J. Turnbull, 2007/10/24
- Re: region-active-p, Richard Stallman, 2007/10/25
- Re: region-active-p, Stephen J. Turnbull, 2007/10/26
- Re: region-active-p, Andreas Röhler, 2007/10/26
- Re: region-active-p, Stephen J. Turnbull, 2007/10/26
- Re: region-active-p, Andreas Röhler, 2007/10/26
- Re: region-active-p, Stephen J. Turnbull, 2007/10/26
- Re: region-active-p, Richard Stallman, 2007/10/26
- Re: region-active-p,
Stephen J. Turnbull <=
- Re: region-active-p, Miles Bader, 2007/10/27
- Re: region-active-p, Andreas Röhler, 2007/10/27
- Re: region-active-p, Stephen J. Turnbull, 2007/10/28
- Re: region-active-p, Miles Bader, 2007/10/28
- Re: region-active-p, Johan Bockgård, 2007/10/28
- Re: region-active-p, Stefan Monnier, 2007/10/28
- Re: region-active-p, Stefan Monnier, 2007/10/28
- Re: region-active-p, Richard Stallman, 2007/10/27
- Re: region-active-p, Stefan Monnier, 2007/10/27
- Re: region-active-p, Miles Bader, 2007/10/27