     ;; Push the current position, so we can go back.
     (xref-push-marker-stack)
 
-    (-let [(buf pos) (elisp-def--find-global sym (eq namespace 'function))]
+    (-let [(buf pos)
+           (cond
+            ((eq namespace 'library)
+             (elisp-def--find-feature sym))
+            ((eq namespace 'variable)
+             (elisp-def--find-variable sym))
+            ;; TODO: is treating quoted symbols as functions always
+            ;; correct?
+            ((memq namespace '(function quoted))
+             (elisp-def--find-function sym)))]
       (unless (and buf pos)
         ;; todo: mention if it's due to being a primitive
         (user-error "Could not find definition for %s %s"

                          (car edebug-info)
                        edebug-info)]
          (setq buf (marker-buffer marker))
          (setq pos (marker-position marker)))))
     ((not callable-p)
      (condition-case nil
          (-let [(sym-buf . sym-pos) (find-definition-noselect sym 'defvar)]
            (setq buf sym-buf)
            (setq pos sym-pos))
        (search-failed nil)
        ;; If your current Emacs instance doesn't match the source
        ;; code configured in find-function-C-source-directory, we can
        ;; get an error about not finding source. Try
        ;; `default-tab-width' against Emacs trunk.
        (error nil))))
    (list buf pos)))

(defun elisp-def--defined-in (sym)

    (overlay-put overlay 'face 'highlight)
    (run-with-timer 0.5 nil 'delete-overlay overlay)))

(defun elisp-def--find-library-name (library)
  "A wrapper around `find-library-name' that returns nil if PATH
has no library with that name.

This can happen when users have installed Emacs without its
source code: they have e.g. org.elc but no org.el."
  (condition-case nil
      (find-library-name library)
    (error nil)))

(defun elisp-def--primitive-p (sym callable-p)
