[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Allow (help "regex") to work correctly.
From: |
Chris K. Jester-Young |
Subject: |
[PATCH] Allow (help "regex") to work correctly. |
Date: |
Mon, 28 Oct 2013 08:35:11 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
When using the (help "regex") syntax, if the search has no matches, you
get an error message of this form:
scheme@(guile-user)> (help "foo")
While compiling expression:
ERROR: In procedure symbol->string: Wrong type argument in position 1
(expecting symbol): "foo"
With this fix, the error message is much more sensible:
scheme@(guile-user)> (help "foo")
Did not find any object matching regexp "foo"
* module/ice-9/documentation.scm: Adjust search-documentation-files's
documentation to say that it will accept strings too.
(find-documentation-in-file): Only call symbol->string if the incoming
object is a symbol. Also convert to use let* instead of nested let.
---
module/ice-9/documentation.scm | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/module/ice-9/documentation.scm b/module/ice-9/documentation.scm
index 9b0a121..cdcebba 100644
--- a/module/ice-9/documentation.scm
+++ b/module/ice-9/documentation.scm
@@ -24,9 +24,9 @@
;; documentation-files -- a search-list of files using the Guile
;; Documentation Format Version 2.
;;
-;; search-documentation-files -- a procedure that takes NAME (a symbol)
-;; and searches `documentation-files' for
-;; associated documentation. optional
+;; search-documentation-files -- a procedure that takes NAME (a symbol or
+;; string) and searches `documentation-files'
+;; for associated documentation. optional
;; arg FILES is a list of filenames to use
;; instead of `documentation-files'.
;;
@@ -161,21 +161,21 @@
(and (file-exists? file)
(call-with-input-file file
(lambda (port)
- (let ((name (symbol->string name)))
- (let ((len (string-length name)))
- (read-delimited entry-delimiter port) ;skip to first entry
- (let loop ((entry (read-delimited entry-delimiter port)))
- (cond ((eof-object? entry) #f)
- ;; match?
- ((and ;; large enough?
- (>= (string-length entry) len)
- ;; matching name?
- (string=? (substring entry 0 len) name)
- ;; terminated?
- (memq (string-ref entry len) '(#\newline)))
- ;; cut away name tag and extra surrounding newlines
- (substring entry (+ len 2) (- (string-length entry) 2)))
- (else (loop (read-delimited entry-delimiter
port)))))))))))
+ (let* ((name (if (symbol? name) (symbol->string name) name))
+ (len (string-length name)))
+ (read-delimited entry-delimiter port) ;skip to first entry
+ (let loop ((entry (read-delimited entry-delimiter port)))
+ (cond ((eof-object? entry) #f)
+ ;; match?
+ ((and ;; large enough?
+ (>= (string-length entry) len)
+ ;; matching name?
+ (string=? (substring entry 0 len) name)
+ ;; terminated?
+ (memq (string-ref entry len) '(#\newline)))
+ ;; cut away name tag and extra surrounding newlines
+ (substring entry (+ len 2) (- (string-length entry) 2)))
+ (else (loop (read-delimited entry-delimiter port))))))))))
(define (search-documentation-files name . files)
(or-map (lambda (file)
--
1.7.10.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Allow (help "regex") to work correctly.,
Chris K. Jester-Young <=