GNU bug report logs -
#20626
Wishlist: M-x shell-command-on-rectangle-region
Previous Next
Reported by: asparagus <at> comcast.net
Date: Thu, 21 May 2015 22:05:02 UTC
Severity: normal
Merged with 19829,
20070
Found in versions 24.3, 25.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>> Wishlist:
>> M-x shell-command-on-rectangle-region
>
> As you can see in bug#20070, the effort to make commands rectangleable
> had stalled some time ago due to the need to decide how to handle
> backward-compatibility of the existing region arguments, e.g. in
>
> (shell-command-on-region START END COMMAND &optional OUTPUT-BUFFER REPLACE
> ERROR-BUFFER DISPLAY-ERROR-BUFFER)
>
> how to send the boundaries of the rectangular region in START and END.
>
> One idea is to handle it like recently we handled backward-compatibility
> for saving dired positions in saveplace.el where we used a new format like
>
> ("~" (dired-filename . "~/.emacs.d/places"))
>
> Using something like this means sending the rectangular bounds
> either in START or END in the new format like
>
> (rect (1 . 2) (3 . 4))
Sorry, I was wrong. I realized now that query-replace has quite
a different requirement. query-replace needs rectangular boundaries
to limit the search for replacements, whereas shell-command-on-region
should extract the rectangular region as strings and replace it with
the result of the command. Here is a working prototype that demonstrates
its possible implementation:
(define-advice shell-command-on-region
(:around (orig-fun start end command
&optional output-buffer replace
error-buffer display-error-buffer))
(if (and (boundp 'rectangle-mark-mode) rectangle-mark-mode)
(let ((input (mapconcat 'identity (delete-extract-rectangle start end) "\n"))
output)
(with-temp-buffer
(insert input)
(call-process-region (point-min) (point-max)
shell-file-name t t
nil shell-command-switch
command)
(setq output (split-string (buffer-string) "\n")))
(goto-char start)
(insert-rectangle output))
(funcall orig-fun start end command
output-buffer replace
error-buffer display-error-buffer)))
This is another case to take into account when designing the interface,
i.e. in this case the list of boundaries in the arg START is not necessary,
and I have no idea how to avoid `(if (and (boundp 'rectangle-mark-mode)
rectangle-mark-mode))'
This bug report was last modified 9 years and 195 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.