Commits

Paul Sexton  committed 42de58d

Fixed problem with lambda list introspection in clisp.
Long lambda lists are now wrapped.
Updated documentation.

  • Participants
  • Parent commits f614283

Comments (0)

Files changed (3)

   (apply #'concatenate 'string strings))
 
 
+(defun string-starts-with? (str start)
+  "* Arguments
+- STR :: A string.
+- START :: A smaller string.
+* Returns
+Boolean.
+* Description
+Predicate. Does the string =STR= start with the string =START=?
+"
+  (eql 0 (search start str)))
+
+
 (defun entity->string (entity)
   "* Arguments
 - ENTITY :: An [[=entity=]].
      #+clisp
      (block nil
        (or (ignore-errors
-             (let ((exp (function-lambda-expression fname)))
+             (return (values (ext:arglist func) t)))
+           (ignore-errors
+             (let ((exp (function-lambda-expression func)))
                (and exp (return (values (second exp) t)))))
-           (ignore-errors
-             (return (values (ext:arglist fname) t)))
            (values nil nil))))))
 
 
   (write-out "~&#+TITLE: ~A" *document-title*)
   (write-out "~&#+AUTHOR: ~A" *document-author*)
   (write-out "~&#+EMAIL: ~A" *document-email*)
-  (write-out "~&#+LINK: hs ~A/%s" (if (eql 0 (search "http:" *hyperspec-root*))
+  (write-out "~&#+LINK: hs ~A/%s" (if (string-starts-with?
+                                       *hyperspec-root* "http:")
                                       *hyperspec-root*
                                       (format nil "file:~A" *hyperspec-root*)))
   (if *document-style-sheet*
                                                      safe match1)))))
                                       :simple-calls t))
          (cond
-           ((eql 0 (search ";;;" str))
+           ((string-starts-with? str ";;;")
             (unless src
               (setf src t)
               (format *out* "#+BEGIN_SRC lisp~%"))
     ((string-starts-with? docstr (format nil "###" #\return #\newline))
       (setf docstr (subseq docstr 3))))
   (if (and (stringp docstr)
-           (eql 0 (search (format nil "~C " *heading-char*) docstr)))
+           (string-starts-with? docstr (format nil "~C " *heading-char*)))
       (let ((*heading-level* (1+ *heading-level*)))
         (write-docstring docstr :levels (1+ *heading-level*)))
       ;; else
   "Writes a section describing the lambda list of the function or macro SYM."
   (writing-section ("Syntax")
     (format *out* "~&#+BEGIN_SRC lisp~%")
-    (format *out* "(~(~A~)~{ ~A~})~%"
-            sym
-            (mapcar (lambda (term)
-                      (if (ampersand-symbol? term)
-                          (string-downcase (string term))
-                          term))
-                    (function-lambda-list sym)))
+    (let* ((text (format
+                  nil "(~(~A~)~{ ~A~})~%"
+                  sym
+                  (mapcar (lambda (term)
+                            (if (ampersand-symbol? term)
+                                (string-downcase (string term))
+                                term))
+                          (function-lambda-list sym))))
+           (lines (word-wrap text :width *line-width*
+                             :respect-hyphens t)))
+      (dolist (line lines)
+        (write-out line)))
     (format *out* "#+END_SRC~%")))