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

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

Re: language environment depending on file


From: Joakim Hove
Subject: Re: language environment depending on file
Date: Fri, 15 Oct 2004 11:47:39 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux)

slanning@theworld.com writes:


>
>   (add-hook 'mmm-mode-hook
>     '(lambda ()
>        (make-variable-buffer-local 'current-language-environment)
>        (set-language-environment "UTF-8")))

/----[C-h v current-language-environmen]
| current-language-environment's value is "Latin-1"
| 
| Documentation:
| The last language environment specified with `set-language-environment'.
| This variable should be set only with M-x customize, which is equivalent
| to using the function `set-language-environment'.
| 
| You can customize this variable.
| 
| Defined in `international/mule-cmds'.
\----

The way I read the above documentation, you really can not set a value
to the current-language-environment variable, the only way to change
the language environment is through the (set-language-environment )
function, and then you can *read* the language-env. status by checking
the current-lang.-env. variable.


> I guess I could add a similar hook as above for every other mode,
> setting language environment back to what I want for the default,
> but that seems pretty ugly.

Yes ugly, and I think it is even worse, because you would have to
change lang.-env. every time you changed buffer (I think). [I dare not
think of the situation when multiple windows/frames are active at the
same time.]

Anyway, you *might* try to advice the set-buffer or switch-to-buffer
functions with something like:

(defun set-lang-env ()
  (if (eq major-mode 'mmm-mode)
      (unless (string-equal current-language-environment "UTF-8")
        (set-language-environment "UTF-8"))
    (if (string-equal current-language-environment "UTF-8")
        (set-language-environment "Latin-1"))))


(defadvice set-buffer (before lang-env-advice (arg))
  "Set language env. when going to a new buffer"
  (set-lang-env))

(ad-activate 'lang-env-advice)


Good luck - Joakim

-- 
Joakim Hove
hove AT ift uib no
+47 (55 5)8 27 90
http://www.ift.uib.no/~hove/


reply via email to

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