help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripting input methods (was back (batch) translate chars to keyboar


From: Nick Dokos
Subject: Re: scripting input methods (was back (batch) translate chars to keyboard events)
Date: Mon, 13 Feb 2012 10:47:58 -0500

Jambunathan K <kjambunathan@gmail.com> wrote:

> 
> Rustom 
> 
> Try this:
> 
> (defun translate-to-hindi (filename)
>   (interactive "fFile to be translated: ")
>   (with-temp-buffer  
>     (switch-to-buffer (current-buffer))
>     (setq buffer-file-coding-system 'utf-8)
>     (set-input-method "devanagari-itrans" t)
>     (execute-kbd-macro
>      (with-temp-buffer
>        (insert-file-contents filename)
>        (buffer-string)))
> 
>     (write-file
>      (concat (file-name-sans-extension filename)
>            "-hi" (file-name-extension filename t)))))
> 

Perfect. I haven't tried to see what happens if you just
input arbitrary junk to it, but it is at least idempotent.

Nick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]