abo-abo / hydra

make Emacs bindings that stick around
1.84k stars 112 forks source link

hydra moves focus away when invoked from mini-buffer in emacsclient (emacs 28.0.50.148045-1 from aur emacs-git) #399

Closed FsharperOnTheRun closed 3 years ago

FsharperOnTheRun commented 3 years ago

When I try invoking a hydra from mini-buffer(eg. counsel-find-file, counsel-M-x) in previous emacs versions the focus would stay in the mini-buffer thus the hydra commands would work. Now in the current emacs from emacs-git aur package(manjaro linux) the focus jumps to another window(away from minibuffer).

Only affects emacsclient executable. Behaves normally on "emacs" executable. I'm having this problem when using org-capture OR daemon.

The stable(?) package (emacs v27.2-1) from extra does not have this issue. Both "emacs" and "emacsclient" behave as intended.

Repro (for manjaro linux)

Install: https://aur.archlinux.org/packages/emacs-git/

Use this init.el:

(require 'package)

(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)

;; From ???
(defun require-package (package &optional min-version no-refresh)
  "Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
  (if (package-installed-p package min-version)
      t
    (if (or (assoc package package-archive-contents) no-refresh)
        (package-install package)
      (progn
        (package-refresh-contents)
        (require-package package min-version t)))))

(require-package 'ivy)
(require-package 'counsel)
(require-package 'ivy-hydra)

(require 'ivy)
(require 'ivy-hydra)

(ivy-mode)

(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)

(global-set-key (kbd "<f9>") 'hydra-ivy/body)

Using directly from emacs executable(non server mode) works as expected

emacs

Using daemon and emacsclient focus:

emacs --daemon
emacsclient -c

Then opening hydra(f9) on counsel-find-file(C-x C-f) causes the focus to move to the main window away from mini-buffer.

FsharperOnTheRun commented 3 years ago

Looks like its working again.