1

To enter Devanagari ITRANS input mode for a specific file, I need to type the following command in Emacs.

C-x RET C-\ devanagari-itrans RET

Is there something I could add to my file that would enable this mode automatically?

I was pointed to Specifying File Variables in the Emacs manual by someone in #emacs on Freenode, so that might be relevant.

1

You can add the following to the end of the file:

Local Variables:
eval: (set-input-method 'devanagari-itrans)
End:

(Pretty self-explanatory: (set-input-method 'devanagari-itrans) will be evaluated when you open the file.)

These lines can, if necessary, be "commented out". For instance, if the file were a python file (with # as the comment marker), the following would also work:

# Local Variables:
# eval: (set-input-method 'devanagari-itrans)
# End:

Note about safety

Since evaling arbitrary lisp forms (as the eval: ARBITRARY_LISP_FORM construction allows you to do), opens up a huge, potential security hole, emacs will ask you whether you want to apply the value(s) in the local variables list. You can agree to apply them this one time, not apply them, or set them as safe (to prevent emacs from asking you about these specific values in the future). The dialogue emacs provides is pretty helpful.

  • 1
    Thank you very much - that works. This is in a LaTeX file, and AUCTeX automatically adds local variables, so that section looks like "%%% Local Variables: %%% coding: utf-8 %%% mode: latex %%% eval: (set-input-method 'devanagari-itrans) %%% TeX-engine: xetex %%% TeX-master: t %%% End:" – Faheem Mitha May 3 '18 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.