Skip to content

Commit

Permalink
[Compatibility] Prevent windmove-swap-state commands from running in …
Browse files Browse the repository at this point in the history
…treemacs.

Fixes #1126
  • Loading branch information
Alexander-Miller committed Oct 28, 2024
1 parent 63e80d4 commit 2f06684
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/elisp/treemacs-compatibility.el
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@

(add-hook 'eyebrowse-post-window-switch-hook #'treemacs--follow-after-eyebrowse-switch))

(with-eval-after-load 'windmove
(defun treemacs--windmove-swap-state-advice (original-fn &rest args)
"Advice for windmove-swap-state-* functions to ignore treemacs.
These commands do not seem to be compatible with side windows (and thus treemacs
in its default configuration), so this advice changes them to do nothing when
the `selected-window' is treemacs.
For all other cases ORIGINAL-FN is called with original ARGS."
(unless (and treemacs-display-in-side-window
(treemacs-is-treemacs-window-selected?))
(apply original-fn args)))

(with-no-warnings
(advice-add 'windmove-swap-states-in-direction
:around #'treemacs--windmove-swap-state-advice)))

(with-eval-after-load 'winum
(when (boundp 'winum-ignored-buffers-regexp)
(add-to-list 'winum-ignored-buffers-regexp (regexp-quote (format "%sScoped-Buffer-" treemacs--buffer-name-prefix)))))
Expand Down

0 comments on commit 2f06684

Please sign in to comment.