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

inline断言问题 #219

Open
luyajun01 opened this issue Jun 15, 2023 · 0 comments
Open

inline断言问题 #219

luyajun01 opened this issue Jun 15, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@luyajun01
Copy link

问题描述

在win 11平台上,emacs 30版本中,不能实现inline断言,即中文输入后空格英文上屏再空格中文上屏。

Emacs中的配置

(use-package rime
  :ensure t
  :init
  (defun +rime-force-enable
      ()
    "[ENHANCED] Force into Chinese input state.
If current input method is not `rime', active it first. If it is
currently in the `meow' non-editable state, then switch to
`moew-insert-state'."
    (interactive)
    (meow-mode 1)
    (let
        ((input-method "rime"))
      (unless
          (string= current-input-method input-method)
        (activate-input-method input-method))
      ;; (when (rime-predicate-prog-mode-p)
      ;;   (if (= (1+ (point)) (line-end-position))
      ;;       (meow-append 1)
      ;;     (meow-insert 1)
	  ;; ))
      (rime-force-enable))
    (meow-mode 0)
    )

  (defun +rime-convert-string-at-point
      ()
    "Convert the string at point to Chinese using the current input scheme.
First call `+rime-force-enable' to active the input method, and
then search back from the current cursor for available string (if
a string is selected, use it) as the input code, call the current
input scheme to convert to Chinese."
    (interactive)
    (meow-mode 1)
    (+rime-force-enable)
    ;; (rime-inline-ascii)
    (let
        ((string
          (if mark-active
              (buffer-substring-no-properties
               (region-beginning)
               (region-end))
            (buffer-substring-no-properties
             (point)
             (max
              (line-beginning-position)
              (-
               (point)
               80)))))
         code
         length)
      (cond
       ((string-match "\\([a-z]+\\|[[:punct:]]\\)[[:blank:]]*$" string)
        (setq code
              (replace-regexp-in-string
               "^[-']" ""
               (match-string 0 string)))
        (setq length
              (length code))
        (setq code
              (replace-regexp-in-string " +" "" code))
        (if mark-active
            (delete-region
             (region-beginning)
             (region-end))
          (when
              (> length 0)
            (delete-char
             (- 0 length))))
        (when
            (> length 0)
          (setq unread-command-events
                (append
                 (listify-key-sequence code)
                 unread-command-events))))
       (t
        (message "`+rime-convert-string-at-point' did nothing."))))
    (meow-insert)
    )

  :custom-face
  (rime-default-face ((t (:background "gray100" :foreground "#333333"))))
  :custom
  (default-input-method "rime")
  (rime-show-candidate 'posframe)
  (rime-emacs-module-header-root "~/.emacs.d/librime/emacs-module/30/")
  (rime-librime-root "C:/Users/tonylu/Downloads/emacs-30/lib")
  (rime-share-data-dir "C:/Program Files (x86)/Rime/weasel-0.14.3/data")
  (rime-user-data-dir "C:/Users/tonylu/AppData/Roaming/Rime")
  :bind
  ("C-S-p". #'+rime-convert-string-at-point)
  (:map rime-active-mode-map
        ("C-S-k" . #'rime-inline-ascii))
  (:map rime-mode-map
   ("C-S-p" . #'rime-force-enable))
  (:map rime-mode-map
      ("C-S-p" . #'+rime-convert-string-at-point))
  :config
  (setq rime-posframe-fixed-position t)
  (setq rime-inline-ascii-trigger 'shift-l)
  (setq rime-disable-predicates
                '(
				  meow-normal-mode-p
				  meow-motion-mode-p
				  meow-insert-mode-p
				  meow-keypad-mode-p
				 rime-predicate-prog-in-code-p
           rime-predicate-after-alphabet-char-p
   )
                              )

  (setq rime-inline-predicates
   '(rime-predicate-space-after-cc-p
   rime-predicate-current-uppercase-letter-p
   )
   )
  (add-hook 'org-mode-hook (lambda () (set-input-method "rime")))
  )
@luyajun01 luyajun01 added the bug Something isn't working label Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant