DogLooksGood / emacs-rime

RIME ㄓ in Emacs
GNU General Public License v3.0
473 stars 68 forks source link

org代码块中输入中文 #215

Open nigo81 opened 1 year ago

nigo81 commented 1 year ago

开启rime-predicate-org-in-src-block-p后,如何在代码块的注释后输入中文?

开启rime-predicate-org-in-src-block-p后,代码块中只能输入英文,但有时候会需要在代码块的注释后输入中文。

我可以怎么能实现这一目的?

Emacs中的配置

(use-package rime
  :ensure t
  :bind
    (:map rime-active-mode-map
     ("<tab>" . 'rime-inline-ascii)     ;; 使用 tab 切换中英文
     :map rime-mode-map
     ("C-`" . 'rime-send-keybinding)    ;; 切换输入方案
     ("C-," . 'rime-force-enable))      ;; 强制使用输入法
  :custom
  (default-input-method "rime")
  :config
  ;; 自定义函数
  (defun rime-predicate-punctuation-line-beginning-p ()
  "If the cursor is after a ascii character.
Can be used in `rime-disable-predicates' and `rime-inline-predicates'."
  (and (> (point) (save-excursion (back-to-indentation) (point)))
       (let ((string (buffer-substring (point) (max (line-beginning-position) (- (point) 80)))))
         (string-match-p "^[\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]$" string))))

  (setq rime-user-data-dir "~/.config/fcitx/rime/")
  (setq rime-show-candidate 'posframe)
  (setq rime-posframe-properties
   (list :internal-border-width 1))
  (with-eval-after-load 'ivy
    (define-key ivy-minibuffer-map (kbd "S-SPC") nil))
  (global-set-key (kbd "S-SPC") 'toggle-input-method)
  (setq rime-disable-predicates
        '(rime-predicate-evil-mode-p
          rime-predicate-after-alphabet-char-p;在英文字符串之后(必须为以字母开头的英文字符串)
          rime-predicate-punctuation-line-beginning-p ; 自定义函数,行首字符后
          rime-predicate-prog-in-code-p
          rime-predicate-in-code-string-p;在代码的字符串中,不含注释的字符串。
          rime-predicate-org-in-src-block-p
          rime-predicate-org-latex-mode-p
          rime-predicate-punctuation-line-begin-p ;在行首要输入符号时
          rime-predicate-punctuation-after-space-cc-p ;当要在中文字符且有空格之后输入符号时
          ))
  (setq rime-inline-predicates
        '(rime-predicate-space-after-cc-p ; 中文接一个空格的后面
          rime-predicate-current-uppercase-letter-p)) ; 当前输入是大写字母的时候
  (setq rime-inline-ascii-trigger 'shift-r)
)
DogLooksGood commented 1 year ago

这个问题,我觉得如果在 org 代码块中有中文需求,代码块以外也有中文需求,就不要使用在 org 中的断言就好了。