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

0.16.0 causes jumping to another application when Emacs child frame closes #776

Open
nohzafk opened this issue Nov 29, 2024 · 4 comments
Open
Labels
bug Something isn't working as expected

Comments

@nohzafk
Copy link

nohzafk commented Nov 29, 2024

I encounter this problem when I upgrade to the latest aerospace 0.16.0, I confirmed that previous 0.15.2 version doesn't cause this issue.

This issue is very like #325 , the problem specifically involves Emacs child frames, which are temporary windows created for UI elements like completion menus

Behavior:

  • Emacs auto completion library creates child frame, and when it finished, Emacs deletes its child frame.
  • At this point, Aerospace loses track of which window should have focus
  • This causes incorrectly jumping focus to another application, making Emacs auto completion completely unusable.
  • Disable Aerospace, this issue disappears.

These child frame is often undecorated

(make-frame
 `((name . ,frame-name)   
   (parent-frame . ,parent)
   (undecorated . t)    
   ...))

My attempts to force focus or modify frame parameters didn't work, suggesting this is more of an Aerospace level issue

@nohzafk nohzafk added the bug Something isn't working as expected label Nov 29, 2024
@nikitabobko
Copy link
Owner

nikitabobko commented Nov 29, 2024

I have never user Emacs, which makes it hard for me to reproduce the issue.

Can you please produce elaborate steps to reproduce that would be clear for people who has never used Emacs in default Emacs configuration?

Thanks

@nohzafk
Copy link
Author

nohzafk commented Nov 30, 2024

This is a complex secnario, I've done my best to create steps to reproduce the issue.

I appreciate your effort to invest this issue. I can't bear it if I can't use Emacs.

Everything will be contained in the test directory, after testing you can just delete the test directory.

Screen Recording 2024-11-30 at 01 45 15

The screen record shows that while typing the completion menu shows up, press TAB to trigger the completion, and then the focused window jump to another application. Rollback to previous version of aerospace with the same setup, it won't hapen.

I have tested following scripts

Steps to reproduce the issue

# create the testing directory
mkdir emacs-q
cd emacs-q

# install emacs using homebrew
brew tap d12frosted/emacs-plus
brew install emacs-plus@29 --with-no-frame-refocus

# create a python virtual environment with dependences for lsp-bridge
cat > lsp-bridge.txt << EOF
epc==0.0.5
orjson==3.9.10
sexpdata==1.0.0
setuptools==69.0.2
rapidfuzz==3.6.1
paramiko==3.4.0
six==1.16.0
watchdog==5.0.3
EOF

python3 -m venv venv && venv/bin/pip install -r lsp-bridge.txt

# setup emacs

cat > init.el <<EOF
;; Disable startup screen
(setq inhibit-startup-screen t)

;; Set initial buffer to *scratch*
(setq initial-buffer-choice t)

;; Bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; Configure straight to use use-package
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

;; Set *scratch* buffer to emacs-lisp-mode
(setq initial-major-mode 'emacs-lisp-mode)

;; Install required dependencies
(use-package markdown-mode
  :straight t)

(use-package yasnippet
  :straight t
  :config
  (yas-global-mode 1))

;; Install and configure lsp-bridge
(use-package lsp-bridge
  :straight '(lsp-bridge :type git
                        :host github
                        :repo "manateelazycat/lsp-bridge"
                        :files ("*.el" "*.py" "acm" "core" "langserver" "multiserver" "resources"))
  :init
  (setq lsp-bridge-python-command (expand-file-name "venv/bin/python" default-directory)))

;; Ensure *scratch* is the initial buffer
(setq inhibit-startup-buffer-menu t)

;; Add startup message to scratch buffer
(add-hook 'emacs-startup-hook
          (lambda ()
            (with-current-buffer "*scratch*"
              (lsp-bridge-mode)
              (goto-char (point-max))
              (insert "\n;; Debug: init.el loaded successfully at " (current-time-string) "\n")
              (insert ";; LSP-Bridge status: " (if (bound-and-true-p lsp-bridge-mode) "enabled" "disabled") "\n\n")
              (insert ";; With Aerospace enabled, try to type a long symbol for example \n")
              (insert "emacs-lisp-compilation-mode-syntax-table\n\n")
              (insert ";; while typing the completion menu will showup and press TAB to trigger the completion \n")
              (insert ";;observe that the focused window will jump to the next application window after pressing TAB.\n")
              (insert ";;This will also happen when you are typing fast.\n")
              (insert "\n")
              (goto-char (point-max)))))
EOF

start emacs to test

With aerospace 0.16.0 enabled, start the emacs.

Emacs will download all the dependecies to the testing directory, if you see warning on Emacs, just ignore it.

emacs --init-directory=. -Q -l init.el

Steps to cleanup after testing

brew uninstall emacs-plus@29
brew untap d12frosted/emacs-plus

remove the testing directory

@goncalvesnelson
Copy link

Hi!
I have the same issue as @nohzafk on emacs-plus@30, after the auto-completion frame closes, the focus changes to another window on the same workspace.

@nohzafk
Copy link
Author

nohzafk commented Dec 9, 2024

I cloud not figure out the issue, right now I just use aerospace 0.15.2, and it works fine 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants