xahlee / xah-fly-keys

the most efficient keybinding for emacs
http://xahlee.info/emacs/misc/xah-fly-keys.html
484 stars 83 forks source link

Setting (xah-fly-keys 1) doesn't work in --daemon mode in startup #103

Closed wofwofwof closed 3 years ago

wofwofwof commented 4 years ago

When I use my config with emacs everything works fine, when I use it with emac --daemon mode the xah-fly-key mode is activated but ignored until I

After this everything works fine. I use version xah-fly-keys-20200707.1310.

At the moment I have no clue whats the reason for this behaviour. On xah-fly-keys-20190223.716 that configuration works. Can somebody just try if its my configuration or a general problem with xah-fly-mode?

Thanks for that fantastic mode

cheers

alex

wofwofwof commented 4 years ago

ok, found my problem, just cleaned up my old dependencies in the packages and now iit works. No problem with xah-fly-mode. Sorry for the noise

wofwofwof commented 4 years ago

lol, reopened again

its still open after the cleanup, but I've got confused because the keys with C- mapping are working. And there are lots of triggers that get one back into the fly-spell mode, some examples are listed:

is it possible that some part of xah now needs an interactive environment and that on daemon mode that doesen't work?

TRSx80 commented 4 years ago

It sound to me like possible config conflict? What do you think?

Have you tried to reproduce the problem with a minimal config (i.e., emacs --no-init-file or -q)?

wofwofwof commented 4 years ago

Hello TRSx80,

thanks for your support. I've tried to make a minimal config where the problem is still there. This is my .emacs.d/init.el:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(require 'xah-fly-keys)
(xah-fly-keys-set-layout "qwertz")
(xah-fly-keys 1)

Thank you very much

alex

ghost commented 3 years ago

I don't know why it happens but this fixed it for me.

Taken from: https://github.com/daviwil/emacs-from-scratch/blob/master/show-notes/Emacs-Tips-08.org#configuring-the-ui-for-new-frames

(defun my/server-fix-up()
  "Make sure 'xah-fly-keys' is starting in command-mode.

https://github.com/xahlee/xah-fly-keys/issues/103
https://github.com/daviwil/emacs-from-scratch/blob/master/show-notes/Emacs-Tips-08.org#configuring-the-ui-for-new-frames"
  (xah-fly-keys-set-layout "dvorak")
  (xah-fly-keys t))

(if (daemonp)
    (add-hook 'server-after-make-frame-hook 'my/server-fix-up))

Edit: If you define keys under 'use-package' (maybe also just 'define-key') Take out: (xah-fly-keys-set-layout "dvorak").

wofwofwof commented 3 years ago

CelestialNebula, thanks a lot, that fixed the problem for me, too.

xahlee commented 3 years ago

thanks guys. thanks @CelestialNebula . i added that to customization page http://ergoemacs.org/misc/xah-fly-keys_customization.html

eexexiexit commented 1 year ago

If i use this fix, in the daemon mode, some calendar bindings seem to have been damaged (in insert mode), for instance (after M-x calendar) and switch to insert-mode:

i d -> diary-insert-entry i b -> diary-insert-block-entry

Does anybody has an idea of what is going on here?

ghost commented 1 year ago

What do you mean damaged? Those appear to be the default keys.

akashpal-21 commented 3 months ago

Can we reopen this issue? It is still a major issue - the mode refuses to work, its very unituitive. Any clue as to what is causing this?

;; Use xah-fly-keys a modal keybinding scheme
(require 'xah-fly-keys)
(xah-fly-keys-set-layout "qwerty")
(if (daemonp)
    (add-hook 'server-after-make-frame-hook #'(lambda ()
                        (unless xah-fly-keys
                          (xah-fly-keys 1))))
  (xah-fly-keys 1))

I have to resort to this.

akashpal-21 commented 3 months ago
(when (daemonp)
  (add-hook 'server-after-make-frame-hook #'(lambda ()
                          (when (and xah-fly-keys
                             (not xah-fly-insert-state-p))
                        (set-transient-map xah-fly-command-map (lambda () t))))))

set-transient-map is failing when set during init. Minimal solution that works.

xahlee commented 3 months ago

maybe open a new issue and reference to this one. i'll look into. meanwhile, i don't recommend running daemon. it creates a lot complications. is confusing in concept, also a lot technical complexities. also more complexities if you are on windows.

instead, setup ur emacs so that u can open multiple instances without emacs ever bugging u to ask questions during launch (e.g. last emacs crashed). so you can always work in mulitple intances in parallel, launch new anytime. if u code emacs, u have to resart emacs often, sometimes multiple times a day, anyway.

akashpal-21 commented 3 months ago

maybe open a new issue and reference to this one.

Will do, thanks. Need to collect my findings more concisely; daemon introduces two regressions - one this and the other setting the cursor colour/shape.

meanwhile, i don't recommend running daemon.

You're correct in this - I have found many bugs while running daemon - for ex.; kill-emacs-hook has some quirks - I am sure there are other such quirks throughout.

I can set up my init such that the difference in opening frame times is less than half a second daemon or not daemon; but I have chosen to not do this - despite having to annoyingly restart the daemon over and over some days to reset temporary code tests - because its quite fast -- the latency in opening subsequent files is substantial even for 0.3~0.4 seconds. The bottleneck is elisp's GC threshold - when GC runs collinearly, execution time is trivially doubled. The annoyances of daemon has not reached the threshold for me to consider refactoring my init and tweak GC, mostly I have learnt to live around it.

But I agree with you, running daemon is not without its share of problems.