 (defun elisp-def ()
   "Go to the definition of the symbol at point."
   (interactive)
-  (-let* ((sym (symbol-at-point))
-          (sym-name (symbol-name sym))
-          (namespaces (elisp-def--namespaces sym))
-          (namespace nil))
-    (if (> (length namespaces) 1)
-        ;; User chooses.
-        (let* ((formatted-namespaces
-                (elisp-def--join-and
-                 (--map (format "a %s" it) namespaces)))
-               (prompt (format "%s is %s, choose: "
-                               sym-name
-                               formatted-namespaces)))
-          (setq namespace
-                (intern
-                 (completing-read prompt namespaces nil t))))
-
-      ;; This symbol is only bound in one namespace.
-      (setq namespace (car namespaces)))
+  (let* ((sym (symbol-at-point))
+         (sym-name (symbol-name sym))
+         ;; Try to find the namespace by macro expanding the code.
+         (namespace (elisp-def--namespace-at-point)))
+    ;; If we couldn't identify a function or variable, see which
+    ;; namespaces this symbol is bound in.
+    (when (eq namespace 'quoted)
+      (-let [namespaces (elisp-def--defined-in sym)]
+        ;; If the symbol is only bound in one namespace, use that.
+        (if (= (length namespaces) 1)
+            (setq namespace (car namespaces))
+          ;; Otherwise, our static analysis has failed, so just ask
+          ;; the user.
+          (let* ((formatted-namespaces
+                  (elisp-def--join-and
+                   (--map (format "a %s" it) namespaces)))
+                 (prompt (format "%s is %s, choose: "
+                                 sym-name
+                                 formatted-namespaces)))
+            (setq namespace
+                  (intern
+                   (completing-read prompt namespaces nil t)))))))
 
     (-let [(buf pos) (elisp-def--find-global sym (eq namespace 'function))]
       (unless (and buf pos)

(require 's)
(require 'f)
(require 'find-func)

(defun elisp-def--flash-region (start end)
  "Temporarily highlight region from START to END."

        (error nil))))
    (list buf pos)))

(defun elisp-def--defined-in (sym)
  "All the namespaces that SYM is globally defined in.
Returns a list '(function variable).

