Function: claude-code-ide-mcp-xref-find-apropos

claude-code-ide-mcp-xref-find-apropos is a natively compiled function defined in claude-code-ide-emacs-tools.el.

Signature

(claude-code-ide-mcp-xref-find-apropos PATTERN FILE-PATH)

Documentation

Find symbols matching PATTERN across the entire project.

FILE-PATH specifies which file's buffer context to use for the search. This function uses the session context to operate in the correct project.

Source Code

;; Defined in /nix/store/yjvbhwl7p6zrbw9xlnni7y4hra8sa3pl-emacs-packages-deps/share/emacs/site-lisp/claude-code-ide-emacs-tools.el
(defun claude-code-ide-mcp-xref-find-apropos (pattern file-path)
  "Find symbols matching PATTERN across the entire project.
FILE-PATH specifies which file's buffer context to use for the search.
This function uses the session context to operate in the correct project."
  (if (not file-path)
      (error "file_path parameter is required. Please specify the file where you want to search for pattern %s" pattern)
    (claude-code-ide-mcp-server-with-session-context nil
      (let ((target-buffer (or (find-buffer-visiting file-path)
                               (find-file-noselect file-path)))
            (pattern-str (format "%s" pattern)))
        (with-current-buffer target-buffer
          (condition-case err
              (let ((backend (xref-find-backend)))
                (cond
                 ((not backend)
                  (format "No xref backend available for %s" file-path))
                 ;; Special handling for etags without tags table
                 ((and (eq backend 'etags)
                       (not (or (and (boundp 'tags-file-name) tags-file-name
                                     (file-exists-p tags-file-name))
                                (and (boundp 'tags-table-list) tags-table-list
                                     (cl-some #'file-exists-p tags-table-list)))))
                  (format "No tags table available for %s" file-path))
                 (t
                  (let ((xref-items (xref-backend-apropos backend pattern-str)))
                    (if xref-items
                        (mapcar (lambda (item)
                                  (let* ((location (xref-item-location item))
                                         (file (xref-location-group location))
                                         (marker (xref-location-marker location))
                                         (line (with-current-buffer (marker-buffer marker)
                                                 (save-excursion
                                                   (goto-char marker)
                                                   (line-number-at-pos))))
                                         (summary (xref-item-summary item)))
                                    (format "%s:%d: %s" file line summary)))
                                xref-items)
                      (format "No symbols found matching pattern '%s'" pattern-str))))))
            (error
             (format "Error searching for pattern '%s' in %s: %s"
                     pattern-str file-path (error-message-string err)))))))))