Discussion:
[AUCTeX] Overenthusiastic language detection
Tristan Miller
2017-06-23 14:28:47 UTC
Permalink
Dear all,

AUCTeX automatically changes the quote and hyphen insertion when using
certain Babel languages. However, I can't help wondering whether the
mechanism it uses to detect the language is a little overenthusiastic.

I usually write in some variant of English, but need to write
occasional passages in some other language. So I usually have
something like the following in my preamble:

\usepackage[ngerman,canadian]{babel}

This causes AUCTeX to change the behaviour of the " and - keys to
support German text, which is not convenient when the vast majority of
the document is in English.

Does it really make sense for AUCTeX to do this when the last entry in
the argument list for Babel is an English one? Even if so, what can I
do to automatically suppress this behaviour? I still want the
appropriate non-English behaviour of " and - when a non-English
language is the last argument to Babel; I just don't want the
non-English behaviour when "english", "american", "british", etc. is
the last argument.

(By the way, in the HTML version of the documentation at
<https://www.gnu.org/software/auctex/manual/auctex/auctex.html>, the
"European" section (§5.4.1) is empty and its subsections give 404
errors.)

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Arash Esbati
2017-07-01 20:11:59 UTC
Permalink
Post by Tristan Miller
AUCTeX automatically changes the quote and hyphen insertion when using
certain Babel languages. However, I can't help wondering whether the
mechanism it uses to detect the language is a little overenthusiastic.
I usually write in some variant of English, but need to write
occasional passages in some other language. So I usually have
\usepackage[ngerman,canadian]{babel}
This causes AUCTeX to change the behaviour of the " and - keys to
support German text, which is not convenient when the vast majority of
the document is in English.
Does it really make sense for AUCTeX to do this when the last entry in
the argument list for Babel is an English one? Even if so, what can I
do to automatically suppress this behaviour? I still want the
appropriate non-English behaviour of " and - when a non-English
language is the last argument to Babel; I just don't want the
non-English behaviour when "english", "american", "british", etc. is
the last argument.
Hi Tristan,

thanks for this report. Within AUCTeX, babel.el runs style files for
language options in reverse order, so canadian.el would come last.

The first issue with your setup is that AUCTeX does not have a style
file for canadian language. This can be cured easily be adding
something like this to AUCTeX:

--8<---------------cut here---------------start------------->8---
(TeX-add-style-hook
"canadian"
(lambda ()
(TeX-run-style-hooks "english"))
LaTeX-dialect)
--8<---------------cut here---------------end--------------->8---

But that will not help either since english.el does not reset the
variable `TeX-quote-language' which is changed by ngerman.el. This
patch should fix the issue with quotes:

--8<---------------cut here---------------start------------->8---
diff --git a/style/english.el b/style/english.el
index 90254c23..33e05e8c 100644
--- a/style/english.el
+++ b/style/english.el
@@ -5,6 +5,8 @@
(TeX-add-style-hook
"english"
(lambda ()
+ (unless (eq (car TeX-quote-language) 'override)
+ (setq TeX-quote-language nil))
(run-hooks 'TeX-language-en-hook))
LaTeX-dialect)
--8<---------------cut here---------------end--------------->8---

Regarding the - key, I could not figure how to solve it with an entry in
`LaTeX-babel-hyphen-language-alist' and setting
`LaTeX-babel-hyphen-language' to "english". Others?

Best, Arash
g***@gmail.com
2017-07-01 21:26:29 UTC
Permalink
Hi Tristan and Arash,

another possible simple solution is to copy and paste the "english.el" style file from your

~/.emacs.d/elpa/auctex-11.90.2/style/

directory into the one with your own style files, defined in TeX-style-local, which for me is

~/.emacs.d/auctex/.auctex-style/

and rename it there to "canadian.el". Of course you can also edit it to create your own canadian style file. I did something similar for the "british.el" style.

Is that correct, people?

By the way, I noticed that emacs's own lisp/language directory already contains an "english.el". Does someone know if there's any path conflict with the auctex one?

Cheers,
J
Post by Arash Esbati
Post by Tristan Miller
AUCTeX automatically changes the quote and hyphen insertion when using
certain Babel languages. However, I can't help wondering whether the
mechanism it uses to detect the language is a little overenthusiastic.
I usually write in some variant of English, but need to write
occasional passages in some other language. So I usually have
\usepackage[ngerman,canadian]{babel}
This causes AUCTeX to change the behaviour of the " and - keys to
support German text, which is not convenient when the vast majority of
the document is in English.
Does it really make sense for AUCTeX to do this when the last entry in
the argument list for Babel is an English one? Even if so, what can I
do to automatically suppress this behaviour? I still want the
appropriate non-English behaviour of " and - when a non-English
language is the last argument to Babel; I just don't want the
non-English behaviour when "english", "american", "british", etc. is
the last argument.
Hi Tristan,
thanks for this report. Within AUCTeX, babel.el runs style files for
language options in reverse order, so canadian.el would come last.
The first issue with your setup is that AUCTeX does not have a style
file for canadian language. This can be cured easily be adding
--8<---------------cut here---------------start------------->8---
(TeX-add-style-hook
"canadian"
(lambda ()
(TeX-run-style-hooks "english"))
LaTeX-dialect)
--8<---------------cut here---------------end--------------->8---
But that will not help either since english.el does not reset the
variable `TeX-quote-language' which is changed by ngerman.el. This
--8<---------------cut here---------------start------------->8---
diff --git a/style/english.el b/style/english.el
index 90254c23..33e05e8c 100644
--- a/style/english.el
+++ b/style/english.el
@@ -5,6 +5,8 @@
(TeX-add-style-hook
"english"
(lambda ()
+ (unless (eq (car TeX-quote-language) 'override)
+ (setq TeX-quote-language nil))
(run-hooks 'TeX-language-en-hook))
LaTeX-dialect)
--8<---------------cut here---------------end--------------->8---
Regarding the - key, I could not figure how to solve it with an entry in
`LaTeX-babel-hyphen-language-alist' and setting
`LaTeX-babel-hyphen-language' to "english". Others?
Best, Arash
_______________________________________________
auctex mailing list
https://lists.gnu.org/mailman/listinfo/auctex
Colin Baxter
2017-07-02 06:53:33 UTC
Permalink
gojjoe> Hi Tristan and Arash, another possible simple solution is to
gojjoe> copy and paste the "english.el" style file from your

gojjoe> ~/.emacs.d/elpa/auctex-11.90.2/style/

gojjoe> directory into the one with your own style files, defined in
gojjoe> TeX-style-local, which for me is

gojjoe> ~/.emacs.d/auctex/.auctex-style/

gojjoe> and rename it there to "canadian.el". Of course you can also
gojjoe> edit it to create your own canadian style file. I did
gojjoe> something similar for the "british.el" style.

gojjoe> Is that correct, people?

I always get confused between 'TeX-style-private' (default path:
~/.emacs.d/auctex/style) and 'TeX-style-local' (default path:
style). Presumably one takes president over the other, but I've never
investigated further.

Best wishes,

Colin.
--
--
Colin Baxter
***@yandex.com
GnuPG fingerprint: 68A8 799C 0230 16E7 BF68 2A27 BBFA 2492 91F5 41C8
Arash Esbati
2017-07-02 20:56:53 UTC
Permalink
Post by Colin Baxter
style). Presumably one takes president over the other, but I've never
investigated further.
Hi Colin,

check the value of `TeX-style-path'.

Best, Arash
Colin Baxter
2017-07-03 07:57:38 UTC
Permalink
Dear Arash,
Post by Colin Baxter
style). Presumably one takes president over the other, but I've
never investigated further.
Arash> Hi Colin,

Arash> check the value of `TeX-style-path'.

Arash> Best, Arash

Thank you. That is useful to know.

Best wishes, Colin.
--
--
Colin Baxter
***@yandex.com
GnuPG fingerprint: 68A8 799C 0230 16E7 BF68 2A27 BBFA 2492 91F5 41C8
Tristan Miller
2017-07-02 09:15:46 UTC
Permalink
Dear Arash,

On Sat, 01 Jul 2017 22:11:59 +0200, Arash Esbati
Post by Arash Esbati
The first issue with your setup is that AUCTeX does not have a style
file for canadian language.
Oh, why not? Is this by design? If not, perhaps such a style file
could be added to the official AUCTeX distribution (along with any
other ones needed for English variants supported by Babel).

Thanks for your other tip regarding how to fix the quote insertion.

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Arash Esbati
2017-07-02 21:03:09 UTC
Permalink
Post by Tristan Miller
Post by Arash Esbati
The first issue with your setup is that AUCTeX does not have a style
file for canadian language.
Oh, why not? Is this by design?
I would say it is by design of free software: Until now, nobody needed
it, nobody asked for it, nobody wrote it :-)
Post by Tristan Miller
If not, perhaps such a style file could be added to the official
AUCTeX distribution (along with any other ones needed for English
variants supported by Babel).
Thanks for your other tip regarding how to fix the quote insertion.
I can add canadian.el to AUCTeX, no problem. Did you have a chance to
try the patch I suggested? I'd like to get that issue in english.el
resolved as well.

Best, Arash
Tristan Miller
2017-07-03 09:08:53 UTC
Permalink
Dear Arash,

On Sun, 02 Jul 2017 23:03:09 +0200, Arash Esbati
Post by Arash Esbati
I can add canadian.el to AUCTeX, no problem.
Great. While you're at it, perhaps you could add "australian" and
"newzealand", which are also recognized by Babel but don't seem to have
corresponding files in AUCTeX.
Post by Arash Esbati
Did you have a chance to try the patch I suggested? I'd like to
get that issue in english.el resolved as well.
Yes, I tested it. Your patch corrects the behaviour of the quotation
marks, but not the hyphen. Thanks for the (partial) workaround. :)

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Arash Esbati
2017-07-03 22:08:06 UTC
Permalink
Post by Tristan Miller
Post by Arash Esbati
I can add canadian.el to AUCTeX, no problem.
Great. While you're at it, perhaps you could add "australian" and
"newzealand", which are also recognized by Babel but don't seem to have
corresponding files in AUCTeX.
Done!
Post by Tristan Miller
Post by Arash Esbati
Did you have a chance to try the patch I suggested? I'd like to
get that issue in english.el resolved as well.
Yes, I tested it. Your patch corrects the behaviour of the quotation
marks, but not the hyphen. Thanks for the (partial) workaround. :)
Thanks for testing. I installed it as well. Reg. the hyphen issue, you
can set `LaTeX-babel-hyphen' to an empty string or nil on a per file
basis like this:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% LaTeX-babel-hyphen: ""
%%% End:

This should serve as a workaround until a real solution is available.

Best, Arash

Loading...