auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] Overenthusiastic language detection


From: Arash Esbati
Subject: Re: [AUCTeX] Overenthusiastic language detection
Date: Sat, 01 Jul 2017 22:11:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2

Tristan Miller <address@hidden> writes:

> 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.

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



reply via email to

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