关于 pyim 的配置不起作用的问题

我在使用 pyim 这个包. 但是在使用过程中发现有两点不能满足自己的要求:

    1. 全程使用英文标点, 即就算是在中文字符后输入标点符号时也是用的英文标点.
    1. 候选词能够多于 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 格式却是不一样的. 我不知道这样会不会有影响.
    1. 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)))))

第一点不知道,第2点你设置一下pyim-page-length试试

好像用rime输入的时候,标点符号不是由pyim决定的,而是取决于.emacs.d/pyim/rime下的yaml文件的配置。

liberime-start 的第二个参数( user_data_dir)用于指定 rime 的配置文件目录,而你配置里写的是 ~/Library/Rime/,当前读取的是外置输入法的 default.custom.yaml,所以才没有生效。

谢谢, 将配置路径改到 yaml 文件所在位置后, 备选词可以变多了.

请问你有相关的 yaml 文件可以让我参考下吗. 我不知道如何配置.

我尝试了下三楼的办法, 可以变多备选词了.谢谢.

好像是在输入法的xxx.schema.yaml文件中找switches节,找关于full_shape的一个东西,不过不是很确定,我只是前段时间pyim双拼有bug的时候试过一下pyim+rime,当时瞎调了很多地方,记不清楚了。