diff options
author | JSDurand <mmemmew@gmail.com> | 2025-07-31 16:23:11 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2025-07-31 16:23:11 +0800 |
commit | 7dc4c91981d534f2d7e00d6c8a71d864c1bcb5f7 (patch) | |
tree | f2e378f06dc1cc88d7026901c8adb9dfe64c44ae | |
parent | f33b12428792eafb8525ee0882354eb1554d2eb4 (diff) |
* input-conf.el (quail, durand-convert-string-by-input-method): This
function converts the string to its equivalent under the chosen
input method. This way one does not have to change the input
method, and later change the typed mess into the desired language
directly, which sometimes occured to me.
-rw-r--r-- | input-conf.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/input-conf.el b/input-conf.el index 461b674..ce01599 100644 --- a/input-conf.el +++ b/input-conf.el @@ -25,6 +25,9 @@ ;;; Code: +;; core package +(require 'quail) + ;;; Chinese-zozy ;; This does not work. I shall find another way to do this. @@ -100,5 +103,26 @@ (quail-set-keyboard-layout "durand-fr") +;;; Convert a string to its equivalent under an input-method + +(defun durand-convert-string-by-input-method (str method) + "Convert the string STR to its equivalent under the input-method \ +METHOD. + +Basically, this functions activates the input method METHOD and +then enters the string STR, and returns the inputted string." + (let ((prev-input-method current-input-method) + (temp-buffer (generate-new-buffer " *temp*" t)) + result) + (switch-to-buffer temp-buffer) + (activate-input-method method) + (execute-kbd-macro (vconcat str)) + (activate-input-method prev-input-method) + (setq + result + (buffer-substring-no-properties (point-min) (point-max))) + (kill-buffer temp-buffer) + result)) + (provide 'input-conf) ;;; input-conf.el ends here |