From 379f2a162beec900f6132dd94e40f216e36965cf Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 5 Jan 2008 22:39:32 +0000 Subject: [PATCH] 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 --- collects/drscheme/private/help-desk.ss | 10 +---- collects/drscheme/private/rep.ss | 2 +- collects/drscheme/private/tool-contracts.ss | 47 --------------------- collects/drscheme/private/unit.ss | 9 +--- collects/help/help.ss | 5 +-- collects/help/search.ss | 21 ++++++--- 6 files changed, 21 insertions(+), 73 deletions(-) diff --git a/collects/drscheme/private/help-desk.ss b/collects/drscheme/private/help-desk.ss index 751158fb00..f7769688ef 100644 --- a/collects/drscheme/private/help-desk.ss +++ b/collects/drscheme/private/help-desk.ss @@ -78,11 +78,5 @@ (define help-desk (case-lambda - [() (void)] - [(key) (help-desk key #f)] - [(key lucky?) (help-desk key lucky? 'keyword+index)] - [(key lucky? type) (help-desk key lucky? type 'contains)] - [(key lucky? type mode) (help-desk key lucky? type mode #f)] - [(key lucky? type mode language) - (generate-search-results (list key)) - (void)])) + [() (send-main-page)] + [(key) (generate-search-results (list key))])) diff --git a/collects/drscheme/private/rep.ss b/collects/drscheme/private/rep.ss index 031ab469b7..a7029b2010 100644 --- a/collects/drscheme/private/rep.ss +++ b/collects/drscheme/private/rep.ss @@ -302,7 +302,7 @@ TODO (and (is-a? tlw drscheme:unit:frame<%>) (send (send tlw get-definitions-text) get-next-settings)))))]) - (drscheme:help-desk:help-desk str #f 'keyword+index 'contains language))))] + (drscheme:help-desk:help-desk str))))] [else (drscheme:help-desk:help-desk)]))) (let ([with-drs-frame diff --git a/collects/drscheme/private/tool-contracts.ss b/collects/drscheme/private/tool-contracts.ss index f6d50393a7..76336c2e30 100644 --- a/collects/drscheme/private/tool-contracts.ss +++ b/collects/drscheme/private/tool-contracts.ss @@ -1306,53 +1306,6 @@ "Constructs a vector whose elements are the fields of \\var{simple-settings}.") - ; - ; - ; - ; ; ; ; ; - ; ; ; ; ; - ; ; ; ; ; - ; ; ;; ;;; ; ; ;; ;; ; ;;; ;;; ; ; - ; ;; ; ; ; ; ;; ; ; ;; ; ; ; ; ; - ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; - ; ; ; ;;;;;; ; ; ; ;;;;;; ; ; ;;;;;; ;; ;;; - ; ; ; ; ; ; ; ; ; ; ; ; ; - ; ; ; ; ; ;; ; ; ;; ; ; ; ; - ; ; ; ;;;; ; ; ;; ;; ; ;;;; ;;; ; ; - ; ; - ; ; - ; ; - - (drscheme:help-desk:help-desk - (case-> - (-> void?) - (string? boolean? (symbols 'keyword 'keyword+index 'all) (symbols 'exact 'contains 'regexp) - . -> . - void?) - (string? boolean? (symbols 'keyword 'keyword+index 'all) . -> . void?) - (string? boolean? . -> . void?)) - (() - (key lucky? type mode) - (key lucky? type) - (key lucky?)) - - "This function opens a help desk window, or brings an already open help" - "desk window to the front. If an argument is specified, that key is" - "searched for." - "" - "If no arguments are supplied, this function" - "opens a help-desk window to the starting page, or just brings a" - "help-desk window to the front (without changing what page it is" - "viewing)." - "" - "If any arguments are supplied, this function" - "opens a help-desk window and searches for \\var{key}, according to " - "\\var{lucky?}, \\var{type}, and \\var{mode}." - "If the second, third, fourth, and/or fifth arguments are omitted, " - "they default to \\scmc{\\#t} \\Symbol{keyword+index} and \\Symbol{exact}," - "and \\Symbol{all} respectively.") - - ; diff --git a/collects/drscheme/private/unit.ss b/collects/drscheme/private/unit.ss index cf65a5673d..e00340f7dd 100644 --- a/collects/drscheme/private/unit.ss +++ b/collects/drscheme/private/unit.ss @@ -140,14 +140,7 @@ module browser threading seems wrong. str (- 200 (string-length (string-constant search-help-desk-for))))) menu - (λ x (help-desk:help-desk str #f 'keyword+index 'contains language))) - (make-object menu-item% - (gui-utils:format-literal-label (string-constant exact-lucky-search-help-desk-for) - (shorten-str - str - (- 200 (string-length (string-constant exact-lucky-search-help-desk-for))))) - menu - (λ x (help-desk:help-desk str #t 'keyword+index 'exact language))) + (λ x (help-desk:help-desk str))) (void))))))))) ;; find-symbol : number -> string diff --git a/collects/help/help.ss b/collects/help/help.ss index 9300316365..0b0d288d82 100644 --- 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 index edafda85f6..cee470d6d3 100644 --- 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))))