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 8535363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:24:49+00:00 2026-06-11T10:24:49+00:00

Ok, noob question maybe but I am having trouble finding information about this stuff.

  • 0

Ok, noob question maybe but I am having trouble finding information about this stuff. I want to write a function that takes whatever is selected in a region and passes it to curl. Curl returns something and I want that something to replace the selected region. In other words, after selecting http://www.foo.com in a region and running the function, the it would be replaced with whatever curl would return if ran on the command line with curl www.foo.com.

Here is my attempt which is very very wrong. Basically, I can’t figure out how to pass that selected region as a variable to shell-command-on-region:

(defun curl-something()
  (interactive)
  (setq region ((region-beginning)(region-end)))
  (shell-command-on-region (region-beginning) (region-end) (shell-command (concat "curl" region)) nil t))

Also, if anyone has any pointers on where to learn basic elisp text manipulation programming, please share them (not reference manuals please). Thanks!

Edit:

Thanks to Randy Morris, I was able to figure out the answer:

(defun curl-something (begin end)
  (interactive "r")
  (shell-command-on-region begin end (concat "curl -s " (buffer-substring begin end)) nil t))
  • 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-06-11T10:24:50+00:00Added an answer on June 11, 2026 at 10:24 am

    You need to pass the “r” flag to (interactive). Your function will then be passed the start and end of the region as numeric arguments which you can use to get the text in the region.

    Here is an example taken from ErgoEmacs:

    (defun dosomething-region (p1 p2)
      "Prints region starting and ending positions." 
      (interactive "r")
      (message "Region starts: %d, end at: %d" p1 p2))
    

    The following function will grab the url and pass it to curl, then dump the contents of that website in a new buffer:

    (defun curl-something (begin end)
      (interactive "r")
      (shell-command (concat "curl " (buffer-substring begin end))))
    

    Also worth noting are the native url- functions for this sort of thing, but I realize that this is beyond the scope of this question.

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

Sidebar

Related Questions

This maybe a noob question but please help me. I found a library called
This may be a noob question but I want to hide the content within
i am new to WPF so maybe this will be noob question but i
Maybe that's a noob question but is there a way to have an yellow
This is a very noob-ish question but I can't figure it out. I want
maybe this is a noob question, but I'm receiving some data over TCP and
Maybe kind of a noob .NET question, but is there an enum that represents
Noob question here! I have an array with hashes that looks like this: arr
Real noob question no doubt, but I can't get my head around this behaviour.
Hi Sorry for this noob question but here goes...i have a working slidetoggle on

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.