这是一段模式匹配,想通过键入字典名字的方式让来设置dict变量,但是每次模式匹配以后dict-name变量一直没有正确匹配,大佬门知道怎么修改吗
(defun stardict-choose-dict ()
(interactive)
(let ((dicts '("本草纲目" "郎道英汉5" "高级汉语大辞典" "古汉语常用辞典" "古汉语常用辞典" "汉语成语辞典" "计算机词汇" "湘雅医学辞典")) chosen-option)
(setq chosen-option (completing-read "Select a dict: " dicts))
(cl-case chosen-option
("本草纲目" (setq dict-name "bcgm"))
("郎道英汉5" (setq dict-name "langdao-ec-gb"))
("高级汉语大辞典" (setq dict-name "gaojihanyudacidian_fix"))
("古汉语常用辞典" (setq dict-name "ghycyzzd"))
("汉语成语辞典" (setq dict-name "hanyuchengyucidian_fix"))
("计算机词汇" (setq dict-name "kdic-computer-gb"))
("湘雅医学辞典" (setq dict-name"xiangya-medical"))
)
)
(setq dict (stardict-open (format "~/.emacs.d/dict/%s" dict-name) dict-name)))
把 cl-case
改成 pcase
,前者不能用来匹配字符串
1 个赞