unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* kill-region in 24.4 shouldn't require BEG and END
@ 2014-11-15  6:55 Kelly Dean
  0 siblings, 0 replies; 3+ messages in thread
From: Kelly Dean @ 2014-11-15  6:55 UTC (permalink / raw)
  To: emacs-devel

If the REGION argument is non-nil, then BEG and END shouldn't be required, since they're unused (except in one place where they aren't needed). So the test
⌜unless (and beg end)⌝
in kill-region should be
⌜unless (or region (and beg end))⌝
and the docstring should point out that if REGION is non-nil, then BEG and END are unused and might as well be nil.

The one place in kill-region where BEG and END are unnecessarily used if REGION is non-nil is the line
⌜(kill-append string (< end beg))⌝
which should be something like
⌜(kill-append string (if region
			(< (point) (mark))
		       (< end beg)))⌝
and similarly for copy-region-as-kill.

Without these changes, both kill-region and its docstring are confusing.

Also, it would be clearer to have different names for the region between the cursor (er. point) and mark vs. a region between two specified positions; maybe call the latter a ‟range”, and have a cut-range function that takes BEG and END and have a cut-region function that takes no arguments, have both call kill-region, rename the latter to ‟cut-range-or-region”, and provide ‟kill-region” as an alias to the latter and mark it as deprecated, but I guess we'd have to wait 20 years before that alias could be safely removed. To go along with that, rename the kill-ring to ‟clip-ring” (not ‟cut-ring” since it holds not just cut things, but also copied things) to be memorable as a ring of clippings since everybody knows what a clipboard is, and rename all the associated functions.
But Emacs just wouldn't be the same if it didn't let us kill things anymore. Maybe the traditional, weaponized version is better after all.



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

* Re: kill-region in 24.4 shouldn't require BEG and END
       [not found] <emacs-mail-is-unusable-1@[87.69.4.28]>
@ 2014-11-15  8:38 ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2014-11-15  8:38 UTC (permalink / raw)
  To: Kelly Dean; +Cc: emacs-devel

> From: Kelly Dean <kelly@prtime.org>
> Date: Sat, 15 Nov 2014 06:55:38 +0000
> 
> If the REGION argument is non-nil, then BEG and END shouldn't be required, since they're unused (except in one place where they aren't needed). So the test
> ⌜unless (and beg end)⌝
> in kill-region should be
> ⌜unless (or region (and beg end))⌝
> and the docstring should point out that if REGION is non-nil, then BEG and END are unused and might as well be nil.

First, please in the future report bugs with "M-x report-emacs-bug",
which will direct the report to the bug tracker, and will also collect
and report the details about your Emacs version and setup that might
be required for analyzing the report.

> The one place in kill-region where BEG and END are unnecessarily used if REGION is non-nil is the line
> ⌜(kill-append string (< end beg))⌝
> which should be something like
> ⌜(kill-append string (if region
> 			(< (point) (mark))
> 		       (< end beg)))⌝
> and similarly for copy-region-as-kill.
> 
> Without these changes, both kill-region and its docstring are confusing.

I don't see how the doc string is confusing.  Your observations might
be correct, but they are based on reading the source code of the
implementation of the function.  I submit that what you saw there are
internal implementation details subject to change without notice, and
that therefore the doc string deliberately refrains from saying what
you want it to say.  IOW, if the implementation is changed some day
such that BEG and END _are_ used even when REGION is given, the
current doc string will still be correct.

Implementation details aside, I've re-read the doc string and found
nothing confusing in it.  If I were to use this function, I understand
from the doc string that I need to provide BEG and END, and also
provide REGION of BEG and END delineated the current region.  This
sounds pretty clear to me.

> Also, it would be clearer to have different names for the region between the cursor (er. point) and mark vs. a region between two specified positions; maybe call the latter a ‟range”, and have a cut-range function that takes BEG and END and have a cut-region function that takes no arguments, have both call kill-region, rename the latter to ‟cut-range-or-region”, and provide ‟kill-region” as an alias to the latter and mark it as deprecated, but I guess we'd have to wait 20 years before that alias could be safely removed. To go along with that, rename the kill-ring to ‟clip-ring” (not ‟cut-ring” since it holds not just cut things, but also copied things) to be memorable as a ring of clippings since everybody knows what a clipboard is, and rename all the associated functions.

IMO, this would be unnecessary complexity.  We already have all those
use cases covered in that single API.

Thanks.




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

* Re: kill-region in 24.4 shouldn't require BEG and END
       [not found] <emacs-mail-is-unusable-1>
@ 2014-11-15 15:22 ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2014-11-15 15:22 UTC (permalink / raw)
  To: Kelly Dean; +Cc: emacs-devel

> If the REGION argument is non-nil, then BEG and END shouldn't be
> required, since they're unused (except in one place where they aren't
> needed).  So the test
>    ⌜unless (and beg end)⌝
> in kill-region should be
>    ⌜unless (or region (and beg end))⌝
> and the docstring should point out that if REGION is non-nil, then BEG
> and END are unused and might as well be nil.

I think a simpler change would be to add, right after the `interactive'
line, a simple:

   (if region (setq beg (mark) end (point)))

Which would make it obvious that the beg/end arguments are not used when
region is non-nil, without having to scan the rest of the code.  And it
would keep the rest of the code simpler (less sprinkling of tests of
`region').

And we could even use another API where we only have BEG and END and say
that if BEG is the symbol `region', then use *the* region.


        Stefan



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

end of thread, other threads:[~2014-11-15 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <emacs-mail-is-unusable-1>
2014-11-15 15:22 ` kill-region in 24.4 shouldn't require BEG and END Stefan Monnier
     [not found] <emacs-mail-is-unusable-1@[87.69.4.28]>
2014-11-15  8:38 ` Eli Zaretskii
2014-11-15  6:55 Kelly Dean

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