[Ecls-list] APROPOS issues, proposed enhancement

Matthew Mondor mm_lists at pulsar-zone.net
Wed Jun 27 09:29:11 UTC 2012

On Wed, 27 Jun 2012 02:23:07 -0400
Matthew Mondor <mm_lists at pulsar-zone.net> wrote:

> (defun apropos (string &optional package)

Alternate implementation:

(defun symbol-apropos-to-string (symbol)
  (let ((out '()))
    (macrolet ((push-string (string)
                 `(push ,string out)))
      (push-string (prin1-to-string symbol))
      (when (fboundp symbol)
        (if (special-operator-p symbol)
            (push-string "  Special form")
            (if (macro-function symbol)
                (push-string "  Macro")
                (push-string "  Function"))))
      (when (boundp symbol)
        (if (constantp symbol)
            (push-string "  Constant: ")
            (push-string "  has value: "))
        (push-string (prin1-to-string (symbol-value symbol))))
      (apply #'concatenate 'string (nreverse out)))))

(defun apropos (string &optional package)
  "Args: (string &optional (package nil))
Prints those symbols whose print-names contain STRING as substring.  If
PACKAGE is non-NIL, then only the specified PACKAGE is searched."
  (setq string (string string))
  (mapc #'(lambda (string)
            (princ string)
           with dupes = (sort (mapcar #'symbol-apropos-to-string
                                      (apropos-list string package))
           for prec = nil then item
           for item in dupes
           unless (and prec (string-equal prec item)) collect item))


More information about the ecl-devel mailing list