unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* language environment depending on file
@ 2004-10-14 14:11 slanning
  2004-10-15  9:47 ` Joakim Hove
  0 siblings, 1 reply; 4+ messages in thread
From: slanning @ 2004-10-14 14:11 UTC (permalink / raw)


I'd like to have emacs change the current language
environment depending on what file I'm editing.
For example, all files ending in .mc, I want to
edit in UTF-8, whereas otherwise use my default
language environment.
  I tried this

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

in ~/.emacs, to try to set the language environment
only locally to a buffer that's loaded when mmm-mode
is started (so really, it's more than *.mc).
The problem is, it ends up changing the language
environment globally, so after I edit a .mc file,
any other file I edit is edited in UTF-8. So I'd like
a per-mode way of setting the language environment
or something. 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: language environment depending on file
  2004-10-14 14:11 language environment depending on file slanning
@ 2004-10-15  9:47 ` Joakim Hove
  2004-10-15 12:38   ` Oliver Scholz
  0 siblings, 1 reply; 4+ messages in thread
From: Joakim Hove @ 2004-10-15  9:47 UTC (permalink / raw)



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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: language environment depending on file
  2004-10-15  9:47 ` Joakim Hove
@ 2004-10-15 12:38   ` Oliver Scholz
  2004-10-19 16:58     ` slanning
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Scholz @ 2004-10-15 12:38 UTC (permalink / raw)


Joakim Hove <hove@ift.uib.no> writes:

> slanning@theworld.com writes:
>
>
>>
>>   (add-hook 'mmm-mode-hook
>>     '(lambda ()
>>        (make-variable-buffer-local 'current-language-environment)
>>        (set-language-environment "UTF-8")))
[...]
> Anyway, you *might* try to advice the set-buffer or switch-to-buffer
> functions with something like:
[...]

I might be wrong, but there seems to be some confusion here. I believe
what the OP really wants is not change the language environment, but
simply the character encoding for .mc files:

(modify-coding-system-alist 'file "\\.mc\\'" 'utf-8)

    Oliver
-- 
24 Vendémiaire an 213 de la Révolution
Liberté, Egalité, Fraternité!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: language environment depending on file
  2004-10-15 12:38   ` Oliver Scholz
@ 2004-10-19 16:58     ` slanning
  0 siblings, 0 replies; 4+ messages in thread
From: slanning @ 2004-10-19 16:58 UTC (permalink / raw)


Oliver Scholz <alkibiades@gmx.de> wrote:
> I might be wrong, but there seems to be some confusion here. I believe
> what the OP really wants is not change the language environment, but
> simply the character encoding for .mc files:
>
> (modify-coding-system-alist 'file "\\.mc\\'" 'utf-8)

Yes, perfect. Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-10-19 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-14 14:11 language environment depending on file slanning
2004-10-15  9:47 ` Joakim Hove
2004-10-15 12:38   ` Oliver Scholz
2004-10-19 16:58     ` slanning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).