Elilif / emacs-anki-helper

Manage your Anki cards in Emacs.
30 stars 2 forks source link

json readtable error: 37 #1

Closed Xiao-M0 closed 10 months ago

Xiao-M0 commented 10 months ago

你好,请问这个json readtable error: 37 是我没配置好吗? 系统是windows11 使用anki-helper-set-front-regionanki-helper-make-two-sided-card会报错 屏幕截图 2023-10-28 005431 屏幕截图 2023-10-28 005542 它会在D盘生成 image 文件中的内容 image

Elilif commented 10 months ago

抱歉,这是代码中忘了做跨平台的适配。由于我手头只有 Linux 的设备,所以可能无法一次性地解决您的问题,如果还有问题,麻烦继续提供详细的信息,谢谢。

Xiao-M0 commented 10 months ago

我测试了,问题并未被解决 这是它的错误信息 屏幕截图 2023-10-28 203414 并且现在不会在D:/tmp下生成文件了

Elilif commented 10 months ago

看样子是 anki-helper--curl-sentinel 中的 (json-read) 的问题,请麻烦您执行以下步骤

  1. 执行下述函数
(defun anki-helper--curl-sentinel (process _status)
  "Process sentinel for AnkiConnect curl requests.

PROCESS and _STATUS are process parameters."
  (let ((proc-buf (process-buffer process)))
    (when (eq (process-status process) 'exit)
      (with-current-buffer proc-buf
        (goto-char (point-min))
        (let* ((json-object-type 'plist)
               (json-array-type 'list)
               result)
          (setq anki-helper--response (buffer-string))
          (setq result (json-read))
          (if-let ((err (plist-get result :error)))
              (message (format "Error: %s" err))
            (let* ((result (plist-get result :result))
                   (info (alist-get process anki-helper--process-alist))
                   (command (plist-get info :command))
                   (orig-info (plist-get info :orig-info)))
              (funcall (alist-get command anki-helper-callback-alist anki-helper-default-callback)
                       orig-info result))))))
    (setf (alist-get process anki-helper--process-alist nil 'remove) nil)
    (kill-buffer proc-buf)))
  1. 执行 anki-helper-set-front-regionanki-helper-make-two-sided-card

  2. 请告诉我变量 anki-helper--response 中的值

Xiao-M0 commented 10 months ago

是这个吗? image

Elilif commented 10 months ago

@Xiao-M0 不是,按照上面的 3 步完成后, C-h v anki-helper--response RET,中间产生的错误无视即可

Xiao-M0 commented 10 months ago

很抱歉,我不太清楚第一步的函数是怎么执行的(是用debug-on-entry吗?) 我用debug-on-entry执行了anki-helper--curl-sentinel 后面按照上述的步骤操作后并未发现anki-helper--response这条命令 image

Elilif commented 10 months ago

很抱歉,我不太清楚第一步的函数是怎么执行的(是用debug-on-entry吗?)

抱歉,是我描述不清,具体操作是: 光标放在函数的末尾,然后 M-x eval-buffer RET

因为这个变量是第一步里设置的,所以需要你 eval 后才有

第二步就是正常通过 M-x 来使用,中间产生的报错忽视即可

Xiao-M0 commented 10 months ago

不是,按照上面的 3 步完成后, C-h v anki-helper--response RET,中间产生的错误无视即可

我完成了上面3步,但是C-h v中并没有发现anki-helper--response image

Elilif commented 10 months ago

@Xiao-M0 那看来我需要装个虚拟机来研究一下了,感谢您耐心帮忙调试

Elilif commented 10 months ago

刚装虚拟机试了一下,问题应该解决了。

Xiao-M0 commented 10 months ago

感谢,问题已经解决了👍