some reformatting, use kw instead of opt-lambda
svn: r5721
This commit is contained in:
parent
c064fe4238
commit
625db9b469
|
@ -1,7 +1,7 @@
|
|||
(module sendurl mzscheme
|
||||
(require (lib "process.ss")
|
||||
(lib "file.ss")
|
||||
(lib "etc.ss")
|
||||
(lib "kw.ss")
|
||||
(lib "port.ss")
|
||||
(lib "sendevent.ss"))
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
|||
(define separate-by-default?
|
||||
(get-preference 'new-browser-for-urls (lambda () #t)))
|
||||
|
||||
; : any -> bool
|
||||
(define (custom-browser? x)
|
||||
(and (pair? x) (string? (car x)) (string? (cdr x))))
|
||||
|
||||
; : any -> bool
|
||||
(define (browser-preference? x)
|
||||
(or (not x) (eq? 'plt x) (memq x unix-browser-list) (custom-browser? x)
|
||||
|
@ -24,8 +28,8 @@
|
|||
(error 'external-browser "~a is not a valid browser preference" x)))))
|
||||
|
||||
; send-url : str [bool] -> void
|
||||
(define send-url
|
||||
(opt-lambda (url-str [separate-window? separate-by-default?])
|
||||
(define/kw (send-url url-str
|
||||
#:optional [separate-window? separate-by-default?])
|
||||
(cond
|
||||
[(procedure? (external-browser))
|
||||
((external-browser) url-str)]
|
||||
|
@ -99,11 +103,7 @@
|
|||
(browser-process cmd))]
|
||||
[else
|
||||
(error 'send-url "Couldn't find ~a to open URL: ~e" (orify unix-browser-list) url-str)]))]
|
||||
[else (error 'send-url "don't know how to open URL on platform: ~s" (system-type))])))
|
||||
|
||||
; : tst -> bool
|
||||
(define (custom-browser? x)
|
||||
(and (pair? x) (string? (car x)) (string? (cdr x))))
|
||||
[else (error 'send-url "don't know how to open URL on platform: ~s" (system-type))]))
|
||||
|
||||
(define unix-browser-list '(opera galeon netscape mozilla dillo))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user