无论命令行还是Emacs中使用sdcv,都产生报错:g_mkdir failed: No such file or directory
在Emacs中则出现使用懒猫大佬的sdcv包时,sdcv-check正常但无法查询到单词释义。 使用melpa上的sdcv时则正常查询,通过gpt对比了下melpa上的sdcv和懒猫大佬的sdcv,排查到可能为sdcv-translate-result函数的问题。
利用gpt重定义该函数后正常查询,但报错信息也随之显示在Emacs的posframe中,同时怀疑是报错信息导致的原函数无法正常查询。请问各位道友们这个报错该如何解决?
懒猫sdcv原函数:
(defun sdcv-translate-result (word dictionary-list)
"Call sdcv to search WORD in DICTIONARY-LIST. Return filtered string of results."
(let* ((arguments (cons word (mapcan (lambda (d) (list "-u" d)) dictionary-list)))
(result (mapconcat
(lambda (result)
(let-alist result
(format "-->%s\n-->%s\n%s\n\n" .dict .word .definition)))
(apply #'sdcv-call-process arguments)
"")))
(if (string-empty-p result)
sdcv-fail-notify-string
result)))
Gpt修改:
(defun sdcv-translate-result (word dictionary-list)
"Call sdcv to search WORD in DICTIONARY-LIST. Return filtered string of results."
(let* ((arguments (cons word (mapcan (lambda (dict) (list "-u" dict)) dictionary-list)))
(cmd (concat "sdcv " (mapconcat #'identity arguments " "))))
;; 打印实际调用的命令
(message "Executing command: %s" cmd)
;; 执行命令
(let ((result (shell-command-to-string cmd)))
(if (string-empty-p result)
sdcv-fail-notify-string
result))))
另外MacOS上的stardict似乎无法使用,尝试了macport和下载release。