我在使用 pyim
这个包. 但是在使用过程中发现有两点不能满足自己的要求:
-
- 全程使用英文标点, 即就算是在中文字符后输入标点符号时也是用的英文标点.
-
- 候选词能够多于 9 个.
对于第一个问题, 我在配置中使用了:
;; 使用半角标点.
(setq pyim-punctuation-translate-p '(no yes auto))
这个是 pyim
文档中写明的, 我不明白它不起作用, 在我使用 emacs 时, 中文符号后输入的标点还是中文的标点符号.
对于第二个问题, 也是参考了文档, 在 ~/.emacs.d/pyim/rime
下添加文件 default.custom.yaml
.
patch:
"menu/page_size": 100
"speller/auto_select": false
"speller/auto_select_unique_candidate": false
也是完全没有作用. 同时还有疑问:
- 1.就是在
yaml
配置文件中, 鼠须管的 Github 文档写明有严格的格式要求. 鼠须管的例子里都是两格缩进
和单引号
的格式. 但是pyim
推荐的yaml
格式却是不一样的. 我不知道这样会不会有影响. -
- 在
yaml
文件中写了配置了, 怎么重新载入让其生效, 没有找到答案, 好像重启 emacs 没有效果,pyim
文档中也没有写明, 我知道鼠须管可以通过重新部署来生效. 但是在pyim
中没有这个东西.
- 在
最后是我抄自论坛高管 子龙山人
的配置, 除了以上我提到的痛点没有满足, 其他使用正常.
(defun hurricane-misc/post-init-pyim ()
(progn
(eval-and-compile
(if (fboundp 'window-inside-edges)
;; Emacs devel.
(defalias 'th-window-edges
'window-inside-edges)
;; Emacs 21.
(defalias 'th-window-edges
'window-edges)
))
(defun th-point-position ()
"Return the location of POINT as positioned on the selected frame.
Return a cons cell `(x . y)'."
(let* ((w (selected-window))
(f (selected-frame))
(edges (th-window-edges w))
(col (current-column))
(row (count-lines (window-start w) (point)))
(x (+ (car edges) col))
(y (+ (car (cdr edges)) row)))
(cons x y)))
(defun get-point-pixel-position ()
"Return the position of point in pixels within the frame."
(let ((point-pos (th-point-position)))
(th-get-pixel-position (car point-pos) (cdr point-pos))))
(defun th-get-pixel-position (x y)
"Return the pixel position of location X Y (1-based) within the frame."
(let ((old-mouse-pos (mouse-position)))
(set-mouse-position (selected-frame)
;; The fringe is the 0th column, so x is OK
x
(1- y))
(let ((point-x (car (cdr (mouse-pixel-position))))
(point-y (cdr (cdr (mouse-pixel-position)))))
;; On Linux with the Enlightenment window manager restoring the
;; mouse coordinates didn't work well, so for the time being it
;; is enabled for Windows only.
(when (eq window-system 'w32)
(set-mouse-position
(selected-frame)
(cadr old-mouse-pos)
(cddr old-mouse-pos)))
(cons point-x point-y))))
(defun display-current-input-method-title (arg1 &optional arg2 arg3)
"Display current input method name."
(when current-input-method-title
(set-mouse-position (selected-frame) (car (th-point-position)) (cdr (th-point-position)))
(x-show-tip current-input-method-title (selected-frame) nil 1 20 -30)))
(advice-add 'evil-insert :after 'display-current-input-method-title)
(when (functionp 'module-load)
(progn
(setq load-path (cons (file-truename "~/.spacemacs.d/") load-path))
(require 'liberime)
(require 'posframe)
(setq default-input-method "pyim")
(setq pyim-page-tooltip 'posframe)
(setq pyim-page-length 9)
(setq-default pyim-english-input-switch-functions
'(pyim-probe-dynamic-english
pyim-probe-program-mode
pyim-probe-org-structure-template))
;; 使用半角标点.
(setq pyim-punctuation-translate-p '(no yes auto))
(bind-key* "s-g" 'pyim-convert-code-at-point)
(liberime-start "/Library/Input Methods/Squirrel.app/Contents/SharedSupport" (file-truename "~/Library/Rime/"))
;; 使用这个来查看当前输入法有哪些.
;; (liberime-get-schema-list)
(liberime-select-schema "luna_pinyin_simp")
(setq pyim-default-scheme 'rime-quanpin)))))