Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6337509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:15:50+00:00 2026-05-24T19:15:50+00:00

Is there some module or command that’ll let me send the current region to

  • 0

Is there some module or command that’ll let me send the current region to shell?

I want to have something like Python-mode’s python-send-region which sends the selected region to the currently running Python shell.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:15:51+00:00Added an answer on May 24, 2026 at 7:15 pm

    Ok, wrote an easy bit. Will probably spend some time to write a complete minor mode.

    For time being the following function will send current line (or region if the mark is active). Does quite a good job for me:

    (defun sh-send-line-or-region (&optional step)
      (interactive ())
      (let ((proc (get-process "shell"))
            pbuf min max command)
        (unless proc
          (let ((currbuff (current-buffer)))
            (shell)
            (switch-to-buffer currbuff)
            (setq proc (get-process "shell"))
            ))
        (setq pbuff (process-buffer proc))
        (if (use-region-p)
            (setq min (region-beginning)
                  max (region-end))
          (setq min (point-at-bol)
                max (point-at-eol)))
        (setq command (concat (buffer-substring min max) "\n"))
        (with-current-buffer pbuff
          (goto-char (process-mark proc))
          (insert command)
          (move-marker (process-mark proc) (point))
          ) ;;pop-to-buffer does not work with save-current-buffer -- bug?
        (process-send-string  proc command)
        (display-buffer (process-buffer proc) t)
        (when step 
          (goto-char max)
          (next-line))
        ))
    
    (defun sh-send-line-or-region-and-step ()
      (interactive)
      (sh-send-line-or-region t))
    (defun sh-switch-to-process-buffer ()
      (interactive)
      (pop-to-buffer (process-buffer (get-process "shell")) t))
    
    (define-key sh-mode-map [(control ?j)] 'sh-send-line-or-region-and-step)
    (define-key sh-mode-map [(control ?c) (control ?z)] 'sh-switch-to-process-buffer)
    

    Enjoy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I built a Perl Inline::C module, but there is some oddity with the sorting.
If a large module is loaded by some submodule of your code, is there
Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
Is there some way to hide the browser toolbar / statusbar etc in current
Is there some rare language construct I haven't encountered (like the few I've learned
I'm using Perl's Getopt::Long module to parse command line arguments. However, it seems that
I use some libraries that I don't want built as part of every project
Well, I have made a module that allows you to copy a file to
I would like to run an executable that performs some processing on a dataset
I have a .net application that is doing COM interop and calling some native

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.