Method: (PERMUTATED-GLOBAL-INDEX BOOK)

Source

(defmethod permutated-global-index ((book book))
  (let ((entries '()))
    (dolist (part (all-code-parts book))
      (when (descriptor part)
        (let ((name-string (symbol-name (effective-name (name (descriptor part))))))
          (dolist (name-part (remove-duplicates
                              (remove-if (lambda (string)
                                           (string= "" string))
                                         (cl-ppcre:split "[^a-zA-Z]" name-string))
                              :test #'string=))
            (let* ((offset (search name-part name-string :test #'char=))
                   (prefix (subseq name-string 0 offset))
                   (suffix (subseq name-string offset)))
              (if (symbolp (name (descriptor part)))
                  (push (list prefix suffix part)
                        entries)
                  (push (list (format nil "(~A ~A"
                                      (first (name (descriptor part)))
                                      prefix)
                              (format nil "~A)" suffix)
                              part)
                        entries)))))))
    (sort entries #'string< :key #'second)))
Source Context