windows 安装

手动复制相关文件到 emacs 安装目录 参考:https://github.com/merrickluo/liberime/releases 查看压缩包内部 Readme 解说

个人词库

激活问题

前提条件

  • liberime-build
  • liberime-deploy

上述命令正常

激活:

  • liberime-sync

注意:即使配置正常,在没有 sync 前,也检测不到个人词库

多实例问题:

  • 相互排斥:只有一个 emacs 实例,可以调用 liberime

切换 scheme(方案,全拼)

doom emacs 配置

packages.el

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
(package! pyim :pin "f48c3edee78ba5f020bcb42830db99a14761f176")
(package! fcitx :pin "12dc2638ddd15c8f6cfaecb20e1f428ab2bb5624")
(package! ace-pinyin :pin "8b2e9335b02486730ea4ceee790130cc5328f9ea")
(package! pangu-spacing :pin "f92898949ba3bf991fd229416f3bbb54e9c6c223")

(package! pyim-basedict)
(if (eq system-type 'windows-nt)
    nil ;; Windows 上,手动 copy, 不需要安装
  (package! liberime
    :recipe (:local-repo "~/programs/liberime")))

(package! valign)

config.el

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
(use-package! pyim
  :after-call after-find-file pre-command-hook
  :init
  (setq pyim-dcache-directory (concat doom-cache-dir "pyim/"))
  ;; 开启拼音搜索功能
  ;; :hook (doom-first-buffer . pyim-isearch-mode)
  :config
  (setq default-input-method "pyim")

  ;; 我使用全拼
  (setq pyim-default-scheme 'quanpin)

  ;; 设置 pyim 探针设置,这是 pyim 高级功能设置,可以实现 *无痛* 中英文切换 :-)
  ;; 我自己使用的中英文动态切换规则是:
  ;; 1. 光标只有在注释里面时,才可以输入中文。
  ;; 2. 光标前是汉字字符时,才能输入中文。
  ;; 3. 使用 M-j 快捷键,强制将光标前的拼音字符串转换为中文。
  (setq-default pyim-english-input-switch-functions
                '(pyim-probe-dynamic-english
                  pyim-probe-isearch-mode
                  pyim-probe-program-mode
                  pyim-probe-org-structure-template))

  (setq-default pyim-punctuation-half-width-functions
                '(pyim-probe-punctuation-line-beginning
                  pyim-probe-punctuation-after-punctuation))

  ;; 使用 pupup-el 来绘制选词框, 如果用 emacs26, 建议设置
  ;; 为 'posframe, 速度很快并且菜单不会变形,不过需要用户
  ;; 手动安装 posframe 包。
  (setq pyim-page-tooltip 'posframe)

  ;; 选词框显示5个候选词
  (setq pyim-page-length 5)

  (setq pyim-dicts
        '((:name "myown" :file "~/home/backup.d/pinyin_dict/personal_dict.txt")
          (:name "dict_someclassmate" :file "~/home/backup.d/pinyin_dict/pyim-bigdict.pyim")
          (:name "all_in_one" :file "~/home/backup.d/pinyin_dict/profession_all_in_one_dict.txt")))
  ;; 模糊音
  (setq pyim-fuzzy-pinyin-alist
        '(("in" "ing")
          ("s" "sh")
          ("z" "zh")
          ("c" "ch")))

  ;; 翻页键
  (define-key pyim-mode-map "." 'pyim-page-next-page)
  (define-key pyim-mode-map "," 'pyim-page-previous-page)

  ;; 选择第二个快捷键 ";"
  (define-key pyim-mode-map ";"
    (lambda ()
      (interactive)
      (pyim-page-select-word-by-number 2)))

  (define-minor-mode my-pyim-forward-mode
    "Minor mode to keymap `M-f' to `pyim-forward-word'"
    :init-value nil
    )

  (defvar my-pyim-forward-mode-map (make-keymap))
  (define-key my-pyim-forward-mode-map (kbd "M-f") 'pyim-forward-word)
  (define-key my-pyim-forward-mode-map (kbd "M-b") 'pyim-backward-word)

  ;; activate pyim forword for specific modes
  ;; (add-hook 'org-mode-hook 'my-pyim-forward-mode)

  :bind
  (("M-j" . pyim-convert-string-at-point) ;与 pyim-probe-dynamic-english 配合
   ("C-;" . pyim-delete-word-from-personal-buffer))
  
  :config
  (featurep! +rime
             (require 'liberime nil t)))

(use-package! pyim-basedict
  :after-call after-find-file pre-command-hook
  :defer t
  ;; :demand t
  :requires pyim
  ;; 激活 basedict 拼音词库,五笔用户请继续阅读 README
  :config (pyim-basedict-enable))

;; ----------------------------------------------------------------
(use-package! liberime
  :when (featurep! +rime)
  :after pyim
  :init
  (if (eq system-type 'windows-nt )
      nil ;; 手动复制官方 Release zip 文件到 emacs 安装目录: https://github.com/merrickluo/liberime/releases
    (progn (add-to-list 'load-path "~/programs/liberime")
           ;; (setq liberime-module-file "/home/sawyer/programs/liberime/src/liberime-core.so")
           ))
  :config
  (setq liberime-auto-build t)
  (let ((liberime-auto-build t))
    (require 'liberime nil t))

  (require 'pyim-liberime)

  (liberime-select-schema "luna_pinyin_simp")
  (setq pyim-default-scheme 'rime-quanpin)

  (setq liberime-user-data-dir (expand-file-name "rime" doom-etc-dir))
  )


(use-package! pyim-liberime
  :when (featurep! +rime)
  :commands (pyim-liberime-create-word pyim-liberime-word-log pyim-liberime-code-log)
  :after (pyim liberime)
  :config
  (setq pyim-default-scheme 'rime-quanpin))


(use-package! valign
  :hook (org-mode . valign-mode)
  :config
  (after! markdown-mode
    (add-hook! 'markdown-mode-hook 'valign-mode)))

;; -------------- origin -------------------------

(use-package! pangu-spacing
  :hook (text-mode . pangu-spacing-mode)
  :config
  ;; Always insert `real' space in org-mode.
  (setq-hook! 'org-mode-hook pangu-spacing-real-insert-separtor t))


(use-package! fcitx
  :after evil
  :config
  (when (setq fcitx-remote-command
              (or (executable-find "fcitx5-remote")
                  (executable-find "fcitx-remote")))
    (fcitx-evil-turn-on)))


(use-package! ace-pinyin
  :after avy
  :init (setq ace-pinyin-use-avy t)
  :config (ace-pinyin-global-mode t))


;;
;;; Hacks

(defadvice! +chinese--org-html-paragraph-a (args)
  "Join consecutive Chinese lines into a single long line without unwanted space
when exporting org-mode to html."
  :filter-args #'org-html-paragraph
  (cl-destructuring-bind (paragraph contents info) args
    (let* ((fix-regexp "[[:multibyte:]]")
           (fixed-contents
            (replace-regexp-in-string
             (concat "\\(" fix-regexp "\\) *\n *\\(" fix-regexp "\\)")
             "\\1\\2"
             contents)))
      (list paragraph fixed-contents info))))

(provide 'config)
;;; config.el ends here