unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* region-active-p
@ 2007-10-19  9:49 Andreas Röhler
  2007-10-19 20:57 ` region-active-p Juri Linkov
  0 siblings, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-10-19  9:49 UTC (permalink / raw)
  To: emacs-devel


What about to introduce `region-active-p' and/or
`region-exists-p' for

(and mark-active transient-mark-mode)

thus enhancing portability with XEmacs, which I try
here with such a construct:

(or (and (featurep 'xemacs)
	 (region-active-p))
    (and 
     mark-active transient-mark-mode))

I'm well aware that behaviour of mark is different in
both Emacsen and thus proceeding of `(and mark-active
transient-mark-mode)' will the not be the same as in
`region-exists-p'. However, in most if not all cases
the result for the user should be comparable and
expected.


Thanks all

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-19  9:49 region-active-p Andreas Röhler
@ 2007-10-19 20:57 ` Juri Linkov
  2007-10-21  7:25   ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: Juri Linkov @ 2007-10-19 20:57 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: emacs-devel

> What about to introduce `region-active-p' and/or
> `region-exists-p' for
>
> (and mark-active transient-mark-mode)

I think this is a good idea.  Instead of putting everywhere
a complex condition:

    (and transient-mark-mode mark-active
	 (not (eq (region-beginning) (region-end))))

`region-active-p' is much shorter.

> thus enhancing portability with XEmacs, which I try
> here with such a construct:
>
> (or (and (featurep 'xemacs)
> 	 (region-active-p))
>     (and
>      mark-active transient-mark-mode))
>
> I'm well aware that behaviour of mark is different in
> both Emacsen and thus proceeding of `(and mark-active
> transient-mark-mode)' will the not be the same as in
> `region-exists-p'. However, in most if not all cases
> the result for the user should be comparable and
> expected.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-19 20:57 ` region-active-p Juri Linkov
@ 2007-10-21  7:25   ` Richard Stallman
  2007-10-21 13:56     ` region-active-p Stefan Monnier
  0 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-21  7:25 UTC (permalink / raw)
  To: Juri Linkov; +Cc: andreas.roehler, emacs-devel

    > What about to introduce `region-active-p' and/or
    > `region-exists-p' for

    > (and mark-active transient-mark-mode)

    I think this is a good idea.  Instead of putting everywhere
    a complex condition:

I agree.  But we need to decide whether (not (eq (region-beginning)
(region-end))) should be part of it.  The name `region-active-p'
implies that it doesn't matter whether the region is empty.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21  7:25   ` region-active-p Richard Stallman
@ 2007-10-21 13:56     ` Stefan Monnier
  2007-10-21 14:48       ` region-active-p Miles Bader
  2007-10-21 17:18       ` region-active-p Stephen J. Turnbull
  0 siblings, 2 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-21 13:56 UTC (permalink / raw)
  To: rms; +Cc: Juri Linkov, andreas.roehler, emacs-devel

>> What about to introduce `region-active-p' and/or
>> `region-exists-p' for

>> (and mark-active transient-mark-mode)

>     I think this is a good idea.  Instead of putting everywhere
>     a complex condition:

> I agree.  But we need to decide whether (not (eq (region-beginning)
> (region-end))) should be part of it.

I think it should be part of it.  All the commands I can think of that use
this kind of feature make the command work on the selected region instead of
just "at point".  So an empty region isn't very meaningful for them.

> The name `region-active-p'
> implies that it doesn't matter whether the region is empty.

Not necessarily.  I don't consider an empty region as being really "active".


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21 13:56     ` region-active-p Stefan Monnier
@ 2007-10-21 14:48       ` Miles Bader
  2007-10-21 19:22         ` region-active-p Andreas Röhler
  2007-10-22  6:09         ` region-active-p Andreas Röhler
  2007-10-21 17:18       ` region-active-p Stephen J. Turnbull
  1 sibling, 2 replies; 81+ messages in thread
From: Miles Bader @ 2007-10-21 14:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juri Linkov, andreas.roehler, rms, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The name `region-active-p'
>> implies that it doesn't matter whether the region is empty.
>
> Not necessarily.  I don't consider an empty region as being really "active".

And in many cases an empty-but-"active" region can be pretty confusing
if you don't realize what's going on... (e.g., undo with an
empty-but-"active" region used to be _extremely_ confusing, though that
seems to have been fixed).

-Miles
-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21 13:56     ` region-active-p Stefan Monnier
  2007-10-21 14:48       ` region-active-p Miles Bader
@ 2007-10-21 17:18       ` Stephen J. Turnbull
  2007-10-21 20:54         ` region-active-p Reiner Steib
  1 sibling, 1 reply; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-21 17:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juri Linkov, andreas.roehler, rms, emacs-devel

Stefan Monnier writes:
 > >> What about to introduce `region-active-p' and/or
 > >> `region-exists-p' for
 > 
 > >> (and mark-active transient-mark-mode)
 > 
 > >     I think this is a good idea.  Instead of putting everywhere
 > >     a complex condition:
 > 
 > > I agree.  But we need to decide whether (not (eq (region-beginning)
 > > (region-end))) should be part of it.
 > 
 > I think it should be part of it.  All the commands I can think of that use
 > this kind of feature make the command work on the selected region instead of
 > just "at point".  So an empty region isn't very meaningful for them.

Please implement this interpretation.  It is the interpretation used
by XEmacs since time immemorial (to me, anyway):

------------------------------------------------------------------------
`region-active-p' is a compiled Lisp function
  -- loaded from "/playpen/src/XEmacs/git-staging/lisp/simple.elc"
(region-active-p)

Documentation:
Return non-nil if the region is active in the current buffer.
If `zmacs-regions' is true, this is equivalent to `region-exists-p'.
Otherwise, this function always returns false.
------------------------------------------------------------------------

I believe `zmacs-regions' is the variable that `transient-mark-mode'
emulates.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21 14:48       ` region-active-p Miles Bader
@ 2007-10-21 19:22         ` Andreas Röhler
  2007-10-23  7:12           ` region-active-p Richard Stallman
  2007-10-22  6:09         ` region-active-p Andreas Röhler
  1 sibling, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-10-21 19:22 UTC (permalink / raw)
  To: Miles Bader; +Cc: Juri Linkov, emacs-devel, Richard Stallman, Stefan Monnier

Am Sonntag, 21. Oktober 2007 16:48 schrieb Miles Bader:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> >> The name `region-active-p'
> >> implies that it doesn't matter whether the region is empty.
> >
> > Not necessarily.  I don't consider an empty region as being really
> > "active".
>
> And in many cases an empty-but-"active" region can be pretty confusing
> if you don't realize what's going on... (e.g., undo with an
> empty-but-"active" region used to be _extremely_ confusing, though that
> seems to have been fixed).
>
> -Miles

Introducing something like 

 (not (eq (region-beginning) (region-end)))

would mean a new feature for both Emacsen

AFAIS XEmacs simple.el knows two funktions

region-active-p  and region-exists-p 

where

(defsubst region-exists-p ()
  "..."
  (not (null (mark))))

relates to the state of `mark-active' in GNU, whereas

`region-active-p' delivers something near
`transient-mark-mode'

(defun region-active-p ()
  "..."
  (and zmacs-regions zmacs-region-extent
       (eq (current-buffer) (zmacs-region-buffer))))

`region-exists-p' returns t if called at a buffer with
length 1 where the mark is set. Checked with:

(defun report-region-exists-p (&optional ispec) 
   (interactive "p")
  (if ispec (message "%s" (not (null (mark)))) 
    (not (null (mark)))))

So far 

(defsubst region-exists-p ()
  "..."
  (not (null (mark))))

could be taken as is, beneath 

(defun region-active-p ()
  "..."
  (and mark-active transient-mark-mode))

Andreas Röhler	

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21 17:18       ` region-active-p Stephen J. Turnbull
@ 2007-10-21 20:54         ` Reiner Steib
  0 siblings, 0 replies; 81+ messages in thread
From: Reiner Steib @ 2007-10-21 20:54 UTC (permalink / raw)
  To: emacs-devel

On Sun, Oct 21 2007, Stephen J. Turnbull wrote:

> Stefan Monnier writes:
>  > > I agree.  But we need to decide whether (not (eq (region-beginning)
>  > > (region-end))) should be part of it.
>  > 
>  > I think it should be part of it.  [...]
>
> Please implement this interpretation.  It is the interpretation used
> by XEmacs since time immemorial (to me, anyway):
>
> ------------------------------------------------------------------------
> `region-active-p' is a compiled Lisp function
>   -- loaded from "/playpen/src/XEmacs/git-staging/lisp/simple.elc"
> (region-active-p)
>
> Documentation:
> Return non-nil if the region is active in the current buffer.
> If `zmacs-regions' is true, this is equivalent to `region-exists-p'.
> Otherwise, this function always returns false.
> ------------------------------------------------------------------------
>
> I believe `zmacs-regions' is the variable that `transient-mark-mode'
> emulates.

FWIW, Gnus has the following compatibility functions (gnus-ems.el):

(defun gnus-region-active-p ()
  "Say whether the region is active."
  (and (boundp 'transient-mark-mode)
       transient-mark-mode
       (boundp 'mark-active)
       mark-active))

(defun gnus-mark-active-p ()
  "Non-nil means the mark and region are currently active in this buffer."
  mark-active) ; aliased to region-exists-p in XEmacs.

When running Gnus in XEmacs, these are aliased:

gnus-xmas.el:433:  (defalias 'gnus-region-active-p 'region-active-p)
gnus-xmas.el:434:  (defalias 'gnus-mark-active-p 'region-exists-p)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21 14:48       ` region-active-p Miles Bader
  2007-10-21 19:22         ` region-active-p Andreas Röhler
@ 2007-10-22  6:09         ` Andreas Röhler
  1 sibling, 0 replies; 81+ messages in thread
From: Andreas Röhler @ 2007-10-22  6:09 UTC (permalink / raw)
  To: Miles Bader
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stefan Monnier, Stephen Turnbull

Am Sonntag, 21. Oktober 2007 16:48 schrieb Miles Bader:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> >> The name `region-active-p'
> >> implies that it doesn't matter whether the region is empty.
> >
> > Not necessarily.  I don't consider an empty region as being really
> > "active".
>
> And in many cases an empty-but-"active" region can be pretty confusing
> if you don't realize what's going on... (e.g., undo with an
> empty-but-"active" region used to be _extremely_ confusing, though that
> seems to have been fixed).
>
> -Miles

That's it. I correct my posting from yesterday so far.

It makes no sence to have two forms--`exist' and
`active'-- else.

So I get two new forms:

(defsubst region-exists-p ()
 "..."
 (not (null (mark))))

(defun region-active-p ()
 "..."
 (and mark-active transient-mark-mode
  (not (eq (region-beginning) (region-end)))))

Installing both makes code in both directions
compatible at that point.

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-21 19:22         ` region-active-p Andreas Röhler
@ 2007-10-23  7:12           ` Richard Stallman
  2007-10-23  8:53             ` region-active-p Andreas Röhler
  2007-10-24 19:34             ` region-active-p Stephen J. Turnbull
  0 siblings, 2 replies; 81+ messages in thread
From: Richard Stallman @ 2007-10-23  7:12 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: juri, emacs-devel, monnier, miles

    (defun region-active-p ()
      "..."
      (and zmacs-regions zmacs-region-extent
	   (eq (current-buffer) (zmacs-region-buffer))))

When commands in XEmacs call this, do they also test
for a nonempty region?  Or do they operate on the region
when it is empty?

I don't see any need for region-exists-p
unless we want it specifically to run code in Emacs
which was written for XEmacs.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-23  7:12           ` region-active-p Richard Stallman
@ 2007-10-23  8:53             ` Andreas Röhler
  2007-10-23 17:53               ` region-active-p Richard Stallman
  2007-10-24 19:34             ` region-active-p Stephen J. Turnbull
  1 sibling, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-10-23  8:53 UTC (permalink / raw)
  To: rms
  Cc: Juri Linkov, Stephen J. Turnbull, emacs-devel, Stefan Monnier,
	Miles Bader

Am Dienstag, 23. Oktober 2007 09:12 schrieb Richard Stallman:
>     (defun region-active-p ()
>       "..."
>       (and zmacs-regions zmacs-region-extent
> 	   (eq (current-buffer) (zmacs-region-buffer))))
>
> When commands in XEmacs call this, do they also test
> for a nonempty region?  Or do they operate on the region
> when it is empty?

No. AFAIU `zmacs-region-extent' checks for a physical extend, it may be nil or 
have a value, for example I got

,----
| `zmacs-region-extent' is a variable declared in Lisp.
|   -- loaded from "/home/speck/progarbeit/xemacs/veraendert/simple.el"
| 
| Value: #<extent [147998, 148021] 0x8e8aa24 in buffer simple.el>
| 
| Documentation:
| The extent of the zmacs region; don't use this. 
`----


`zmacs-regions' seems equivalent to
`transient-mark-mode':

,----
| `zmacs-regions' is a built-in boolean variable.
|   -- loaded 
from "/usr/src/packages/BUILD/xemacs-21.5.27.20060705/src/editfns.c"
| 
| Value: t
| 
| Documentation:
| *Whether LISPM-style active regions should be used.
| This means that commands which operate on the region (the area between the
| point and the mark) will only work while the region is in the ``active''
| state, which is indicated by highlighting.
`----

>
> I don't see any need for region-exists-p
> unless we want it specifically to run code in Emacs
> which was written for XEmacs.

AFAIS `region-exists-p' in XEmacs delivers precisely
the value `mark-active' in GNU has.

To provide respective symbols in both Emacsen would
save time for programmers.

Maybe it could be written in GNU somehow as

(defun region-exists-p ()
  mark-active)

and in XEmacs

(setq mark-active (region-exists-p))


Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-23  8:53             ` region-active-p Andreas Röhler
@ 2007-10-23 17:53               ` Richard Stallman
  2007-10-24  7:33                 ` region-active-p Andreas Röhler
  0 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-23 17:53 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: juri, stephen, emacs-devel, monnier, miles

    > When commands in XEmacs call this, do they also test
    > for a nonempty region?  Or do they operate on the region
    > when it is empty?

    No.

What does "no" mean in this context?  (Please don't ask which part of
"no" I don't understand.)

	AFAIU `zmacs-region-extent' checks for a physical extend, it may be nil or 
    have a value, for example I got

What does "checks for a physical extend" mean?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-23 17:53               ` region-active-p Richard Stallman
@ 2007-10-24  7:33                 ` Andreas Röhler
  2007-10-25  2:10                   ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-10-24  7:33 UTC (permalink / raw)
  To: rms
  Cc: Reiner Steib, emacs-devel, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Dienstag, 23. Oktober 2007 19:53 schrieb Richard Stallman:
>     > When commands in XEmacs call this, do they also test
>     > for a nonempty region?  Or do they operate on the region
>     > when it is empty?
>
>     No.
>
> What does "no" mean in this context?  (Please don't ask which part of
> "no" I don't understand.)
>

Was intended as the answer of your last question and followed be some 
explanation. Sorry if it was not clear enough.

> 	AFAIU `zmacs-region-extent' checks for a physical extend, it may be nil or
>     have a value, for example I got
>
> What does "checks for a physical extend" mean?

As "physical" I understand something that exists and
has a body, an extend. An empty buffer I understand as of no extend, but 
existing.

Thus the mark may exist whereas the region has no
extention. Thats possible with mark-active and
region-exist-p.

Therefor 

(not (eq (region-beginning) (region-end)))

as proposed by Juri for Emacs looks necessary to be
sure.

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-23  7:12           ` region-active-p Richard Stallman
  2007-10-23  8:53             ` region-active-p Andreas Röhler
@ 2007-10-24 19:34             ` Stephen J. Turnbull
  2007-10-25  9:01               ` region-active-p Richard Stallman
  1 sibling, 1 reply; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-24 19:34 UTC (permalink / raw)
  To: rms; +Cc: juri, miles, Andreas Röhler, monnier, emacs-devel

Richard Stallman writes:

 > When commands in XEmacs call [region-active-p], do they also test
 > for a nonempty region?  Or do they operate on the region
 > when it is empty?

Core commands defined in Lisp don't test (at least not within 3 lines,
checked with grep -3), but they're generally wrappers for functions
defined in C that do test (eg, the casefilling commands).

 > I don't see any need for region-exists-p
 > unless we want it specifically to run code in Emacs
 > which was written for XEmacs.

The use-case in XEmacs is that some code wishes to operate on the
region regardless of whether it is active.  All examples in XEmacs
core code are used to determine whether a menu item or dialog button
is active; I presume that the corresponding functions query the user
if the region exists but is inactive, and simply executes if the
region is active.  I don't know if there are any important uses.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-24  7:33                 ` region-active-p Andreas Röhler
@ 2007-10-25  2:10                   ` Richard Stallman
  0 siblings, 0 replies; 81+ messages in thread
From: Richard Stallman @ 2007-10-25  2:10 UTC (permalink / raw)
  To: juri, miles, stephen, monnier, emacs-devel, reinersteib+gmane

I cannot understand what Andreas Roehler is trying to say.
Can someone else answer my question?
       
     > When commands in XEmacs call this, do they also test
     > for a nonempty region?  Or do they operate on the region
     > when it is empty?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-24 19:34             ` region-active-p Stephen J. Turnbull
@ 2007-10-25  9:01               ` Richard Stallman
  2007-10-26  5:38                 ` region-active-p Stephen J. Turnbull
  0 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-25  9:01 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: juri, miles, andreas.roehler, monnier, emacs-devel

     > When commands in XEmacs call [region-active-p], do they also test
     > for a nonempty region?  Or do they operate on the region
     > when it is empty?

    Core commands defined in Lisp don't test (at least not within 3 lines,
    checked with grep -3), but they're generally wrappers for functions
    defined in C that do test (eg, the casefilling commands).

I don't entirely understand the answer.  Maybe I did not state the
question clearly.  When you say they "don't test", what precisely
don't they test?

Are you sayimg that they call `region-active-p' but do not test
whether the region is nonempty?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-25  9:01               ` region-active-p Richard Stallman
@ 2007-10-26  5:38                 ` Stephen J. Turnbull
  2007-10-26  8:17                   ` region-active-p Andreas Röhler
  0 siblings, 1 reply; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-26  5:38 UTC (permalink / raw)
  To: rms; +Cc: juri, emacs-devel, andreas.roehler, monnier, miles

Richard Stallman writes:
 >      > When commands in XEmacs call [region-active-p], do they also test
 >      > for a nonempty region?  Or do they operate on the region
 >      > when it is empty?
 > 
 >     Core commands defined in Lisp don't test (at least not within 3 lines,
 >     checked with grep -3), but they're generally wrappers for functions
 >     defined in C that do test (eg, the casefilling commands).
 > 
 > I don't entirely understand the answer.  Maybe I did not state the
 > question clearly.  When you say they "don't test", what precisely
 > don't they test?

They don't test "for a nonempty region".

 > Are you sayimg that they call `region-active-p' but do not test
 > whether the region is nonempty?

Yes.

Specifically, the function that calls `region-active-p' does not.
However, in the cases I looked at, that function simply dispatches to
a more primitive function that acts on the region.  The more primitive
function checks for non-empty in those cases.  The typical idiom is

(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)))

`fill-region' *does* check that the region is nonempty before doing
any work.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-26  5:38                 ` region-active-p Stephen J. Turnbull
@ 2007-10-26  8:17                   ` Andreas Röhler
  2007-10-26  9:21                     ` region-active-p Stephen J. Turnbull
  0 siblings, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-10-26  8:17 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stefan Monnier, Stephen Turnbull, Miles Bader

Am Freitag, 26. Oktober 2007 07:38 schrieben Sie:
> Richard Stallman writes:
>  >      > When commands in XEmacs call [region-active-p], do they also test
>  >      > for a nonempty region?  Or do they operate on the region
>  >      > when it is empty?
>  >
>  >     Core commands defined in Lisp don't test (at least not within 3
>  > lines, checked with grep -3), but they're generally wrappers for
>  > functions defined in C that do test (eg, the casefilling commands).
>  >
>  > I don't entirely understand the answer.  Maybe I did not state the
>  > question clearly.  When you say they "don't test", what precisely
>  > don't they test?
>
> They don't test "for a nonempty region".
>
>  > Are you sayimg that they call `region-active-p' but do not test
>  > whether the region is nonempty?
>
> Yes.
>
> Specifically, the function that calls `region-active-p' does not.


So my understanding ceased to exist... :)

 `region-active-p' reads and depends with `and' from variable

`zmacs-region-extent'.

(and  ... zmacs-region-extent

If there is no extension, just the mark set,
`zmacs-region-extent' is nil and `region-active-p'
returns nil therefor.

I would qualify this behaviour as including a check.

BTW quite other thing with `region-exist-p'.

Maybe I miss the point?

Cheers

Andreas Röhler

> However, in the cases I looked at, that function simply dispatches to
> a more primitive function that acts on the region.  The more primitive
> function checks for non-empty in those cases.  The typical idiom is
>
> (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)))
>
> `fill-region' *does* check that the region is nonempty before doing
> any work.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-26  8:17                   ` region-active-p Andreas Röhler
@ 2007-10-26  9:21                     ` Stephen J. Turnbull
  2007-10-26 11:03                       ` region-active-p Andreas Röhler
  2007-10-27  2:28                       ` region-active-p Richard Stallman
  0 siblings, 2 replies; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-26  9:21 UTC (permalink / raw)
  To: Andreas =?iso-8859-1?q?R=F6hler?=
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stefan Monnier, Miles Bader

Andreas Röhler 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.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-26  9:21                     ` region-active-p Stephen J. Turnbull
@ 2007-10-26 11:03                       ` Andreas Röhler
  2007-10-26 21:53                         ` region-active-p Stephen J. Turnbull
  2007-10-27  2:28                       ` region-active-p Richard Stallman
  1 sibling, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-10-26 11:03 UTC (permalink / raw)
  To: emacs-devel
  Cc: Richard Stallman, Reiner Steib, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Freitag, 26. Oktober 2007 11:21 schrieb Stephen J. Turnbull:
> Andreas Röhler 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), 

If this is possible--my little check rather
contradicts--than I consider it as not congruent with
its name "extent" or a bug.

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

For appropriate names I held something like

1 region-exist-p
2 region-extent-p
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

Andreas Röhler

> in which case there is 
> (usually) no point in operating on the region.  It is that check that
> Richard is asking about AFAICS.
>
>

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-26 11:03                       ` region-active-p Andreas Röhler
@ 2007-10-26 21:53                         ` Stephen J. Turnbull
  0 siblings, 0 replies; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-26 21:53 UTC (permalink / raw)
  To: Andreas Röhler
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stefan Monnier, Miles Bader

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
developers.

 > 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.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-26  9:21                     ` region-active-p Stephen J. Turnbull
  2007-10-26 11:03                       ` region-active-p Andreas Röhler
@ 2007-10-27  2:28                       ` Richard Stallman
  2007-10-27  5:20                         ` region-active-p Stephen J. Turnbull
  1 sibling, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-27  2:28 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

     > 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.  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?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27  2:28                       ` region-active-p Richard Stallman
@ 2007-10-27  5:20                         ` Stephen J. Turnbull
  2007-10-27  6:17                           ` region-active-p Miles Bader
  2007-10-27 23:41                           ` region-active-p Richard Stallman
  0 siblings, 2 replies; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-27  5:20 UTC (permalink / raw)
  To: rms; +Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

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.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27  5:20                         ` region-active-p Stephen J. Turnbull
@ 2007-10-27  6:17                           ` Miles Bader
  2007-10-27  7:57                             ` region-active-p Andreas Röhler
                                               ` (2 more replies)
  2007-10-27 23:41                           ` region-active-p Richard Stallman
  1 sibling, 3 replies; 81+ messages in thread
From: Miles Bader @ 2007-10-27  6:17 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	monnier

"Stephen J. Turnbull" <turnbull@sk.tsukuba.ac.jp> writes:
> `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.

So, which operations _don't_ check?  Well, I assume there are some which
don't check, but probably should, so maybe it's more reasonable to ask,
which operations _shouldn't_ check?

-Miles

-- 
Would you like fries with that?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27  6:17                           ` region-active-p Miles Bader
@ 2007-10-27  7:57                             ` Andreas Röhler
  2007-10-28  6:55                             ` region-active-p Stephen J. Turnbull
  2007-10-28 12:15                             ` region-active-p Johan Bockgård
  2 siblings, 0 replies; 81+ messages in thread
From: Andreas Röhler @ 2007-10-27  7:57 UTC (permalink / raw)
  To: Miles Bader
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stefan Monnier, Stephen Turnbull

Am Samstag, 27. Oktober 2007 08:17 schrieb Miles Bader:
> "Stephen J. Turnbull" <turnbull@sk.tsukuba.ac.jp> writes:
> > `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.
>
> So, which operations _don't_ check?  Well, I assume there are some which
> don't check, but probably should, so maybe it's more reasonable to ask,
> which operations _shouldn't_ check?
>
> -Miles

After all, checking in Juri's proposal would ease
writing GNU code and enhance compatibility. May he get
a green light?

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27  5:20                         ` region-active-p Stephen J. Turnbull
  2007-10-27  6:17                           ` region-active-p Miles Bader
@ 2007-10-27 23:41                           ` Richard Stallman
  2007-10-28  1:21                             ` region-active-p Stefan Monnier
  2007-10-28  7:29                             ` region-active-p Stephen J. Turnbull
  1 sibling, 2 replies; 81+ messages in thread
From: Richard Stallman @ 2007-10-27 23:41 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

Thanks.  Now I understand what XEmacs does here.

I propose to add an optional argument NONEMPTY to region-active-p
which means "return nil if the region is empty".  How about it?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27 23:41                           ` region-active-p Richard Stallman
@ 2007-10-28  1:21                             ` Stefan Monnier
  2007-10-28  1:27                               ` region-active-p Miles Bader
  2007-10-29  0:11                               ` region-active-p Richard Stallman
  2007-10-28  7:29                             ` region-active-p Stephen J. Turnbull
  1 sibling, 2 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-28  1:21 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stephen J. Turnbull, miles

> Thanks.  Now I understand what XEmacs does here.
> I propose to add an optional argument NONEMPTY to region-active-p
> which means "return nil if the region is empty".  How about it?

I expect the opposite makes more sense:

   (defun region-active-p (&optional allow-empty)
     "Return non-nil if the region is active.
   Optional argument ALLOW-EMPTY non-nil means that an empty region
   may also be considered as active."
     ...)

This is because in most cases we've seen we want to treat empty regions as
inactive.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  1:21                             ` region-active-p Stefan Monnier
@ 2007-10-28  1:27                               ` Miles Bader
  2007-10-28  2:43                                 ` region-active-p Stefan Monnier
  2007-10-29  0:11                               ` region-active-p Richard Stallman
  1 sibling, 1 reply; 81+ messages in thread
From: Miles Bader @ 2007-10-28  1:27 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stephen J. Turnbull

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I propose to add an optional argument NONEMPTY to region-active-p
>> which means "return nil if the region is empty".  How about it?
>
> I expect the opposite makes more sense:
...
> This is because in most cases we've seen we want to treat empty regions as
> inactive.

I agree, but is this sufficiently compatible with xemacs?

[I don't think they actually have strictly the same behavior -- if the use
of empty regions is vanishingly rare, then who cares...]

-Miles

-- 
"I distrust a research person who is always obviously busy on a task."
   --Robert Frosch, VP, GM Research

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  1:27                               ` region-active-p Miles Bader
@ 2007-10-28  2:43                                 ` Stefan Monnier
  0 siblings, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-28  2:43 UTC (permalink / raw)
  To: Miles Bader
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stephen J. Turnbull

> I agree, but is this sufficiently compatible with xemacs?

Close enough: the differences should only affect the users, but not the
package authors.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27  6:17                           ` region-active-p Miles Bader
  2007-10-27  7:57                             ` region-active-p Andreas Röhler
@ 2007-10-28  6:55                             ` Stephen J. Turnbull
  2007-10-28  7:32                               ` region-active-p Miles Bader
  2007-10-28 12:15                             ` region-active-p Johan Bockgård
  2 siblings, 1 reply; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-28  6:55 UTC (permalink / raw)
  To: Miles Bader
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	monnier

Miles Bader writes:

 > So, which operations _don't_ check?  Well, I assume there are some which
 > don't check, but probably should, so maybe it's more reasonable to ask,
 > which operations _shouldn't_ check?

As I wrote before, these APIs seem to be mainly used for interactive
DWIM-type functions where you can either specify a region or let
XEmacs guess a region for you.  I can't think of an operation that
*shouldn't* check offhand, but if there is one, it would be a bad idea
for these APIs to check because they wouldn't work with such an API if
they did.  Since they're only used interactively AFAIK, postponing the
check to the function that actually does the work is no big loss.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27 23:41                           ` region-active-p Richard Stallman
  2007-10-28  1:21                             ` region-active-p Stefan Monnier
@ 2007-10-28  7:29                             ` Stephen J. Turnbull
  2007-10-28 21:06                               ` region-active-p Stefan Monnier
                                                 ` (2 more replies)
  1 sibling, 3 replies; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-28  7:29 UTC (permalink / raw)
  To: rms; +Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

Richard Stallman writes:

 > Thanks.  Now I understand what XEmacs does here.
 > 
 > I propose to add an optional argument NONEMPTY to region-active-p
 > which means "return nil if the region is empty".  How about it?

No, thank you.  That makes the name inaccurate in XEmacs usage, is not
backwardly compatible (unlike GNU, we support older versions of XEmacs
which will not support that argument), is IMO less readable than using
an explicit check where the optimization is appropriate and needed,
and as far as I know is redundant in current XEmacsen because functions
where the check is appropriate already do it (typically very quickly
because they do it in C).

A new API defaulting to the semantics of `region-exists-p' would be
preferable.  (Not `region-active-p', since the former makes sense to
the user regardless of whether zmacs-regions/transient-mark-mode is
active.)

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  6:55                             ` region-active-p Stephen J. Turnbull
@ 2007-10-28  7:32                               ` Miles Bader
  0 siblings, 0 replies; 81+ messages in thread
From: Miles Bader @ 2007-10-28  7:32 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	monnier

"Stephen J. Turnbull" <stephen@xemacs.org> writes:
> I can't think of an operation that *shouldn't* check offhand, but if
> there is one, it would be a bad idea for these APIs to check because
> they wouldn't work with such an API if they did.  Since they're only
> used interactively AFAIK, postponing the check to the function that
> actually does the work is no big loss.

It's not a "big loss" but it is silly bloat.  Putting the check in the
common function will also likely reduce bugs because it will avoid the
case where the function writer forgets to do the extra check (and as
undo has shown, _not_ checking can be quite confusing).

If we're going for 100% rigid API compatibility, even in the most
obscure corner cases, then of course it shouldn't check.  But I'm not
sure we are.

-Miles

-- 
P.S.  All information contained in the above letter is false,
      for reasons of military security.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-27  6:17                           ` region-active-p Miles Bader
  2007-10-27  7:57                             ` region-active-p Andreas Röhler
  2007-10-28  6:55                             ` region-active-p Stephen J. Turnbull
@ 2007-10-28 12:15                             ` Johan Bockgård
  2007-10-28 21:07                               ` region-active-p Stefan Monnier
  2007-10-28 21:07                               ` region-active-p Stefan Monnier
  2 siblings, 2 replies; 81+ messages in thread
From: Johan Bockgård @ 2007-10-28 12:15 UTC (permalink / raw)
  To: emacs-devel

Miles Bader <miles@gnu.org> writes:

> So, which operations _don't_ check?  Well, I assume there are some which
> don't check, but probably should, so maybe it's more reasonable to ask,
> which operations _shouldn't_ check?

Keyboard macros might get in trouble if Emacs tries to be clever about
empty regions.

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  7:29                             ` region-active-p Stephen J. Turnbull
@ 2007-10-28 21:06                               ` Stefan Monnier
  2007-10-29  0:11                               ` region-active-p Richard Stallman
  2007-10-29  8:24                               ` region-active-p Andreas Röhler
  2 siblings, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-28 21:06 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri, miles

> where the check is appropriate already do it (typically very quickly
> because they do it in C).

Speed is 100% irrelevant here: we're talking about a handful of non-looping
operations executed for interactive calls.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28 12:15                             ` region-active-p Johan Bockgård
@ 2007-10-28 21:07                               ` Stefan Monnier
  2007-10-28 21:07                               ` region-active-p Stefan Monnier
  1 sibling, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-28 21:07 UTC (permalink / raw)
  To: emacs-devel

>> So, which operations _don't_ check?  Well, I assume there are some which
>> don't check, but probably should, so maybe it's more reasonable to ask,
>> which operations _shouldn't_ check?

> Keyboard macros might get in trouble if Emacs tries to be clever about
> empty regions.

I doubt it'll make any real difference.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28 12:15                             ` region-active-p Johan Bockgård
  2007-10-28 21:07                               ` region-active-p Stefan Monnier
@ 2007-10-28 21:07                               ` Stefan Monnier
  1 sibling, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-28 21:07 UTC (permalink / raw)
  To: emacs-devel

> Keyboard macros might get in trouble if Emacs tries to be clever about
> empty regions.

That is irrelevant: we're talking about *where* to put the empty-region
check, not about whether to tput it in or not.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  7:29                             ` region-active-p Stephen J. Turnbull
  2007-10-28 21:06                               ` region-active-p Stefan Monnier
@ 2007-10-29  0:11                               ` Richard Stallman
  2007-10-30  0:12                                 ` region-active-p Stephen J. Turnbull
  2007-10-29  8:24                               ` region-active-p Andreas Röhler
  2 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-29  0:11 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

I just double-checked.  What we want for Emacs is closer to your
`region-active-p'.  We want it to test for Transient Mark mode with
the mark active.

     > I propose to add an optional argument NONEMPTY to region-active-p
     > which means "return nil if the region is empty".  How about it?

    No, thank you.  That makes the name inaccurate in XEmacs usage, is not
    backwardly compatible

I don't know how to understand "backwardly compatible".  I designed
this to make it an upward compatible change for you.  Does "backwardly
compatible" mean something else?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  1:21                             ` region-active-p Stefan Monnier
  2007-10-28  1:27                               ` region-active-p Miles Bader
@ 2007-10-29  0:11                               ` Richard Stallman
  2007-10-29  1:40                                 ` region-active-p Stefan Monnier
  1 sibling, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-29  0:11 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, turnbull,
	miles

    I expect the opposite makes more sense:

       (defun region-active-p (&optional allow-empty)
	 "Return non-nil if the region is active.
       Optional argument ALLOW-EMPTY non-nil means that an empty region
       may also be considered as active."
	 ...)

    This is because in most cases we've seen we want to treat empty regions as
    inactive.

I agree this would be better.  I made my proposal the way I did
because it is an upward compatible change for XEmacs.  But if that is
not a factor in the decision, let's define the argument as you suggest.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-29  0:11                               ` region-active-p Richard Stallman
@ 2007-10-29  1:40                                 ` Stefan Monnier
  2007-12-10 23:08                                   ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: Stefan Monnier @ 2007-10-29  1:40 UTC (permalink / raw)
  To: rms; +Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, turnbull,
	miles

>     I expect the opposite makes more sense:
>        (defun region-active-p (&optional allow-empty)
> 	 "Return non-nil if the region is active.
>        Optional argument ALLOW-EMPTY non-nil means that an empty region
>        may also be considered as active."
> 	 ...)

>     This is because in most cases we've seen we want to treat empty regions as
>     inactive.

> I agree this would be better.  I made my proposal the way I did
> because it is an upward compatible change for XEmacs.  But if that is
> not a factor in the decision, let's define the argument as you suggest.

As I said elsewhere, I do not think compatibility is an issue because the
potential difference will only cause different behavior for the user, but
will not cause bugs.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-28  7:29                             ` region-active-p Stephen J. Turnbull
  2007-10-28 21:06                               ` region-active-p Stefan Monnier
  2007-10-29  0:11                               ` region-active-p Richard Stallman
@ 2007-10-29  8:24                               ` Andreas Röhler
  2 siblings, 0 replies; 81+ messages in thread
From: Andreas Röhler @ 2007-10-29  8:24 UTC (permalink / raw)
  To: emacs-devel
  Cc: Richard Stallman, Reiner Steib, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Sonntag, 28. Oktober 2007 08:29 schrieb Stephen J. Turnbull:
> Richard Stallman writes:
>  > Thanks.  Now I understand what XEmacs does here.
>  >
>  > I propose to add an optional argument NONEMPTY to region-active-p
>  > which means "return nil if the region is empty".  How about it?
>
> No, thank you.  That makes the name inaccurate in XEmacs usage, is not
> backwardly compatible (unlike GNU, we support older versions of XEmacs
> which will not support that argument), is IMO less readable than using
> an explicit check where the optimization is appropriate and needed,
> and as far as I know is redundant in current XEmacsen because functions
> where the check is appropriate already do it (typically very quickly
> because they do it in C).
>
> A new API defaulting to the semantics of `region-exists-p' would be
> preferable.  (Not `region-active-p', 


For compatibility we should have both. 

(defun region-exists-p ()
  mark-active)

and

 (defun region-active-p (&optional allow-empty)
...

Andreas Röhler

> since the former makes sense to 
> the user regardless of whether zmacs-regions/transient-mark-mode is
> active.)

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-29  0:11                               ` region-active-p Richard Stallman
@ 2007-10-30  0:12                                 ` Stephen J. Turnbull
  2007-10-30  8:22                                   ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-10-30  0:12 UTC (permalink / raw)
  To: rms; +Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

Richard Stallman writes:

 > I just double-checked.  What we want for Emacs is closer to your
 > `region-active-p'.  We want it to test for Transient Mark mode with
 > the mark active.
 > 
 >      > I propose to add an optional argument NONEMPTY to region-active-p
 >      > which means "return nil if the region is empty".  How about it?
 > 
 >     No, thank you.  That makes the name inaccurate in XEmacs usage, is not
 >     backwardly compatible
 > 
 > I don't know how to understand "backwardly compatible".  I designed
 > this to make it an upward compatible change for you.  Does "backwardly
 > compatible" mean something else?

Upwardly compatible, yes, but code that uses that argument cannot be
used in current XEmacsen.  The OP, Andreas Roehler, is specifically
going to want to use it, because those are his preferred semantics.
From the point of view of XEmacs, the additional argument is a clear
nuisance because most of the early uses are presumably going to be by
third parties wishing to eliminate a source of incompatibility, and
they're going to be disappointed.

If you plan to use this API generally in Emacs, then I guess XEmacs
compatibility is a secondary consideration.  If so I would prefer that
you use a different name and the semantics for the argument that
Stefan proposed (or no argument if you also add `region-exists-p' with
XEmacs's semantics).  Then we can add it to XEmacs with less testing
than changing an API, you better semantics (and can ignore the XEmacs
APIs that have semantics that don't look useful to Emacs), and Andreas
gets the semantics that are intuitive to him.

Possible names are `region-usable-p' and `region-nonempty-p'.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30  0:12                                 ` region-active-p Stephen J. Turnbull
@ 2007-10-30  8:22                                   ` Richard Stallman
  2007-10-30  8:59                                     ` region-active-p David Kastrup
  2007-10-30 15:03                                     ` region-active-p Drew Adams
  0 siblings, 2 replies; 81+ messages in thread
From: Richard Stallman @ 2007-10-30  8:22 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

    If you plan to use this API generally in Emacs, then I guess XEmacs
    compatibility is a secondary consideration.  If so I would prefer that
    you use a different name and the semantics for the argument that
    Stefan proposed

I'm not wedded to any particular name.

    Possible names are `region-usable-p' and `region-nonempty-p'.

Neither one fits quite right.  Whether the region is active is more
central to the meaning than whether it is nonempty.

Perhaps `region-overrides-p' is a good name.  The decision is whether
the region should override the normal meaning of the command.

I invite other suggestions.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30  8:22                                   ` region-active-p Richard Stallman
@ 2007-10-30  8:59                                     ` David Kastrup
  2007-10-31  7:46                                       ` region-active-p Richard Stallman
  2007-10-30 15:03                                     ` region-active-p Drew Adams
  1 sibling, 1 reply; 81+ messages in thread
From: David Kastrup @ 2007-10-30  8:59 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	Stephen J. Turnbull, miles

Richard Stallman <rms@gnu.org> writes:

>     If you plan to use this API generally in Emacs, then I guess XEmacs
>     compatibility is a secondary consideration.  If so I would prefer that
>     you use a different name and the semantics for the argument that
>     Stefan proposed
>
> I'm not wedded to any particular name.
>
>     Possible names are `region-usable-p' and `region-nonempty-p'.
>
> Neither one fits quite right.  Whether the region is active is more
> central to the meaning than whether it is nonempty.
>
> Perhaps `region-overrides-p' is a good name.  The decision is whether
> the region should override the normal meaning of the command.
>
> I invite other suggestions.

region-effective-p

I am quite unconvinced that it is a good idea to differentiate the
non-empty case, however.  It is just begging for a wagonload of
commands that behave inconsistently, depending on what the programmer
happened to pick for checking the region.

I think that for Emacs, we should stay with the equivalent of (and
transient-mark-mode mark-active).  If that introduces some slight user
level incompatibility with XEmacs, this is hardly tragic:
zmacs-regions is different from Emacs' region handling, anyway.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: region-active-p
  2007-10-30  8:22                                   ` region-active-p Richard Stallman
  2007-10-30  8:59                                     ` region-active-p David Kastrup
@ 2007-10-30 15:03                                     ` Drew Adams
  2007-10-30 19:03                                       ` region-active-p Stefan Monnier
                                                         ` (2 more replies)
  1 sibling, 3 replies; 81+ messages in thread
From: Drew Adams @ 2007-10-30 15:03 UTC (permalink / raw)
  To: rms, Stephen J. Turnbull
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	miles

> I'm not wedded to any particular name. Possible names are
> `region-usable-p' and `region-nonempty-p'.
> Neither one fits quite right.  Whether the region is active is more
> central to the meaning than whether it is nonempty.
> Perhaps `region-overrides-p' is a good name.  The decision is whether
> the region should override the normal meaning of the command.
> I invite other suggestions.

transient-region-p?

BTW, what's the reason for creating this, again? I thought this was about
harmonizing with XEmacs somehow. Now that doesn't seem possible. What's
wrong with just (and mark-active transient-mark-mode)? that's short and
leaves no doubt about the meaning.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 15:03                                     ` region-active-p Drew Adams
@ 2007-10-30 19:03                                       ` Stefan Monnier
  2007-10-30 19:49                                         ` region-active-p Drew Adams
  2007-10-31  7:47                                       ` region-active-p Richard Stallman
  2007-10-31  7:47                                       ` region-active-p Richard Stallman
  2 siblings, 1 reply; 81+ messages in thread
From: Stefan Monnier @ 2007-10-30 19:03 UTC (permalink / raw)
  To: Drew Adams
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stephen J. Turnbull, miles

>> I'm not wedded to any particular name. Possible names are
>> `region-usable-p' and `region-nonempty-p'.
>> Neither one fits quite right.  Whether the region is active is more
>> central to the meaning than whether it is nonempty.
>> Perhaps `region-overrides-p' is a good name.  The decision is whether
>> the region should override the normal meaning of the command.
>> I invite other suggestions.

> transient-region-p?

> BTW, what's the reason for creating this, again? I thought this was about
> harmonizing with XEmacs somehow. Now that doesn't seem possible. What's
> wrong with just (and mark-active transient-mark-mode)? that's short and
> leaves no doubt about the meaning.

I thought the whole point was to add region-emptyness checking in there
as well (and potentially more, to account for things like a region that
has just been selected with the mouse).


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: region-active-p
  2007-10-30 19:03                                       ` region-active-p Stefan Monnier
@ 2007-10-30 19:49                                         ` Drew Adams
  2007-10-30 20:15                                           ` region-active-p Stefan Monnier
  2007-10-30 23:43                                           ` region-active-p Miles Bader
  0 siblings, 2 replies; 81+ messages in thread
From: Drew Adams @ 2007-10-30 19:49 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stephen J. Turnbull, miles

> >> I'm not wedded to any particular name. Possible names are
> >> `region-usable-p' and `region-nonempty-p'.
> >> Neither one fits quite right.  Whether the region is active is more
> >> central to the meaning than whether it is nonempty.
> >> Perhaps `region-overrides-p' is a good name.  The decision is whether
> >> the region should override the normal meaning of the command.
> >> I invite other suggestions.
>
> > transient-region-p?
>
> > BTW, what's the reason for creating this, again? I thought this
> > was about harmonizing with XEmacs somehow. Now that doesn't seem
possible.
> > What's wrong with just (and mark-active transient-mark-mode)? that's
short
> > and leaves no doubt about the meaning.
>
> I thought the whole point was to add region-emptyness checking in there
> as well (and potentially more, to account for things like a region that
> has just been selected with the mouse).

Oh, right; I forgot.

A short name probably won't capture all 3 things this is a conjunction of:
(1) tmm mode, (2) mark-active, (3) point diff from mark. The last can
probably be dropped from the name, so perhaps `transient-region-p'?

Whatever the name is, the doc string should make 1,2,3 clear.

Also, I don't follow your remark in parens - could you elaborate?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 19:49                                         ` region-active-p Drew Adams
@ 2007-10-30 20:15                                           ` Stefan Monnier
  2007-10-30 20:28                                             ` region-active-p Drew Adams
  2007-10-30 23:43                                           ` region-active-p Miles Bader
  1 sibling, 1 reply; 81+ messages in thread
From: Stefan Monnier @ 2007-10-30 20:15 UTC (permalink / raw)
  To: Drew Adams
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stephen J. Turnbull, miles

>> I thought the whole point was to add region-emptyness checking in there
>> as well (and potentially more, to account for things like a region that
>> has just been selected with the mouse).

> Oh, right; I forgot.

> A short name probably won't capture all 3 things this is a conjunction of:
> (1) tmm mode, (2) mark-active, (3) point diff from mark. The last can
> probably be dropped from the name, so perhaps `transient-region-p'?

> Whatever the name is, the doc string should make 1,2,3 clear.

> Also, I don't follow your remark in parens - could you elaborate?

Hmm.... [grepping frantically] ... oh I have it, it's in skeleton.el:

                          (or (eq last-command 'mouse-drag-region)
			      (and transient-mark-mode mark-active))

-- Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: region-active-p
  2007-10-30 20:15                                           ` region-active-p Stefan Monnier
@ 2007-10-30 20:28                                             ` Drew Adams
  2007-10-30 21:30                                               ` region-active-p Stefan Monnier
  0 siblings, 1 reply; 81+ messages in thread
From: Drew Adams @ 2007-10-30 20:28 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: rms, andreas.roehler, emacs-devel, juri, Stephen J. Turnbull,
	miles

> >> I thought the whole point was to add region-emptyness checking in there
> >> as well (and potentially more, to account for things like a region that
> >> has just been selected with the mouse).
>
> > Oh, right; I forgot.
> > A short name probably won't capture all 3 things this is a
> > conjunction of: (1) tmm mode, (2) mark-active, (3) point diff
> > from mark. The last can probably be dropped from the name, so
> > perhaps `transient-region-p'?
>
> > Whatever the name is, the doc string should make 1,2,3 clear.
> > Also, I don't follow your remark in parens - could you elaborate?
>
> Hmm.... [grepping frantically] ... oh I have it, it's in skeleton.el:
>
>                           (or (eq last-command 'mouse-drag-region)
> 			      (and transient-mark-mode mark-active))

Thanks for frantically searching, but I still don't understand. Do you think
that should be added to the function we're discussing now
(`transient-region-p' or whatever we call it)? If so, why?

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 20:28                                             ` region-active-p Drew Adams
@ 2007-10-30 21:30                                               ` Stefan Monnier
  0 siblings, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-10-30 21:30 UTC (permalink / raw)
  To: Drew Adams
  Cc: rms, andreas.roehler, emacs-devel, juri, Stephen J. Turnbull,
	miles

>> Hmm.... [grepping frantically] ... oh I have it, it's in skeleton.el:
>> 
>> (or (eq last-command 'mouse-drag-region)
>> (and transient-mark-mode mark-active))

> Thanks for frantically searching, but I still don't understand. Do you think
> that should be added to the function we're discussing now
> (`transient-region-p' or whatever we call it)? If so, why?

Don't know.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 19:49                                         ` region-active-p Drew Adams
  2007-10-30 20:15                                           ` region-active-p Stefan Monnier
@ 2007-10-30 23:43                                           ` Miles Bader
  2007-10-31  6:35                                             ` region-active-p David Kastrup
  2007-11-03 21:08                                             ` region-active-p Stephen J. Turnbull
  1 sibling, 2 replies; 81+ messages in thread
From: Miles Bader @ 2007-10-30 23:43 UTC (permalink / raw)
  To: Drew Adams
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stefan Monnier, Stephen J. Turnbull

"Drew Adams" <drew.adams@oracle.com> writes:
> A short name probably won't capture all 3 things this is a conjunction of:
> (1) tmm mode, (2) mark-active, (3) point diff from mark. The last can
> probably be dropped from the name, so perhaps `transient-region-p'?

I dunno, I think most of these "alternative" names are not very good.

Part of the problem is that "transient-mark-mode" is not a particularly
clear name itself; it's one of those names that, if you sit down and
think about it, you can kind of see where it came from, but it's
... awkward.  Oh well, tmm is too embedded to change, but we should aim
to use more intuitive names for new interfaces.

"region-active-p" is by contrast, a really good name:  I think it very
naturally captures the "sense" of what it does, even to someone not
entirely clear with the details of Emacs mark/region handling.

Personally I think we should just use region-active-p, with non-empty
test by default -- the incompatibility with xemacs is minor, and I think
it's far more important that the code in Emacs be clear.  I'm sure
package authors can cope in those (very few) cases where it actually
makes any difference.

> Whatever the name is, the doc string should make 1,2,3 clear.

Very true.

-Miles

-- 
Yo mama's so fat when she gets on an elevator it HAS to go down.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 23:43                                           ` region-active-p Miles Bader
@ 2007-10-31  6:35                                             ` David Kastrup
  2007-10-31  7:59                                               ` region-active-p Miles Bader
  2007-11-03 21:08                                             ` region-active-p Stephen J. Turnbull
  1 sibling, 1 reply; 81+ messages in thread
From: David Kastrup @ 2007-10-31  6:35 UTC (permalink / raw)
  To: Miles Bader
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stefan Monnier, Stephen J. Turnbull, Drew Adams

Miles Bader <miles@gnu.org> writes:

> Personally I think we should just use region-active-p, with non-empty
> test by default -- the incompatibility with xemacs is minor, and I
> think it's far more important that the code in Emacs be clear.  I'm
> sure package authors can cope in those (very few) cases where it
> actually makes any difference.

But the standard test _is_ (and transient-make-mode mark-active) and has
been so for eternities.  And it will stay that way for external packages
for a long time to come.  So we will get inconsistent behavior.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30  8:59                                     ` region-active-p David Kastrup
@ 2007-10-31  7:46                                       ` Richard Stallman
  0 siblings, 0 replies; 81+ messages in thread
From: Richard Stallman @ 2007-10-31  7:46 UTC (permalink / raw)
  To: David Kastrup
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, miles

    I think that for Emacs, we should stay with the equivalent of (and
    transient-mark-mode mark-active).

I've already decided that question and I will not reopen it.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 15:03                                     ` region-active-p Drew Adams
  2007-10-30 19:03                                       ` region-active-p Stefan Monnier
@ 2007-10-31  7:47                                       ` Richard Stallman
  2007-10-31  7:47                                       ` region-active-p Richard Stallman
  2 siblings, 0 replies; 81+ messages in thread
From: Richard Stallman @ 2007-10-31  7:47 UTC (permalink / raw)
  To: Drew Adams
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, miles

    BTW, what's the reason for creating this, again?

Simplicity and avoidance of errors.

						     I thought this was about
    harmonizing with XEmacs somehow.

No, that's just a secondary issue affecting how to do it.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 15:03                                     ` region-active-p Drew Adams
  2007-10-30 19:03                                       ` region-active-p Stefan Monnier
  2007-10-31  7:47                                       ` region-active-p Richard Stallman
@ 2007-10-31  7:47                                       ` Richard Stallman
  2007-10-31  8:00                                         ` region-active-p Miles Bader
  2 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-31  7:47 UTC (permalink / raw)
  To: Drew Adams
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, miles

    transient-region-p?

That name seems ok to me.  But I think that `region-overrides-p'
hits it more accurately.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-31  6:35                                             ` region-active-p David Kastrup
@ 2007-10-31  7:59                                               ` Miles Bader
  0 siblings, 0 replies; 81+ messages in thread
From: Miles Bader @ 2007-10-31  7:59 UTC (permalink / raw)
  To: David Kastrup
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stefan Monnier, Stephen J. Turnbull, Drew Adams

David Kastrup <dak@gnu.org> writes:
>> Personally I think we should just use region-active-p, with non-empty
>> test by default -- the incompatibility with xemacs is minor, and I
>> think it's far more important that the code in Emacs be clear.  I'm
>> sure package authors can cope in those (very few) cases where it
>> actually makes any difference.
>
> But the standard test _is_ (and transient-make-mode mark-active) and has
> been so for eternities.  And it will stay that way for external packages
> for a long time to come.  So we will get inconsistent behavior.

Who cares?  In most cases, the new behavior is _better_.

In other words, it seems likely that the number of times a user is
_helped_ because the new behavior is more intuitive, will exceed the
number of times a user is confused because the behavior is not 100% the
same as it was previously.

-Miles

-- 
My books focus on timeless truths.  -- Donald Knuth

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-31  7:47                                       ` region-active-p Richard Stallman
@ 2007-10-31  8:00                                         ` Miles Bader
  2007-10-31 23:58                                           ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: Miles Bader @ 2007-10-31  8:00 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, Drew Adams

Richard Stallman <rms@gnu.org> writes:
> That name seems ok to me.  But I think that `region-overrides-p'
> hits it more accurately.

Overrides what?

-Miles

-- 
My spirit felt washed.  With blood.  [Eli Shin, on "The Passion of the Christ"]

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-31  8:00                                         ` region-active-p Miles Bader
@ 2007-10-31 23:58                                           ` Richard Stallman
  2007-11-01  2:33                                             ` region-active-p Miles Bader
  0 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-10-31 23:58 UTC (permalink / raw)
  To: Miles Bader
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

    > That name seems ok to me.  But I think that `region-overrides-p'
    > hits it more accurately.

    Overrides what?

Overrides the command's usual behavior.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-31 23:58                                           ` region-active-p Richard Stallman
@ 2007-11-01  2:33                                             ` Miles Bader
  2007-11-01  2:55                                               ` region-active-p Stefan Monnier
  2007-11-01 19:04                                               ` region-active-p Richard Stallman
  0 siblings, 2 replies; 81+ messages in thread
From: Miles Bader @ 2007-11-01  2:33 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

Richard Stallman <rms@gnu.org> writes:
>     > That name seems ok to me.  But I think that `region-overrides-p'
>     > hits it more accurately.
>
>     Overrides what?
>
> Overrides the command's usual behavior.

Perhaps that's how it's usually used, but to name the predicate based on
that seems sort of weird.

If I see code like:

   (if (region-active-p)
       ...do-this...
       ...do-that...)

It seems fairly clear to me what's going on (I'm assuming that people
can intuitively grasp the idea of an active region -- given the
commonness of this concept, and the suggestivenss of the term, I think
they can).

But this:

   (if (region-overrides-p)
       ...do-this...
       ...do-that...)

(1) Obscures the fact that the _reason_ for overriding the is that the
    region is active.  It sounds "arbitrary".

    In fact, upon first seeing it, it sounds like maybe there might be a
    "region-override" flag somewhere which controls the behavior, or
    that the rules were too complex to find a good intuitive name, and
    one must examine `region-override-p' to see what the actual rules
    are (I don't think this is true -- I think the _concept_ is pretty
    concise).  This makes the code harder to understand.

(2) It requires the concept of "usual" behavior to be understood,
    whereas a name phrased in terms.  Perhaps in many cases that's OK,
    but it seems like an unnecessary bit of extra information one is
    required to know.

    One can imagine a command where the "usual" case the active-region
    case, but which also has a useful non-active behavior.  For a
    command like this, the name "overrides" is awkward.

Anyway, what I'm trying to say is that a name like `region-override-p'
makes code harder to understand.

-Miles

-- 
"Whatever you do will be insignificant, but it is very important that
 you do it."  Mahatma Gandhi

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-01  2:33                                             ` region-active-p Miles Bader
@ 2007-11-01  2:55                                               ` Stefan Monnier
  2007-11-01 10:06                                                 ` region-active-p Kim F. Storm
  2007-11-01 19:04                                               ` region-active-p Richard Stallman
  1 sibling, 1 reply; 81+ messages in thread
From: Stefan Monnier @ 2007-11-01  2:55 UTC (permalink / raw)
  To: Miles Bader
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	stephen, drew.adams

> Anyway, what I'm trying to say is that a name like `region-override-p'
> makes code harder to understand.

For what it's worth, I agree 100%,


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-01  2:55                                               ` region-active-p Stefan Monnier
@ 2007-11-01 10:06                                                 ` Kim F. Storm
  2007-11-01 15:46                                                   ` region-active-p Drew Adams
  0 siblings, 1 reply; 81+ messages in thread
From: Kim F. Storm @ 2007-11-01 10:06 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	stephen, drew.adams, Miles Bader

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Anyway, what I'm trying to say is that a name like `region-override-p'
>> makes code harder to understand.
>
> For what it's worth, I agree 100%,

FWIW, me too.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 81+ messages in thread

* RE: region-active-p
  2007-11-01 10:06                                                 ` region-active-p Kim F. Storm
@ 2007-11-01 15:46                                                   ` Drew Adams
  2007-11-01 17:56                                                     ` region-active-p David Kastrup
  0 siblings, 1 reply; 81+ messages in thread
From: Drew Adams @ 2007-11-01 15:46 UTC (permalink / raw)
  To: Kim F. Storm, Stefan Monnier
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	stephen, Miles Bader

> >> Anyway, what I'm trying to say is that a name like `region-override-p'
> >> makes code harder to understand.
> >
> > For what it's worth, I agree 100%,
> 
> FWIW, me too.

FWIW, another.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-01 15:46                                                   ` region-active-p Drew Adams
@ 2007-11-01 17:56                                                     ` David Kastrup
  2007-11-01 23:08                                                       ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: David Kastrup @ 2007-11-01 17:56 UTC (permalink / raw)
  To: Drew Adams
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stefan Monnier, Kim F. Storm, stephen, Miles Bader

"Drew Adams" <drew.adams@oracle.com> writes:

>> >> Anyway, what I'm trying to say is that a name like `region-override-p'
>> >> makes code harder to understand.
>> >
>> > For what it's worth, I agree 100%,
>> 
>> FWIW, me too.
>
> FWIW, another.

What about region-given-p or region-specified-p or region-selected-p?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-01  2:33                                             ` region-active-p Miles Bader
  2007-11-01  2:55                                               ` region-active-p Stefan Monnier
@ 2007-11-01 19:04                                               ` Richard Stallman
  2007-11-02  0:18                                                 ` region-active-p Miles Bader
  1 sibling, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-11-01 19:04 UTC (permalink / raw)
  To: Miles Bader
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

    > Overrides the command's usual behavior.

    Perhaps that's how it's usually used, but to name the predicate based on
    that seems sort of weird.

It is not weird to name a function based on the job you do with it.

The other good names cause practical problems which have already been
explained.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-01 17:56                                                     ` region-active-p David Kastrup
@ 2007-11-01 23:08                                                       ` Richard Stallman
  0 siblings, 0 replies; 81+ messages in thread
From: Richard Stallman @ 2007-11-01 23:08 UTC (permalink / raw)
  To: David Kastrup
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	storm, stephen, drew.adams, miles

    What about region-given-p or region-specified-p or region-selected-p?

Those talk more specifically about the preexisting situation
rather than about the action to be taken.  And they are partly
inaccurate about what they say about the situation.  For that
reason I don't like them.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-01 19:04                                               ` region-active-p Richard Stallman
@ 2007-11-02  0:18                                                 ` Miles Bader
  2007-11-02 15:02                                                   ` region-active-p Richard Stallman
  0 siblings, 1 reply; 81+ messages in thread
From: Miles Bader @ 2007-11-02  0:18 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

Richard Stallman <rms@gnu.org> writes:
>     > Overrides the command's usual behavior.
>
>     Perhaps that's how it's usually used, but to name the predicate based on
>     that seems sort of weird.
>
> It is not weird to name a function based on the job you do with it.

It's not very helpful for elisp hackers, however -- to understand what's
going on, they must go and read the source code to the function in
question -- whereas a better name _does_ help them.

If you see:

   (if (i-should-jump-p) (jump))

That really tells you nothing about the reasons for jumping (you need to
read i-should-jump-p to find out), whereas:

   (if (im-really-depressed-p) (jump))

tells you why in a glance; to find out all the gory details you need to
read more, but until you do that, you still have a good general idea.

The former style can be desirable if the details of should-jump-p in
fact are very complicated (not summarizable by a single phrase) or might
change often though user-customization or whatever.  Still, one has to
weigh flexibility against clarity in deciding which style to use.

> The other good names cause practical problems which have already been
> explained.

Well then why not pick _another_ good name which is still helpful to the
code reader?  David Kastrup suggested `region-selected-p', which seems
intuitive and helpful in the same way that region-active-p is.

-Miles

-- 
The automobile has not merely taken over the street, it has dissolved the
living tissue of the city.  Its appetite for space is absolutely insatiable;
moving and parked, it devours urban land, leaving the buildings as mere islands
of habitable space in a sea of dangerous and ugly traffic.
[James Marston Fitch, New York Times, 1 May 1960]

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-02  0:18                                                 ` region-active-p Miles Bader
@ 2007-11-02 15:02                                                   ` Richard Stallman
  2007-11-02 21:39                                                     ` region-active-p Stefan Monnier
  2007-11-02 22:31                                                     ` region-active-p Miles Bader
  0 siblings, 2 replies; 81+ messages in thread
From: Richard Stallman @ 2007-11-02 15:02 UTC (permalink / raw)
  To: Miles Bader
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

    Well then why not pick _another_ good name which is still helpful to the
    code reader?  David Kastrup suggested `region-selected-p', which seems
    intuitive and helpful in the same way that region-active-p is.

I won't argue against `region-selected-p', even though it seems
less on the mark than `region-active-p'.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-02 15:02                                                   ` region-active-p Richard Stallman
@ 2007-11-02 21:39                                                     ` Stefan Monnier
  2007-11-02 22:31                                                     ` region-active-p Miles Bader
  1 sibling, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-11-02 21:39 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, stephen,
	drew.adams, Miles Bader

>     Well then why not pick _another_ good name which is still helpful to the
>     code reader?  David Kastrup suggested `region-selected-p', which seems
>     intuitive and helpful in the same way that region-active-p is.

> I won't argue against `region-selected-p', even though it seems
> less on the mark than `region-active-p'.

Both sounds good to me,


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-02 15:02                                                   ` region-active-p Richard Stallman
  2007-11-02 21:39                                                     ` region-active-p Stefan Monnier
@ 2007-11-02 22:31                                                     ` Miles Bader
  2007-11-03 20:48                                                       ` region-active-p Richard Stallman
  1 sibling, 1 reply; 81+ messages in thread
From: Miles Bader @ 2007-11-02 22:31 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

Richard Stallman <rms@gnu.org> writes:
>     Well then why not pick _another_ good name which is still helpful to the
>     code reader?  David Kastrup suggested `region-selected-p', which seems
>     intuitive and helpful in the same way that region-active-p is.
>
> I won't argue against `region-selected-p', even though it seems
> less on the mark than `region-active-p'.

Actually I prefer `region-active-p' too, as long as the slight
inconsistency with the xemacs definition is OK (I think it is,
personally).

-Miles

-- 
My spirit felt washed.  With blood.  [Eli Shin, on "The Passion of the Christ"]

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-02 22:31                                                     ` region-active-p Miles Bader
@ 2007-11-03 20:48                                                       ` Richard Stallman
  2007-11-05  6:48                                                         ` region-active-p Miles Bader
  0 siblings, 1 reply; 81+ messages in thread
From: Richard Stallman @ 2007-11-03 20:48 UTC (permalink / raw)
  To: Miles Bader
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

    Actually I prefer `region-active-p' too, as long as the slight
    inconsistency with the xemacs definition is OK (I think it is,
    personally).

The function should have an argument which says
whether an empty region should count as "selected".
They asked us to use a name that is new.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-30 23:43                                           ` region-active-p Miles Bader
  2007-10-31  6:35                                             ` region-active-p David Kastrup
@ 2007-11-03 21:08                                             ` Stephen J. Turnbull
  1 sibling, 0 replies; 81+ messages in thread
From: Stephen J. Turnbull @ 2007-11-03 21:08 UTC (permalink / raw)
  To: Miles Bader
  Cc: rms, reinersteib+gmane, andreas.roehler, emacs-devel, juri,
	Stefan Monnier, Drew Adams

Miles Bader writes:

 > Personally I think we should just use region-active-p, with non-empty
 > test by default

We and 3rd party library developers will get bug reports when people
write libraries that depend on Emacs semantics.  Please don't use this
identifier with default semantics that differ from XEmacs's; there is
no need to do so.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-11-03 20:48                                                       ` region-active-p Richard Stallman
@ 2007-11-05  6:48                                                         ` Miles Bader
  0 siblings, 0 replies; 81+ messages in thread
From: Miles Bader @ 2007-11-05  6:48 UTC (permalink / raw)
  To: rms
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, monnier,
	stephen, drew.adams

Richard Stallman <rms@gnu.org> writes:
> The function should have an argument which says
> whether an empty region should count as "selected".
> They asked us to use a name that is new.

Ok, then let's use `region-selected-p'...

-Miles

-- 
A zen-buddhist walked into a pizza shop and
said, "Make me one with everything."

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-10-29  1:40                                 ` region-active-p Stefan Monnier
@ 2007-12-10 23:08                                   ` Richard Stallman
  2007-12-11  8:15                                     ` region-active-p Andreas Röhler
  2007-12-11  9:07                                     ` region-active-p Andreas Röhler
  0 siblings, 2 replies; 81+ messages in thread
From: Richard Stallman @ 2007-12-10 23:08 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: reinersteib+gmane, andreas.roehler, emacs-devel, juri, turnbull,
	miles

I came up with a better solution to the question of what region-active-p
should do when the region is empty: make it a user option.
I think that will make people happy, because I expect most users will
have the same preference for all the commands.

I will install it when I have a good connection.

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-10 23:08                                   ` region-active-p Richard Stallman
@ 2007-12-11  8:15                                     ` Andreas Röhler
  2007-12-11  9:57                                       ` region-active-p Juri Linkov
  2007-12-11  9:07                                     ` region-active-p Andreas Röhler
  1 sibling, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-12-11  8:15 UTC (permalink / raw)
  To: rms
  Cc: Reiner Steib, emacs-devel, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Dienstag, 11. Dezember 2007 00:08 schrieb Richard Stallman:
> I came up with a better solution to the question of what region-active-p
> should do when the region is empty: make it a user option.
> I think that will make people happy, because I expect most users will
> have the same preference for all the commands.
>
> I will install it when I have a good connection.
>
>

That certainly wouldn't be wrong on the logical level,
however can't help in original case, reduces
compatibilty rather than enhances them.

My idea was to make the writing of compatible code a
little bit easier, to get rid of one of these (featurep
'xemacs) forms occasionally.

If you could ask Juri to install his answer we will all
live in a better world. :)

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-10 23:08                                   ` region-active-p Richard Stallman
  2007-12-11  8:15                                     ` region-active-p Andreas Röhler
@ 2007-12-11  9:07                                     ` Andreas Röhler
  2007-12-11  9:59                                       ` region-active-p Juri Linkov
  1 sibling, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-12-11  9:07 UTC (permalink / raw)
  To: rms
  Cc: Reiner Steib, emacs-devel, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Dienstag, 11. Dezember 2007 00:08 schrieb Richard Stallman:
> I came up with a better solution to the question of what region-active-p
> should do when the region is empty: make it a user option.
> I think that will make people happy, because I expect most users will
> have the same preference for all the commands.
>
> I will install it when I have a good connection.
>
>

To be more precisely: For the special case "region
exist but empty" XEmacs has already the function
`region-exists-p'. `region-active-p' fails in
that case and I see no reason to make things more
complicated at this point.

It's quite easy to follow in both cases, remaining
differences caused by routines below will not be
remarkable by users as was stated correctly.

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11  8:15                                     ` region-active-p Andreas Röhler
@ 2007-12-11  9:57                                       ` Juri Linkov
  2007-12-11 11:52                                         ` region-active-p Andreas Röhler
  0 siblings, 1 reply; 81+ messages in thread
From: Juri Linkov @ 2007-12-11  9:57 UTC (permalink / raw)
  To: Andreas Röhler
  Cc: rms, Reiner Steib, emacs-devel, Stefan Monnier, Stephen Turnbull,
	Miles Bader

>> I came up with a better solution to the question of what region-active-p
>> should do when the region is empty: make it a user option.
>> I think that will make people happy, because I expect most users will
>> have the same preference for all the commands.
>>
>> I will install it when I have a good connection.
>
> That certainly wouldn't be wrong on the logical level,
> however can't help in original case, reduces
> compatibilty rather than enhances them.
>
> My idea was to make the writing of compatible code a
> little bit easier, to get rid of one of these (featurep
> 'xemacs) forms occasionally.
>
> If you could ask Juri to install his answer we will all
> live in a better world. :)

I proposed:

(defun region-active-p ()
    (and transient-mark-mode mark-active
	 (not (eq (region-beginning) (region-end)))))

And as I understand, Richard wants:

(defun region-active-p ()
    (and transient-mark-mode mark-active
	 (if some-new-user-option
             (not (eq (region-beginning) (region-end))))))

This seems like a good solution.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11  9:07                                     ` region-active-p Andreas Röhler
@ 2007-12-11  9:59                                       ` Juri Linkov
  2007-12-11 11:50                                         ` region-active-p Andreas Röhler
  0 siblings, 1 reply; 81+ messages in thread
From: Juri Linkov @ 2007-12-11  9:59 UTC (permalink / raw)
  To: Andreas Röhler
  Cc: rms, Reiner Steib, emacs-devel, Stefan Monnier, Stephen Turnbull,
	Miles Bader

>> I came up with a better solution to the question of what region-active-p
>> should do when the region is empty: make it a user option.
>> I think that will make people happy, because I expect most users will
>> have the same preference for all the commands.
>>
>> I will install it when I have a good connection.
>
> To be more precisely: For the special case "region
> exist but empty" XEmacs has already the function
> `region-exists-p'. `region-active-p' fails in
> that case and I see no reason to make things more
> complicated at this point.
>
> It's quite easy to follow in both cases, remaining
> differences caused by routines below will not be
> remarkable by users as was stated correctly.

`region-exists-p' in XEmacs would be equivalent in Emacs to:

(defun region-exists-p ()
    (not (null mark-active)))

I don't see how this is comparable to `region-active-p'
with "region exist but empty" in Emacs.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11  9:59                                       ` region-active-p Juri Linkov
@ 2007-12-11 11:50                                         ` Andreas Röhler
  0 siblings, 0 replies; 81+ messages in thread
From: Andreas Röhler @ 2007-12-11 11:50 UTC (permalink / raw)
  To: emacs-devel
  Cc: Richard Stallman, Reiner Steib, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Dienstag, 11. Dezember 2007 10:59 schrieb Juri Linkov:
> >> I came up with a better solution to the question of what region-active-p
> >> should do when the region is empty: make it a user option.
> >> I think that will make people happy, because I expect most users will
> >> have the same preference for all the commands.
> >>
> >> I will install it when I have a good connection.
> >
> > To be more precisely: For the special case "region
> > exist but empty" XEmacs has already the function
> > `region-exists-p'. `region-active-p' fails in
> > that case and I see no reason to make things more
> > complicated at this point.
> >
> > It's quite easy to follow in both cases, remaining
> > differences caused by routines below will not be
> > remarkable by users as was stated correctly.
>
> `region-exists-p' in XEmacs would be equivalent in Emacs to:
>
> (defun region-exists-p ()
>     (not (null mark-active)))
>
Yes, and that's the second useful thing here, thanks.

> I don't see how this is comparable to `region-active-p'
> with "region exist but empty" in Emacs.

Because if a "region exist but empty" returns `t', the
mark must be set, nothing more is required. That's
precisely the question, `mark-active' and
`region-exists-p' are answering.


Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11  9:57                                       ` region-active-p Juri Linkov
@ 2007-12-11 11:52                                         ` Andreas Röhler
  2007-12-11 14:55                                           ` region-active-p Stefan Monnier
  0 siblings, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-12-11 11:52 UTC (permalink / raw)
  To: emacs-devel
  Cc: Richard Stallman, Reiner Steib, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Dienstag, 11. Dezember 2007 10:57 schrieb Juri Linkov:
> >> I came up with a better solution to the question of what region-active-p
> >> should do when the region is empty: make it a user option.
> >> I think that will make people happy, because I expect most users will
> >> have the same preference for all the commands.
> >>
> >> I will install it when I have a good connection.
> >
> > That certainly wouldn't be wrong on the logical level,
> > however can't help in original case, reduces
> > compatibilty rather than enhances them.
> >
> > My idea was to make the writing of compatible code a
> > little bit easier, to get rid of one of these (featurep
> > 'xemacs) forms occasionally.
> >
> > If you could ask Juri to install his answer we will all
> > live in a better world. :)
>
> I proposed:
>
> (defun region-active-p ()
>     (and transient-mark-mode mark-active
> 	 (not (eq (region-beginning) (region-end)))))
>
> And as I understand, Richard wants:
>
> (defun region-active-p ()
>     (and transient-mark-mode mark-active
> 	 (if some-new-user-option
>              (not (eq (region-beginning) (region-end))))))
>
> This seems like a good solution.


That new design of `region-active-p' would permit
behaving as `region-exists-p',

the result therefor will not be comparable with XEmacs,
even if it will differ only on a mince level. GNU user
then is able to allow something, which in not allowed
in XE, where to be `active' region _must_ have an
extend.

But why introduce new diffs? If there is a need I will
change my mind.

Until then I see two practical cases: 

- a region with an extend is needed
- if mark is set it's sufficient

Both questions are served already. For case two
`mark-active' or `region-exists-p' are enough, case one
is perfect answered with `region-active-p' in it's
comparable variant.

BTW if something deserves a `new-user-option' here, IMO
it's `transient-mark-mode', because to permit highlighting or not
has not really a meaning about the existence of the
region.

Then I come to this

(defun region-active-p ()
  (if user-requires-transient-mark-mode
      (and transient-mark-mode mark-active
	   (not (eq (region-beginning) (region-end))))
    (not (eq (region-beginning) (region-end)))))


Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11 11:52                                         ` region-active-p Andreas Röhler
@ 2007-12-11 14:55                                           ` Stefan Monnier
  2007-12-11 17:05                                             ` region-active-p Andreas Röhler
  0 siblings, 1 reply; 81+ messages in thread
From: Stefan Monnier @ 2007-12-11 14:55 UTC (permalink / raw)
  To: Andreas Röhler
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stephen Turnbull, Miles Bader

> But why introduce new diffs? If there is a need I will
> change my mind.

Diferences of behavior are perfectly fine.  The differences we do not
want are differences which break elisp code (i.e. packages).  I see no
indication that this kind of difference will ever break elisp code.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11 14:55                                           ` region-active-p Stefan Monnier
@ 2007-12-11 17:05                                             ` Andreas Röhler
  2007-12-11 18:16                                               ` region-active-p Stefan Monnier
  0 siblings, 1 reply; 81+ messages in thread
From: Andreas Röhler @ 2007-12-11 17:05 UTC (permalink / raw)
  To: emacs-devel
  Cc: Richard Stallman, Reiner Steib, Juri Linkov, Stefan Monnier,
	Stephen Turnbull, Miles Bader

Am Dienstag, 11. Dezember 2007 15:55 schrieb Stefan Monnier:
> > But why introduce new diffs? If there is a need I will
> > change my mind.
>
> Diferences of behavior are perfectly fine.  The differences we do not
> want are differences which break elisp code (i.e. packages).  I see no
> indication that this kind of difference will ever break elisp code.
>
>
>         Stefan
>

A bug then may occur at XEmacs-side if someone codes
the need for an exclusive `mark-active'/region-exists-p
with `region-active-p useroption'. XEmacs will not know
about that option, only reads `region-active-p' and
decision may be wrong.

XEmacs will always check for an extend if
`region-active-p' is written and maybe return `nil' in
cases, where it's not TRT.

Andreas Röhler

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: region-active-p
  2007-12-11 17:05                                             ` region-active-p Andreas Röhler
@ 2007-12-11 18:16                                               ` Stefan Monnier
  0 siblings, 0 replies; 81+ messages in thread
From: Stefan Monnier @ 2007-12-11 18:16 UTC (permalink / raw)
  To: Andreas Röhler
  Cc: Richard Stallman, Reiner Steib, emacs-devel, Juri Linkov,
	Stephen Turnbull, Miles Bader

>> > But why introduce new diffs? If there is a need I will
>> > change my mind.
>> 
>> Diferences of behavior are perfectly fine.  The differences we do not
>> want are differences which break elisp code (i.e. packages).  I see no
>> indication that this kind of difference will ever break elisp code.

> A bug then may occur at XEmacs-side if someone codes
> the need for an exclusive `mark-active'/region-exists-p
> with `region-active-p useroption'. XEmacs will not know
> about that option, only reads `region-active-p' and
> decision may be wrong.

> XEmacs will always check for an extend if
> `region-active-p' is written and maybe return `nil' in
> cases, where it's not TRT.

You talk about the user-level behavior.  Reread what I wrote.


        Stefan

^ permalink raw reply	[flat|nested] 81+ messages in thread

end of thread, other threads:[~2007-12-11 18:16 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-19  9:49 region-active-p Andreas Röhler
2007-10-19 20:57 ` region-active-p Juri Linkov
2007-10-21  7:25   ` region-active-p Richard Stallman
2007-10-21 13:56     ` region-active-p Stefan Monnier
2007-10-21 14:48       ` region-active-p Miles Bader
2007-10-21 19:22         ` region-active-p Andreas Röhler
2007-10-23  7:12           ` region-active-p Richard Stallman
2007-10-23  8:53             ` region-active-p Andreas Röhler
2007-10-23 17:53               ` region-active-p Richard Stallman
2007-10-24  7:33                 ` region-active-p Andreas Röhler
2007-10-25  2:10                   ` region-active-p Richard Stallman
2007-10-24 19:34             ` region-active-p Stephen J. Turnbull
2007-10-25  9:01               ` region-active-p Richard Stallman
2007-10-26  5:38                 ` region-active-p Stephen J. Turnbull
2007-10-26  8:17                   ` region-active-p Andreas Röhler
2007-10-26  9:21                     ` region-active-p Stephen J. Turnbull
2007-10-26 11:03                       ` region-active-p Andreas Röhler
2007-10-26 21:53                         ` region-active-p Stephen J. Turnbull
2007-10-27  2:28                       ` region-active-p Richard Stallman
2007-10-27  5:20                         ` region-active-p Stephen J. Turnbull
2007-10-27  6:17                           ` region-active-p Miles Bader
2007-10-27  7:57                             ` region-active-p Andreas Röhler
2007-10-28  6:55                             ` region-active-p Stephen J. Turnbull
2007-10-28  7:32                               ` region-active-p Miles Bader
2007-10-28 12:15                             ` region-active-p Johan Bockgård
2007-10-28 21:07                               ` region-active-p Stefan Monnier
2007-10-28 21:07                               ` region-active-p Stefan Monnier
2007-10-27 23:41                           ` region-active-p Richard Stallman
2007-10-28  1:21                             ` region-active-p Stefan Monnier
2007-10-28  1:27                               ` region-active-p Miles Bader
2007-10-28  2:43                                 ` region-active-p Stefan Monnier
2007-10-29  0:11                               ` region-active-p Richard Stallman
2007-10-29  1:40                                 ` region-active-p Stefan Monnier
2007-12-10 23:08                                   ` region-active-p Richard Stallman
2007-12-11  8:15                                     ` region-active-p Andreas Röhler
2007-12-11  9:57                                       ` region-active-p Juri Linkov
2007-12-11 11:52                                         ` region-active-p Andreas Röhler
2007-12-11 14:55                                           ` region-active-p Stefan Monnier
2007-12-11 17:05                                             ` region-active-p Andreas Röhler
2007-12-11 18:16                                               ` region-active-p Stefan Monnier
2007-12-11  9:07                                     ` region-active-p Andreas Röhler
2007-12-11  9:59                                       ` region-active-p Juri Linkov
2007-12-11 11:50                                         ` region-active-p Andreas Röhler
2007-10-28  7:29                             ` region-active-p Stephen J. Turnbull
2007-10-28 21:06                               ` region-active-p Stefan Monnier
2007-10-29  0:11                               ` region-active-p Richard Stallman
2007-10-30  0:12                                 ` region-active-p Stephen J. Turnbull
2007-10-30  8:22                                   ` region-active-p Richard Stallman
2007-10-30  8:59                                     ` region-active-p David Kastrup
2007-10-31  7:46                                       ` region-active-p Richard Stallman
2007-10-30 15:03                                     ` region-active-p Drew Adams
2007-10-30 19:03                                       ` region-active-p Stefan Monnier
2007-10-30 19:49                                         ` region-active-p Drew Adams
2007-10-30 20:15                                           ` region-active-p Stefan Monnier
2007-10-30 20:28                                             ` region-active-p Drew Adams
2007-10-30 21:30                                               ` region-active-p Stefan Monnier
2007-10-30 23:43                                           ` region-active-p Miles Bader
2007-10-31  6:35                                             ` region-active-p David Kastrup
2007-10-31  7:59                                               ` region-active-p Miles Bader
2007-11-03 21:08                                             ` region-active-p Stephen J. Turnbull
2007-10-31  7:47                                       ` region-active-p Richard Stallman
2007-10-31  7:47                                       ` region-active-p Richard Stallman
2007-10-31  8:00                                         ` region-active-p Miles Bader
2007-10-31 23:58                                           ` region-active-p Richard Stallman
2007-11-01  2:33                                             ` region-active-p Miles Bader
2007-11-01  2:55                                               ` region-active-p Stefan Monnier
2007-11-01 10:06                                                 ` region-active-p Kim F. Storm
2007-11-01 15:46                                                   ` region-active-p Drew Adams
2007-11-01 17:56                                                     ` region-active-p David Kastrup
2007-11-01 23:08                                                       ` region-active-p Richard Stallman
2007-11-01 19:04                                               ` region-active-p Richard Stallman
2007-11-02  0:18                                                 ` region-active-p Miles Bader
2007-11-02 15:02                                                   ` region-active-p Richard Stallman
2007-11-02 21:39                                                     ` region-active-p Stefan Monnier
2007-11-02 22:31                                                     ` region-active-p Miles Bader
2007-11-03 20:48                                                       ` region-active-p Richard Stallman
2007-11-05  6:48                                                         ` region-active-p Miles Bader
2007-10-29  8:24                               ` region-active-p Andreas Röhler
2007-10-22  6:09         ` region-active-p Andreas Röhler
2007-10-21 17:18       ` region-active-p Stephen J. Turnbull
2007-10-21 20:54         ` region-active-p Reiner Steib

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).