Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve elpy-shell-echo-output 'when-shell-not-visible for multiple frames #2050

Open
dafxy opened this issue Aug 24, 2024 · 0 comments
Open

Comments

@dafxy
Copy link

dafxy commented Aug 24, 2024

Here is how to make it work with multiple frames.

(defmacro elpy-shell--with-maybe-echo-output (body)
  "Run BODY and grab shell output according to `elpy-shell-echo-output'.

This modifies the original function to check if shell is visible in other frames

"
  `(cl-letf (((symbol-function 'python-shell-send-file)
              (if elpy-shell-echo-output
                  (symbol-function 'elpy-shell-send-file)
                (symbol-function 'python-shell-send-file))))
     (let* ((process (elpy-shell--ensure-shell-running))
            (process-buf (process-buffer process))
            ;; Check if the buffer is visible in any window of any frame
            (shell-visible (or elpy-shell-display-buffer-after-send
                               (get-buffer-window-list process-buf nil t)))) ; Checks all frames
       (with-current-buffer process-buf
         (setq-local elpy-shell--capture-output
                     (and elpy-shell-echo-output
                          (or (not (eq elpy-shell-echo-output 'when-shell-not-visible))
                              (not (null shell-visible)))))) ; Properly check for visibility
       (progn ,body))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant