Skip to content

inline断言问题 #219

Open
Open
@luyajun01

Description

问题描述

在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")))
  )

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions