tags:

views:

79

answers:

2

I have a command called go-to-url that I call in my lisp code, which opens up a webpage, I just pass it a value string as so:

(go-to-url "www.yahoo.com")

However it'd be nice to use this function from the M-x command line. Is there a way to do that? Nothing that I have tried works

+11  A: 

Hi John,

you would use the interactive form:

(defun go-to-url (url)
  (interactive "sURL: ")
  (do-your-stuff url))

This way you can use go-to-url both in your lisp and with M-x: go-to-url and you'll be prompted for the argument.

See also my reply to your other question: http://stackoverflow.com/questions/2235884/emacs-is-there-a-way-to-create-a-interactive-script-using-emacs

danielpoe
Hey Daniel, thanks for the reply to both of my questions, this is really helpful, so I can kill 2 birds with 1 stone this way. Thanks a lot. I'll get back to the other question later when I have time hopefully later today. Just been swamped at work. Thanks though, this will save me a bit of my day :-)
John Baker
A: 

There is a function that does this already `browse-url', which will prompt you to browse the url at point or you can edit/create one.

For functions that take numeric arguments you can also use C-u then type the value you want passing to the command you execute.

justinhj