我尝试将 Latex 命令或 UTF-8 符号插入缓冲区,但在
pcase
选择."No Match"
"bigodot"
grafm
在我看来,通过删除UTF-8
符号、在第一个空格之前获取第一个单词以及仅使用"bigodot"
与pcase
子句一起使用的字符串描述符来进行修改。
(defun imprint (selector kmstr &optional grapheme)
"Insert Latex Command or the equivalent UTF-8 grapheme."
(if (or (not grapheme) (equal selector "Command"))
(insert kmstr)
(insert grapheme)))
;;-------------------------------------
(defun bigops (grafm seltr)
"Binary Operations."
(interactive
(let ( (csel '("Symbol" "Command"))
(cseq '("bigodot ⨀" "bigoplus ⨁︁" "bigotimes ⨂︁")) )
(list
(completing-read "Grapheme: " cseq nil t "bigcap ⋂")
(completing-read "Selector: " csel nil t "Command")) ))
(setq grafm (car (split-string grafm)))
(message "Grafm: .%S." grafm)
(pcase grafm
("bigodot" (imprint seltr "\\bigodot" "⨀"))
("bigoplus︁" (imprint seltr "\\bigoplus" "⨁︁"))
("bigotimes︁" (imprint seltr "\\bigotimes" "⨂︁"))
(_ (message "%s" "No Match")) ))
在您作为匹配输入的字符串中的不同位置存在隐藏字符(代码点 65025),
pcase
这些字符会导致意外的匹配失败。你可以用以下方式将它们可视化