Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org代码块中输入中文 #215

Open
nigo81 opened this issue Mar 12, 2023 · 1 comment
Open

org代码块中输入中文 #215

nigo81 opened this issue Mar 12, 2023 · 1 comment

Comments

@nigo81
Copy link

nigo81 commented Mar 12, 2023

开启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)
)
  • 操作系统:如 arcolinux
  • Emacs版本:如 29.0.60
  • Librime版本:如 1.8.5-1
  • Librime安装方式:包管理器yay
@nigo81 nigo81 added the bug Something isn't working label Mar 12, 2023
@DogLooksGood
Copy link
Owner

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

@DogLooksGood DogLooksGood removed the bug Something isn't working label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants