emacs-devel
[Top][All Lists]
Advanced

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

Re: Design of commands operating on rectangular regions


From: John Wiegley
Subject: Re: Design of commands operating on rectangular regions
Date: Fri, 20 Nov 2015 11:10:49 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)

>>>>> Juri Linkov <address@hidden> writes:

>  (defun shell-command-on-region (start end command
>                                     &optional output-buffer replace
> -                                   error-buffer display-error-buffer)
> +                                   error-buffer display-error-buffer
> +                                   region-noncontiguous-p)
>    "Execute string COMMAND in inferior shell with region as input.

Juri,

Can you tell me more about the meaning of `region-noncontiguous-p' here? How
does the caller know when this option is required?

My takeaway is that this patch conflates user-level indications (selected
regions) too closely with the programmatically provided entities (the region
specified by START END). Perhaps it points to the need for an `interactive'
specifier to request "the current region, though if multiple sub-regions
exist, the set of spans indicated by those sub-regions". A function like
`shell-command-on-region' should be determined by its arguments. This patch
introduces a much tighter coupling with its context of use than what we had
previously.

To make that last statement clearer: Right now, `shell-command-on-region' acts
on a buffer, and a region of text within that buffer. This region is provided
to the command through its arguments by (interactive "r"). The only thing that
`shell-command-on-region' needs to do beyond that is to query the current
buffer, in order to feed text to the executed process. So, our "context" is
the current buffer, while everything else is provided by its arguments.

Your patch introduces a more hybridized behavior: (interactive "r") provides
the total extent of the region, but now there's an additional parameter,
`region-noncontiguous-p', that alters the behavior of shell-command-on-region
so that it pays attention not only to the current buffer, but also to
user-specified regions when drawing text from the buffer. And these regions
are only somewhat related to the region provided by "interactive 'r'".

I feel that the semantic "level" of these three arguments -- START, END and
REGION-NONCONTIGUOUS-P -- are now different, which I find confusing.
`region-noncontiguous-p' doesn't relate to the `interactive' form at all, but
rather solely to this new behavior, internal to shell-command-on-region.

I'd really like to solve this in a different manner for 25.1.

John



reply via email to

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