Function: claude-code-ide-mcp-server-with-session-context
claude-code-ide-mcp-server-with-session-context is a macro defined in
claude-code-ide-mcp-server.el.
Signature
(claude-code-ide-mcp-server-with-session-context SESSION-ID &rest BODY)
Documentation
Execute BODY with the context of SESSION-ID.
Sets the default-directory to the session's project directory and makes the session's buffer current if it exists. Prefers the last active buffer over the registered buffer.
Source Code
;; Defined in /nix/store/yjvbhwl7p6zrbw9xlnni7y4hra8sa3pl-emacs-packages-deps/share/emacs/site-lisp/claude-code-ide-mcp-server.el
(defmacro claude-code-ide-mcp-server-with-session-context (session-id &rest body)
"Execute BODY with the context of SESSION-ID.
Sets the default-directory to the session's project directory
and makes the session's buffer current if it exists.
Prefers the last active buffer over the registered buffer."
(declare (indent 1))
`(let* ((context (claude-code-ide-mcp-server-get-session-context ,session-id))
(project-dir (plist-get context :project-dir))
(last-active-buffer (plist-get context :last-active-buffer))
(registered-buffer (plist-get context :buffer))
;; Prefer last active buffer, fall back to registered buffer
(buffer (or (and last-active-buffer
(buffer-live-p last-active-buffer)
last-active-buffer)
(and registered-buffer
(buffer-live-p registered-buffer)
registered-buffer))))
(if (not context)
(error "No session context found for session %s" ,session-id)
(let ((default-directory (or project-dir default-directory)))
(if buffer
(with-current-buffer buffer
,@body)
,@body)))))