-
Notifications
You must be signed in to change notification settings - Fork 2
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
Initial RPC/hooks implementation #9
Conversation
I wonder why two sockets are necessary? One should be enough. emacs_ipc.pyfrom PyQt6.QtNetwork import QLocalSocket
from PyQt6.QtCore import QTextStream, QByteArray, pyqtSlot
from qutebrowser.api import message, cmdutils
from qutebrowser.keyinput import modeman
from qutebrowser.misc import objects
from qutebrowser.misc.ipc import IPCServer
from qutebrowser.utils import objreg
class EmacsIPCServer(IPCServer):
def __init__(self, socketname):
super().__init__(socketname)
objreg.register(name = "emacs-ipc-server",
obj = self,
update = True)
self.listen()
@pyqtSlot()
def on_timeout(self):
# this needs to be adjusted
print("Ignoring timeout")
return
def send_cmd(self, cmd):
socket = self._get_socket()
if socket and socket.isOpen():
socket.write(QByteArray(cmd.encode("utf-8")))
socket.flush()
def init():
server = EmacsIPCServer("/tmp/emacs-ipc")
init()
@cmdutils.register()
def test(text: str) -> None:
"""Test launcher"""
server = objreg.get("emacs-ipc-server")
server.send_cmd(text) Emacs part(make-network-process
:name "qutebrowser-ipc"
:buffer (generate-new-buffer "qute-ipc")
:family 'local
:filter (lambda (proc string) (with-local-quit (eval (read string))))
:service "/tmp/emacs-ipc"
:nowait nil
:sentinel (lambda (proc event)
(when (string= event "connection broken by remote peer\n")
(delete-process proc)))) Start qutebrowser, |
btw, it doesn't seem to fix the "Buffer is read-only issue" 😢 |
Using your But this seems to indicate that there is something else causing this than the current theory. I'm leaning towards some weird interaction with the buffer focus when focusing and unfocusing the minibuffer. What it seems like to me is that the underlying emacs buffer of the EXWM window is given focus instead of the X11 window. But it is very weird that it doesn't happen for other minibuffer commands, and that it doesn't happen when manually opening the launcher through
Apparently that is indeed enough. I was thinking that there needed to be a server process in emacs for the communication inititated by qutebrowser, but seems like it doesn't matter which end is the server and which is the client. |
I tried various different commands to see what causes the issue and what doesn't. Works:
Fails:
Seems the common denominator is accepting an entry through EDIT: Interestingly, |
Reproducing now via alacritty as well! This seems to be a bug in EXWM, that happens whenever an X11 window has focus, and the minibuffer is focused without being called from an emacs keybinding. Simply open an alacritty terminal (or I would assume any X11 terminal) and run EDIT: Just verified it in xterm as well. |
Merging this as is, to enable working on other features depending on this. These changes should not affect any existing features. |
Work in progress! Current status is very experimental, expect breakage.
Current status: