kkp icon indicating copy to clipboard operation
kkp copied to clipboard

Not working with emacs daemon

Open DCsunset opened this issue 8 months ago • 7 comments

Hi,

Thanks for this great package. It works so far for me in emacs GUI and emacs -nw.

However, it doesn't work when used with emacs daemon and emacsclient -t. When I run (kkp-status), it simply returns KKP supported in this terminal. KKP not active in this terminal.

Is there a way to make it work with emacs daemon?

DCsunset avatar Apr 19 '25 14:04 DCsunset

I see a commit was added but in the meantime this worked in a pinch:

(use-package kkp                                                                                                               
    :ensure t                                                                                                                    
    :config                                                                                                                      
    (add-hook 'server-after-make-frame-hook                                                                                      
        (lambda ()                                                                                                         
            (kkp-enable-in-terminal)))                                                                                       
    (global-kkp-mode +1))

yaqubroli avatar Jun 03 '25 18:06 yaqubroli

Hi @DCsunset could you verify the patch in branch fix-issue-17-daemon-mode fixes your problem? I never had the problem with emacsclient so I wasn't able to reproduce your problem, but judging from the other command hooking into server-after-make-frame might be the correct solution.

benotn avatar Jun 04 '25 10:06 benotn

I regret to announce that I don't think my code snippet actually works. It seems to work when a new frame is created in addition to a running one (I tested it by creating a new tab in kitty), but not when, e.g., an ssh connection breaks and I have to reconnect. I'm not sure what the functional difference between these things is, though, or why it's not working.

yaqubroli avatar Jun 04 '25 15:06 yaqubroli

Hi @benotn, unfortunately it still doesn't work for me. kkp-status still shows the same message. I even tried running (kkp-enable-for-client-frame (selected-frame)) directly but it kkp-status still shows the same message.

Besides, there's a bug in the hook. If I run emacsclient -t the second time, the client crashes immediately because it calls kkp-enable-for-client-frame with 0 argument.

DCsunset avatar Jun 05 '25 00:06 DCsunset

I see a commit was added but in the meantime this worked in a pinch:

(use-package kkp                                                                                                               
    :ensure t                                                                                                                    
    :config                                                                                                                      
    (add-hook 'server-after-make-frame-hook                                                                                      
        (lambda ()                                                                                                         
            (kkp-enable-in-terminal)))                                                                                       
    (global-kkp-mode +1))

I tried your config and it doesn't work for me even I run emacscilent for the first time (I assume that should create a new frame)

DCsunset avatar Jun 05 '25 00:06 DCsunset

@DCsunset could you maybe describe your setup so I can reproduce the bug? which terminal application and version, and the steps to start the emacs-daemon and the emacs client, even if they might be very simple and straightforward.

benotn avatar Jun 06 '25 14:06 benotn

Sure. The setup is relatively simple:

  • Terminal: Ghostty 1.1.3
  • Start the daemon: emacs --daemon=test (test is the name of the socket to prevent conflict with other daemons)
  • Run the client: emacsclient -t -s test

DCsunset avatar Jun 06 '25 19:06 DCsunset