summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input-conf.el24
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