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

emacs30 remote server出现epc error invalid-function #1123

Open
norris-young opened this issue Dec 7, 2024 · 3 comments
Open

emacs30 remote server出现epc error invalid-function #1123

norris-young opened this issue Dec 7, 2024 · 3 comments

Comments

@norris-young
Copy link
Contributor

最近想试下emacs30,然后发现有问题.
local用法正常,remote用法出现epc error invalid-function.
emacs -Q 用下面的方式配置就可以复现,同样的方式emacs29没有问题.

这个error我在lsp-bridge仓库里没搜到,不知道是不是python epc报的错?所以不知道咋定位了

另外我看emacs30好像有个news是内置了json support,没有--with-json了,不知道有没有影响.

编译版本:

GNU Emacs 30.0.92 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2024-12-07

编译选项:

"--with-native-compilation=aot --with-tree-sitter --without-compress-install 'CFLAGS=-march=native -O2'"
(add-to-list 'load-path "~/.emacs.d/packages/lsp-bridge/")
(add-to-list 'load-path "~/.emacs.d/packages/markdown-mode/")
(add-to-list 'load-path "~/.emacs.d/packages/yasnippet/")
(use-package lsp-bridge
  :custom
  (lsp-bridge-enable-log t)
  (lsp-bridge-enable-with-tramp t)
  (lsp-bridge-remote-start-automatically t)
  (lsp-bridge-remote-python-command "~/usr/local/bin/python3.10")
  (lsp-bridge-remote-python-file "~/.emacs.d/packages/lsp-bridge/lsp_bridge.py")
  (lsp-bridge-remote-log "~/.emacs.d/lbr_log.txt")
  (lsp-bridge-c-lsp-server 'ccls)
  )
(global-lsp-bridge-mode)
(lsp-bridge-mode)
--- [13:06:48.621723] Received from server 10.114.100.181 port 9998: {'command': 'eval-in-emacs', 'sexp': ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing")'], 'host': '10.114.100.181'}

--- [13:06:48.623409] Received from server 10.114.100.181 port 9998: {'command': 'eval-in-emacs', 'sexp': ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing 1/6591")'], 'host': '10.114.100.181'}
ERROR:epc:ReturnError([Symbol('invalid-function'), ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing")']])
ERROR:epc:ReturnError([Symbol('invalid-function'), ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing 1/6591")']])

--- [13:06:48.791255] Received from server 10.114.100.181 port 9998: {'command': 'eval-in-emacs', 'sexp': ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing 31/6591")'], 'host': '10.114.100.181'}

--- [13:06:48.798512] Received from server 10.114.100.181 port 9998: {'command': 'eval-in-emacs', 'sexp': ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing 32/6591")'], 'host': '10.114.100.181'}
ERROR:epc:ReturnError([Symbol('invalid-function'), ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing 31/6591")']])
ERROR:epc:ReturnError([Symbol('invalid-function'), ['(lsp-bridge--record-work-done-progress \'"[LSP-Bridge] indexing 32/6591")']])

@norris-young
Copy link
Contributor Author

确实和json的改动有关系,逻辑上在lsp_bridge_server的情况下,sexp好像套了2次[]

lsp-bridge/core/utils.py

Lines 190 to 208 in 520d253

def eval_in_emacs(method_name, *args):
global lsp_bridge_server
if test_interceptor: # for test purpose, record all eval_in_emacs calls
test_interceptor(method_name, args)
args = [sexpdata.Symbol(method_name)] + list(map(handle_arg_types, args)) # type: ignore
sexp = sexpdata.dumps(args)
logger.debug("Eval in Emacs: %s", sexp)
# Call eval-in-emacs elisp function.
if lsp_bridge_server and lsp_bridge_server.file_command_server:
lsp_bridge_server.file_command_server.send_message({
"command": "eval-in-emacs",
"sexp": [sexp]
})
else:
epc_client.call("eval-in-emacs", [sexp]) # type: ignore

lsp-bridge/lsp_bridge.py

Lines 609 to 612 in 520d253

def handle_lsp_message(self, message):
if message["command"] == "eval-in-emacs":
# Execute emacs command from remote server.
eval_sexp_in_emacs(message["sexp"])

lsp-bridge/core/utils.py

Lines 477 to 478 in 520d253

def eval_sexp_in_emacs(sexp):
epc_client.call("eval-in-emacs", [sexp])

我去掉1次[]改成下面这样,emacs30就正常了

def eval_sexp_in_emacs(sexp):
    epc_client.call("eval-in-emacs", sexp)

@manateelazycat
Copy link
Owner

大佬, 多测试一下, 如果几天没毛病, 欢迎发送补丁。

感谢大佬的详细调查。

@manateelazycat
Copy link
Owner

eval-in-emacs 是可以支持Elisp函数和函数参数的, 如果去掉 [] 会导致很多地方调用Elisp函数参数的地方都会出错。

我感觉更像是Emacs那边兼容性破坏的问题, 等正式版发布再看看吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants