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

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

Re: choose input method automatically


From: Oliver Scholz
Subject: Re: choose input method automatically
Date: Tue, 29 Jun 2004 17:36:47 -0000
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt)

Michael Slass <miknrene@drizzle.com> writes:

> Kevin Rodgers <ihs_4664@yahoo.com> writes:
>
>>Simon Strobl wrote:
>> > if a file starts with
>> >
>> >  -*- coding: utf-8;-*-
>> >
>> > emacs will automatically set the coding to utf-8. Is there something
>> > analogous for the input method?
>>
>>I would try adding this in -*-...-*-:
>>
>>eval: (set-input-method "foo")
>>
>
> There's a gotcha with that --- if you don't want emacs forcing you to
> confirm the local eval each time you read one of these files, you'll
> need to frob enable-local-eval, as described in the "File Local
> Variables" section of the emacs manual (excerpted below):
[...]

If you want to avoid both (confirming each time as well as frobbing
enable-local-eval) you could set some variable of your own in the
local variables section (everything below is untested)  …

-*- my-input-method: lirum-larum -*-

… and then put something like this into your .emacs:


(defvar my-input-method nil
  "Preferred input method local to a file.
This variable is meant to be set in the local variables section.")
(make-variable-buffer-local 'my-input-method)

;; When visiting a file, check whether `my-input-method' is non-nil
;; and set the current input method accordingly.
(add-hook 'find-file-hooks
          (lambda ()
            (when my-input-method
              ;; I seem to recall that the argument to
              ;; `set-input-method' is supposed to be a string, but I
              ;; can't check right now.
              (set-input-method (symbol-name my-input-method)))))



I think this method would also be useful for setting up file-specific
indentation styles, btw.

    Oliver
-- 
26 Prairial an 212 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

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