一本书如何快速收集生单词呢
回到 xah 主页找到了改进那么一点点的解决办法:
;; put this AFTER loading xah-fly-keys (define-key xah-fly-command-map (kbd “x”) 'command-name-x)
参考这个把需要的快捷键重新定义一遍,当然这是个变相的方法,两个包让哪个的在一定条件下优先还是不会
Dictionary-overlay所记录的knownwords.json让记录这一生的词汇量成为可能…
emacs 里打开阅读,可以利用 bigword 和 D-O 来辅助
收集生词的话,我问了下gpt:
(defun add-word-to-vocab-file ()
"将光标所在位置的英文单词添加到生词文本文件中,并弹出一个通知消息。"
(interactive)
(let ((word (substring-no-properties (thing-at-point 'word))))
(when (string-match-p "^[[:alpha:]]+$" word)
(with-temp-buffer
(insert word)
(newline)
(append-to-file (point-min) (point-max) "~/vocab.txt"))
(message (concat "单词 [ " word " ] 添加到生词本中。")))))
挺好用的~
遇到新问题(macos) 执行render无反应,执行jump to next unknow word的话
split-string: Wrong type argument: stringp, nil
websocket-bridge-app-log-buffer:
WebSocket Client [dictionary-overlay] connected, the server port is 59859
dictionary-overlay-sdcv-dictionary-path : null
Sdcv Dictionary load success.
dictionary-overlay-crow-engine : google
dictionary-overlay-translators : ["local","sdcv","darwin","web"]
dictionary-overlay-user-data-directory : ~/.emacs.d/dictionary-overlay-data/
dictionary-overlay-just-unknown-words : true
(dictionary-overlay-refresh-overlays)
看着像,当前buffer,没有生词。
谢谢,render完后最下面是报错和整篇文章的字符什么的,估计还是和哪个配置冲突了
没有排查到,另外快捷键定义争不过xah-fly-keys的问题我也没能找到办法
chatgpt说的挺有道理的样子,但是并不成功:
好的,我们可以再定义一个钩子函数`my-enable-xah-fly-keys`,用于在离开`dictionary-overlay`的覆盖区域时重新开启`xah-fly-keys`。并将它同时添加到`post-command-hook`钩子上:
(defun my-disable-xah-fly-keys ()
"Disable `xah-fly-keys' when entering `dictionary-overlay' mode."
(when (derived-mode-p 'dictionary-overlay-mode)
(xah-fly-keys 0)))
(defun my-enable-xah-fly-keys ()
"Enable `xah-fly-keys' when leaving `dictionary-overlay' mode."
(when (not (derived-mode-p 'dictionary-overlay-mode))
(xah-fly-keys 1)))
(add-hook 'post-command-hook #'my-disable-xah-fly-keys)
(add-hook 'post-command-hook #'my-enable-xah-fly-keys)
以上代码定义了两个钩子函数,其中my-disable-xah-fly-keys
与之前相同,用于在进入dictionary-overlay
的覆盖区域时关闭xah-fly-keys
。而my-enable-xah-fly-keys
则是用于在离开dictionary-overlay
的覆盖区域时重新开启xah-fly-keys
。我们将这两个钩子函数同时添加到post-command-hook
钩子上,这样可以实现在进入和离开dictionary-overlay
的覆盖区域时自动启用和禁用xah-fly-keys
的功能。
需要注意的是,这里并没有把钩子函数添加到专门处理dictionary-overlay
快捷键的dictionary-overlay-mode-hook
中,因为可能会有一些其他操作(比如移动光标或输入文本)也会让用户离开或进入dictionary-overlay
的覆盖区域。因此,我们改用了post-command-hook
钩子来实现这个功能,它在每个编辑命令之后运行,比较通用,而且也不会对其他操作(如打字)产生干扰。
讲得像模像样,但最后一句报错它解决不了
核心问题:
在emacs里,如何让一个模式的快捷键优先于另一个模式?
update: 由于解决不了上述问题,已转向使用meow
请问,配置里如果只保留sdcv
(setq dictionary-overlay-translators '("sdcv")
是否会造成有些词不在字典里,如CEO,deeper等,会被D-O的识别为生词但又没生成overlay (没中文),导致按 n 快捷键失败?(M-x dictionary-overlay-jump-next-unknown-word可以执行)
转到meow后,还遇到了一个问题但不确认是什么引起的,overlay上按c ,备选释义能显示,但向下到某一释义、回车,释义并没有变
快捷键只有在当前单词生成了释义的overlay时才会生效。
如果只使用 sdcv 本地词典。那么遇到词典里没有的生词,就不会生成释义overlay,那么当前位置快捷键是没有生效的。
感谢确认,明白了,看来要去找一个再大一些本地词典
今天我又想了下,再大的词典也会遇到未收词,那么本地的话,如果不生成overlay就不能按 n 往前跳。能否这样解决,没查到的直接生成一个 “(?)" 这样的overlay,既可以区分出生词(而不是目前和普通正文一样),又不会使快捷键失效
为啥只保留一个 sdcv? 用 web 作为保底,没有多少可能遇到不存在的吧
因为有没有网络的时候 (另外我加回darwin web试了下,类似dorm,forgotten, uncareful 这样的词不知为何也是没有解释但又是跳转对象)
现在大家一般都是大屏,有没有坛友试过,emac左右分屏,左边用D-O渲染,右边用EAF运行goldendict查词?
- 有没有办法让没查到的词生成一个空的overlay
比如 apple() 这样,目的是为了用快捷键 n 跳到下一个生词,目前没生成就会输入 n
- 这两天遇到了这个错误 webtranlate error 按提示运行 log 后
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)>
重装了google translate 没能解决
你好ginqi7大侠,安装dictionary-overlay遇到了麻烦,能帮帮吗?
archlinux环境,emacs 30,requirements.txt里面的几个都装了。
执行dictionary-overlay-start显示已经启动。 然后我打开了一个epub,哈利波特与魔法石英文版,然后执行dictionary-overlay-render-buffer,没有出现生词的中文标注。
运行一下 websocket-bridge-app-log-buffer
看看日志试试。
WebSocket Client [dictionary-overlay] connected, the server port is 39883
dictionary-overlay-sdcv-dictionary-path : null
Sdcv Dictionary load success.
dictionary-overlay-crow-engine : google
dictionary-overlay-translators : ["local","sdcv","darwin","web"]
dictionary-overlay-user-data-directory : ~/.emacs.d/dictionary-overlay-data/
dictionary-overlay-just-unknown-words : true
(dictionary-overlay-refresh-overlays)
看起来正常启动了。你需要运行 dictionary-overlay-mark-word-known
标记生词,然后会在 buffer 里展示你所有标记过的生词。
或者你把 dictionary-overlay-just-unknown-words 设置为 nil, 那么它会是透析模式,那么它会翻译 buffer 里所有的单词,直到你把某个单词标记为已知 dictionary-overlay-mark-word-known 。
爱你么么哒亲亲😙