commit 4a193f003160e7d19c1f5db50b14e475bac66091
parent fed85187e35d6d6cdb9e490e74b6556aac9a2e28
Author: Robby Findler <robby@racket-lang.org>
Date: Sat, 5 Jan 2008 22:39:32 +0000
searching in help desk now says 'no results' if there are no results, and the help desk menu item in drscheme opens the front page of the manuals
svn: r8227
original commit: 379f2a162beec900f6132dd94e40f216e36965cf
Diffstat:
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/collects/help/help.ss b/collects/help/help.ss
@@ -1,8 +1,6 @@
#lang scheme/base
(require "search.ss"
- net/sendurl
- setup/dirs
scheme/cmdline)
(define exact-search? #f)
@@ -18,7 +16,6 @@
(error 'plt-help "expected a single search term, got ~s" search-term))
(send-exact-results (car search-term))]
[(null? search-term)
- (let ([dest-path (build-path (find-doc-dir) "start" "index.html")])
- (send-url (format "file://~a" (path->string dest-path))))]
+ (send-main-page)]
[else
(generate-search-results search-term)]))
diff --git a/collects/help/search.ss b/collects/help/search.ss
@@ -10,11 +10,17 @@
(prefix-in scheme: scribble/scheme)
net/sendurl
net/uri-codec
- mzlib/contract)
+ mzlib/contract
+ setup/dirs)
(provide/contract
[generate-search-results (-> (listof string?) void?)]
- [send-exact-results (-> string? void?)])
+ [send-exact-results (-> string? void?)]
+ [send-main-page (-> void?)])
+
+(define (send-main-page)
+ (let ([dest-path (build-path (find-doc-dir) "start" "index.html")])
+ (send-url (format "file://~a" (path->string dest-path)))))
;; if there is exactly one exact match for this search key, go directly
;; to that place. Otherwise, go to a page that lists all of the matches.
@@ -58,9 +64,14 @@
[matching-entries (filter (has-match search-regexps) index)]
[exact-matches (filter (has-match exact-search-regexps) matching-entries)]
[inexact-matches (filter (compose not (has-match exact-search-regexps)) matching-entries)])
- (append
- (build-itemization "Exact matches" exact-matches)
- (build-itemization "Containing matches" inexact-matches)))))
+ (cond
+ [(and (null? exact-matches)
+ (null? inexact-matches))
+ (list (make-element "schemeerror" (list "No results found.")))]
+ [else
+ (append
+ (build-itemization "Exact matches" exact-matches)
+ (build-itemization "Containing matches" inexact-matches))]))))
file)
(send-url (format "file://~a" (path->string file)))
(void))))