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

Error if window is strongly dedicated #113

Open
ferrine opened this issue Jan 12, 2025 · 2 comments
Open

Error if window is strongly dedicated #113

ferrine opened this issue Jan 12, 2025 · 2 comments

Comments

@ferrine
Copy link

ferrine commented Jan 12, 2025

exwm/exwm-workspace.el

Lines 1036 to 1040 in 26d24e5

(if window
(set-frame-parameter exwm--frame
'exwm-selected-window window)
(set-window-buffer (frame-selected-window exwm--frame)
buffer-or-name)))

Hi, using this function I noticed that if the selected window is nil, an error can happen for

(set-window-buffer (frame-selected-window exwm--frame)
                                     buffer-or-name)

It happens when returns a window that is strongly dedicated.

as a workaround I had to replace this piece of code with

(let ((selected-window (frame-selected-window exwm--frame)))
   (if (window-dedicated-p selected-window)
       (let ((new-window (split-window selected-window nil 'down)))
         (set-window-buffer new-window buffer-or-name))
     (set-window-buffer selected-window buffer-or-name)))

The solution proposed is weird and I do not like it. The behavior (window placement) is different from the case you first switch to the desired workspace and then switch to buffer.

Background

Initially I was attempting to write similar function but with non-EXWM buffers filtered out. I wanted to easily navigate across opened applications.

@ferrine
Copy link
Author

ferrine commented Jan 13, 2025

I ended up writing this function

(defun my/navigate-to-exwm-buffer ()
    "Navigate to EXWM buffer whereever it is."
    (interactive)
    (let* ((buffers-alist exwm--id-buffer-alist)
           (buffer-names
            (mapcar (lambda (pair)
                      (cons (string-trim-left (buffer-name (cdr pair))) (cdr pair)))
                    buffers-alist))
           (selected-buffer-name
            (completing-read "Select Application: " buffer-names nil t))
           (selected-buffer
            (cdr (assoc selected-buffer-name buffer-names))))
      (with-current-buffer selected-buffer
        (exwm-workspace-switch exwm--frame)
        (if (not exwm--floating-frame)
            (switch-to-buffer selected-buffer)
          ;; Select the floating frame.
          (select-frame-set-input-focus exwm--floating-frame)
          (select-window (frame-root-window exwm--floating-frame))))))
  • It ignores spaces in buffer names
  • It also has workspace switching that does not check for too much

I'm not optimising it too much, but at least do I miss anything critical?

@Stebalien
Copy link
Contributor

It looks like the real issue is that we're "stealing" an EXWM buffer from a window where it's "dedicated". The only real feasible solution I can think of is to automatically undedicate and/or close the window we stole the buffer from.

But there are some snags:

  1. Ideally we'd allow the same EXWM buffer to be dedicated to different windows in different tabs/workspaces.
  2. When an EXWM buffer is dedicated to a Emacs window on the current workspace, I'd rather switch to that buffer then move/undedicate it. But I'm not sure how to make that work reliably when users can switch buffers with, e.g., switch-to-buffer. I'd rather not add a bunch of advice.

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

2 participants