diff options
author | JSDurand <mmemmew@gmail.com> | 2025-08-18 18:08:13 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2025-08-18 18:08:13 +0800 |
commit | effba3d828bb3502edbbb56e34efbd3a2cd49969 (patch) | |
tree | 9e802c74aae19f062516516b010a06cb5b972338 | |
parent | 5c230a8892b42c5d5f77c89057312679097c6a97 (diff) |
input: Convert buffer region to a specified input method
* input-conf.el (durand-convert-region-by-input-method): A helper to
convert buffer text according to a chosen input method. I think
this is sometimes convenient.
-rw-r--r-- | input-conf.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/input-conf.el b/input-conf.el index ce01599..1ea7f0d 100644 --- a/input-conf.el +++ b/input-conf.el @@ -124,5 +124,24 @@ then enters the string STR, and returns the inputted string." (kill-buffer temp-buffer) result)) +(defun durand-convert-region-by-input-method (start end method) + "Convert the string in the region between START and END by the +input-method METHOD. + +See the function `durand-convert-string-by-input-method' for +more." + (interactive + (append + (cond ((region-active-p) + (list (region-beginning) (region-end))) + ((list (point) (point)))) + (list (read-input-method-name "By which input method: ")))) + (let* ((str (buffer-substring-no-properties start end)) + (converted + (durand-convert-string-by-input-method str method))) + (delete-region start end) + (goto-char start) + (insert converted))) + (provide 'input-conf) ;;; input-conf.el ends here |