mit-scheme-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MIT-Scheme-users] A working BROWSE-URL-AT-POINT for Edwin


From: Rich Loveland
Subject: [MIT-Scheme-users] A working BROWSE-URL-AT-POINT for Edwin
Date: Wed, 7 Jan 2015 22:28:29 -0500
User-agent: IMAIL/1.21; Edwin/3.116; MIT-Scheme/9.2

A feature I've missed in Edwin is the ability to easily browse a URL
at point, especially when reading email.  With the following Edwin
command bound to a key, things are much nicer:

(define-command browse-url-at-point
  "Open the thing at point in an external web browser.
The thing at point must be a valid HTTP URI."
  ()
  (lambda ()
    (let* ((url-candidate (thing-at-point)))
      (if (not (http-request-uri? (->uri url-candidate)))
          (error "Thing at point is not a valid HTTP request URI: " 
url-candidate)
          (let* ((browser (if (string=?
                                  microcode-id/operating-system-variant
                                  "OS X")
                                 "open -a Firefox"
                                 "firefox"))
                    (browser-command (string-append browser " " url-candidate)))
               (run-shell-command browser-command))))))

The browser check is not robust, but I only use Firefox on OS X and
Linux.  Edit to suit.  This should probably be a variable set by the
user from Edwin.

Hope someone finds it useful.

(Note: This command uses THING-AT-POINT, which is defined in an
earlier message to this list with the subject "Edwin command to
quickly view source of a Scheme procedure".)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]