Subject: Re: bug#19829: 25.0.50; Design of commands operating on rectangular regions

From: Juri Linkov <[email-masked]>
Date: Thu, 02 Jul 2015 01:17:53 +0300

>> +(defun region ()
>> +  `(region
>> +    (positions ,@(funcall region-extract-function 'positions))))
>
> I don't think we want such a short name.  How 'bout `region-boundaries'?
> Also, why `(region (positions ,@<foo>)) rather than something simpler
> like `(region ,@<foo>)?

The goal is to design the interface as general as possible
to be able to define potential future non-rectangular regions.
For instance, a circular region could be defined in the future as:

  (region
   (shape . circle)
   (radius . 42)
   (center . ...)
   ...

Then to distinguish a rectangular region we could add (shape . rectangle)
to the current information:

  (region
   (shape . rectangle)
   (positions . ...)
   ...

>> -(defun query-replace (from-string to-string &optional delimited start end backward)
>> +(defun query-replace (from-string to-string &optional delimited start end backward region)
> [...]
>> +	   (if (use-region-p) (region-beginning))
>> +	   (if (use-region-p) (region-end))
>> +	   (nth 3 common)
>> +	   (if (use-region-p) (region)))))
>
> I think we should re-use one of START or END rather than add a REGION argument.

Stuffing the region information into one of its boundary args would be too ugly.
I guess this is why you designed a cleaner interface by adding a REGION argument
to several commands:

  (defun kill-region (beg end &optional region)
  (defun kill-ring-save (beg end &optional region)
  (defun copy-region-as-kill (beg end &optional region)

with such a clean docstring:

  "The optional argument REGION if non-nil, indicates that we're not just killing
   some text between BEG and END, but we're killing the region.

that will fit other commands like ‘downcase-region’ and ‘shell-command-on-region’
when replacing “killing the region” with a more general “operating on the region”.