Function: claude-code-ide-mcp--get-buffer-project

claude-code-ide-mcp--get-buffer-project is a natively compiled function defined in claude-code-ide-mcp.el.

Signature

(claude-code-ide-mcp--get-buffer-project)

Documentation

Get the project directory for the current buffer.

Returns the expanded project root path if a project is found, otherwise returns nil. Uses buffer-local cache to avoid repeated project lookups.

Source Code

;; Defined in /nix/store/yjvbhwl7p6zrbw9xlnni7y4hra8sa3pl-emacs-packages-deps/share/emacs/site-lisp/claude-code-ide-mcp.el
  cli-pid)         ; PID of the connected CLI process

(defun claude-code-ide-mcp--get-buffer-project ()
  "Get the project directory for the current buffer.
Returns the expanded project root path if a project is found,
otherwise returns nil.
Uses buffer-local cache to avoid repeated project lookups."
  ;; Check if we have a valid cache
  (if claude-code-ide-mcp--buffer-cache-valid
      ;; Cache is valid, return cached value (even if nil)
      claude-code-ide-mcp--buffer-project-cache
    ;; Cache is invalid or doesn't exist, recalculate
    (let ((project-dir (when-let* ((project (project-current)))
                         (expand-file-name (project-root project)))))
      ;; Update cache
      (setq claude-code-ide-mcp--buffer-project-cache project-dir
            claude-code-ide-mcp--buffer-cache-valid t)
      project-dir)))