From: Sascha Wilde <wilde@sha-bang.de>
To: David Kastrup <dak@gnu.org>
Cc: Thomas Arendsen Hein <thomas@intevation.de>, emacs-devel@gnu.org
Subject: Better language detection for tutorial (was: set-locale-environement: strange default detection)
Date: Sun, 22 Jul 2007 16:59:14 +0200 [thread overview]
Message-ID: <m2lkd8o56l.fsf_-_@kenny.sha-bang.de> (raw)
In-Reply-To: <86ejj4g3d4.fsf@lola.quinscape.zz> (David Kastrup's message of "Thu\, 19 Jul 2007 11\:16\:39 +0200")
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
David Kastrup <dak@gnu.org> wrote:
> Sascha Wilde <wilde@sha-bang.de> writes:
>> So, what about the idea I sketched in my patch?
>
> The proper fix would be to have something more fine-grained than
> language-environment inside of Emacs.
>
> Until such a time, your fix appeared like the right thing to do at
> that junction to me. Your patch (I am going my memory here) has the
> disadvantage that it might look up the empty string as a language
> explicitly, expecting it to turn up nil. That's sort of ugly.
Here a revised version of the patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacs-tutorial-lang.patch --]
[-- Type: text/x-patch, Size: 2366 bytes --]
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 16:45:04.220919438 +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 then current-language-environment, which is not
+ intended to chose the language used for messages and documentation."
+ (let (locale (vars '("LC_ALL" "LC_MESSAGES" "LANG")))
+ (while (and vars
+ (= 0 (length locale))) ; nil or empty string
+ (setq locale (getenv (pop vars))))
+ (if (< 0 (length locale))
+ (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 16:48:36 2007
[-- Attachment #3: Type: text/plain, Size: 203 bytes --]
--
Sascha Wilde : The most exciting phrase to hear in science, the one
: that heralds new discoveries, is not "Eureka!" (I found
: it!) but "That's funny ..." -- Isaac Asimov
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2007-07-22 14:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-18 10:14 set-locale-environement: strange default detection Sascha Wilde
2007-07-18 10:19 ` David Kastrup
2007-07-18 10:40 ` Sascha Wilde
2007-07-18 10:50 ` David Kastrup
2007-07-18 11:04 ` Jan Djärv
2007-07-18 12:28 ` Sascha Wilde
2007-07-18 18:54 ` Reiner Steib
2007-07-18 21:24 ` David Kastrup
2007-07-19 8:21 ` Sascha Wilde
2007-07-19 9:16 ` David Kastrup
2007-07-22 14:59 ` Sascha Wilde [this message]
2007-07-22 15:41 ` Better language detection for tutorial (was: set-locale-environement: strange default detection) Andreas Schwab
2007-07-22 15:44 ` Better language detection for tutorial David Kastrup
2007-07-22 23:16 ` Andreas Schwab
2007-07-22 20:20 ` Sascha Wilde
2007-07-23 3:11 ` Eli Zaretskii
2007-07-23 9:25 ` Sascha Wilde
2007-07-23 19:29 ` Eli Zaretskii
2007-07-23 20:29 ` Sascha Wilde
2007-07-23 20:38 ` David Kastrup
2007-07-24 6:18 ` Eli Zaretskii
2007-07-24 7:17 ` Kenichi Handa
2007-07-24 7:36 ` Eli Zaretskii
2007-07-24 7:53 ` Kenichi Handa
2007-07-24 18:45 ` Eli Zaretskii
2007-07-25 1:01 ` Kenichi Handa
2007-07-25 3:14 ` Eli Zaretskii
2007-07-25 4:48 ` Kenichi Handa
2007-07-25 19:24 ` Eli Zaretskii
2007-07-26 2:29 ` Kenichi Handa
2007-07-26 11:40 ` Eli Zaretskii
2007-07-26 12:19 ` Kenichi Handa
2007-07-26 12:25 ` Eli Zaretskii
2007-07-26 12:54 ` Kenichi Handa
2007-07-20 17:42 ` set-locale-environement: strange default detection Reiner Steib
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2lkd8o56l.fsf_-_@kenny.sha-bang.de \
--to=wilde@sha-bang.de \
--cc=dak@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=thomas@intevation.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.