[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Better language detection for tutorial
From: |
Sascha Wilde |
Subject: |
Re: Better language detection for tutorial |
Date: |
Sun, 22 Jul 2007 22:20:18 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
Andreas Schwab <address@hidden> wrote:
> Sascha Wilde <address@hidden> writes:
>
>> + (defun tutorial-get-language ()
>> + "Use LC_ALL, LC_MESSAGES, LANG in turn to determine language to use.
>> + This is more reliable then current-language-environment, which is not
> than `...'
>> + intended to chose the language used for messages and documentation."
> choose
Thanks, I changed that...
>> + (let (locale (vars '("LC_ALL" "LC_MESSAGES" "LANG")))
>> + (while (and vars
>> + (= 0 (length locale))) ; nil or empty string
> zerop or (= (length locale) 0)
I copied this part of the code from `mule-cmds.el',
set-locale-environment. I intentionally didn't change the code,
but I agree that your version is better style, so I changed that,
too.
>> + (setq locale (getenv (pop vars))))
>
> pop is a macro in cl.
See Davids mail on this.
>> + (if (< 0 (length locale))
> (> (length locale) 0)
Originally written according to the code from `mule-cmds.el', changed.
New patch:
diff -c /usr/local/hg/emacs-hg/lisp/tutorial.el
/home/wilde/src/emacs-hg-work/lisp/tutorial.el
*** /usr/local/hg/emacs-hg/lisp/tutorial.el 2007-06-13 08:22:59.377470279
+0200
--- /home/wilde/src/emacs-hg-work/lisp/tutorial.el 2007-07-22
22:14:52.079157597 +0200
***************
*** 621,626 ****
--- 621,641 ----
face tutorial-warning-face
read-only t)))))))))))
+ (defun tutorial-get-language ()
+ "Use LC_ALL, LC_MESSAGES, LANG in turn to determine language to use.
+ This is more reliable than current-language-environment, which is not
+ intended to choose the language used for messages and documentation."
+ (let (locale (vars '("LC_ALL" "LC_MESSAGES" "LANG")))
+ (while (and vars
+ (zerop (length locale))) ; nil or empty string
+ (setq locale (getenv (pop vars))))
+ (if (> (length locale) 0)
+ (let ((language (locale-name-match locale
+ locale-language-names)))
+ (if (consp language)
+ (car language)
+ language)))))
+
(defun tutorial--saved-dir ()
"Directory to which tutorials are saved."
(expand-file-name "tutorial" user-emacs-directory))
***************
*** 766,774 ****
(add-hook 'minibuffer-setup-hook
'minibuffer-completion-help)
(read-language-name 'tutorial "Language: " "English"))
! (if (get-language-info current-language-environment
'tutorial)
! current-language-environment
! "English")))
(filename (get-language-info lang 'tutorial))
;; Choose a buffer name including the language so that
;; several languages can be tested simultaneously:
--- 781,790 ----
(add-hook 'minibuffer-setup-hook
'minibuffer-completion-help)
(read-language-name 'tutorial "Language: " "English"))
! (or (tutorial-get-language)
! (if (get-language-info current-language-environment
'tutorial)
! current-language-environment
! "English"))))
(filename (get-language-info lang 'tutorial))
;; Choose a buffer name including the language so that
;; several languages can be tested simultaneously:
Diff finished. Sun Jul 22 22:16:56 2007
--
Sascha Wilde -.-. ..- .-. .. --- ... .. - -.--
-.- .. .-.. .-.. . -..
- .... .
-.-. .- -
- Re: set-locale-environement: strange default detection, (continued)
- Re: set-locale-environement: strange default detection, Reiner Steib, 2007/07/18
- Re: set-locale-environement: strange default detection, David Kastrup, 2007/07/18
- Re: set-locale-environement: strange default detection, Sascha Wilde, 2007/07/19
- Re: set-locale-environement: strange default detection, David Kastrup, 2007/07/19
- Better language detection for tutorial (was: set-locale-environement: strange default detection), Sascha Wilde, 2007/07/22
- Re: Better language detection for tutorial (was: set-locale-environement: strange default detection), Andreas Schwab, 2007/07/22
- Re: Better language detection for tutorial, David Kastrup, 2007/07/22
- Re: Better language detection for tutorial, Andreas Schwab, 2007/07/22
- Re: Better language detection for tutorial,
Sascha Wilde <=
- Re: Better language detection for tutorial, Eli Zaretskii, 2007/07/22
- Re: Better language detection for tutorial, Sascha Wilde, 2007/07/23
- Re: Better language detection for tutorial, Eli Zaretskii, 2007/07/23
- Re: Better language detection for tutorial, Sascha Wilde, 2007/07/23
- Re: Better language detection for tutorial, David Kastrup, 2007/07/23
- Re: Better language detection for tutorial, Eli Zaretskii, 2007/07/24
- Re: Better language detection for tutorial, Kenichi Handa, 2007/07/24
- Re: Better language detection for tutorial, Eli Zaretskii, 2007/07/24
- Re: Better language detection for tutorial, Kenichi Handa, 2007/07/24
- Re: Better language detection for tutorial, Eli Zaretskii, 2007/07/24