Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Late edit</strong>: As much as I appreciate the upvotes, Jurta's answer is the way to go. And Greg's hack is neater than mine.</p> <p>I'll leave the rest of this here because it might be worth something, but...</p> <hr> <p><strong><code>M-x shell-command-on-region</code></strong>, which appears to be bound to <strong><code>M-|</code></strong> by default.</p> <hr> <p>I see that this does not do exactly what Rohit asked for. Using <code>C-h f shell-command-on-region</code> reveals that the desired behavior is available in the non-interactive version of the command (by setting the argument <code>replace</code> to non-nil). We should be able to write a wrapper to do this. </p> <p>Try this (load it into <code>*scratch*</code> and run <code>M-x eval-buffer</code>, if it works, copy it to your .emacs file):</p> <pre><code>(defun shell-command-on-region-replace (start end command) "Run shell-command-on-region interactivly replacing the region in place" (interactive (let (string) (unless (mark) (error "The mark is not set now, so there is no region")) ;; Do this before calling region-beginning ;; and region-end, in case subprocess output ;; relocates them while we are in the minibuffer. ;; call-interactively recognizes region-beginning and ;; region-end specially, leaving them in the history. (setq string (read-from-minibuffer "Shell command on region: " nil nil nil 'shell-command-history)) (list (region-beginning) (region-end) string))) (shell-command-on-region start end command t t) ) </code></pre> <p>And note as I say in the comments that this is not a very emacsy thing to do. But I think it works.</p> <hr> <p>For any readers who don't know how to select a region:</p> <ol> <li>Move the "point" (current cursor position) to one end of the region, and use <code>C-space</code> to activate the "mark"</li> <li>Move the point to the other end of the region</li> <li>Your done, invoke the command</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload