diff options
| author | Alan Third | 2016-02-10 18:27:50 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-02-10 18:36:04 -0800 |
| commit | eb4a18c7db2286bcb9d9ea8f392175a28a86772c (patch) | |
| tree | b1dabf5c65d2fe69a9bc18f2eb9ee1f0d5b8e7c9 /src | |
| parent | 456c0a3137bf58ee61a8e442cff0ca5d808e8d32 (diff) | |
| download | emacs-eb4a18c7db2286bcb9d9ea8f392175a28a86772c.tar.gz emacs-eb4a18c7db2286bcb9d9ea8f392175a28a86772c.zip | |
Set locale when run from OS X GUI
* src/emacs.c (main): Call ns_init_locale.
* src/nsterm.m (ns_init_locale): Get locale from OS and set LANG.
* src/nsterm.h: Include ns_init_locale.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 5 | ||||
| -rw-r--r-- | src/nsterm.h | 2 | ||||
| -rw-r--r-- | src/nsterm.m | 21 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c index e3cfad0f7f8..ab5d777aa2e 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1310,6 +1310,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1310 | init_ntproc (dumping); /* must precede init_editfns. */ | 1310 | init_ntproc (dumping); /* must precede init_editfns. */ |
| 1311 | #endif | 1311 | #endif |
| 1312 | 1312 | ||
| 1313 | #ifdef HAVE_NS | ||
| 1314 | /* Initialise the locale from user defaults. */ | ||
| 1315 | ns_init_locale(); | ||
| 1316 | #endif | ||
| 1317 | |||
| 1313 | /* Initialize and GC-protect Vinitial_environment and | 1318 | /* Initialize and GC-protect Vinitial_environment and |
| 1314 | Vprocess_environment before set_initial_environment fills them | 1319 | Vprocess_environment before set_initial_environment fills them |
| 1315 | in. */ | 1320 | in. */ |
diff --git a/src/nsterm.h b/src/nsterm.h index 6ca584e6774..fa5399c7f90 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -1141,6 +1141,8 @@ extern void ns_retain_object (void *obj); | |||
| 1141 | extern void *ns_alloc_autorelease_pool (void); | 1141 | extern void *ns_alloc_autorelease_pool (void); |
| 1142 | extern void ns_release_autorelease_pool (void *); | 1142 | extern void ns_release_autorelease_pool (void *); |
| 1143 | extern const char *ns_get_defaults_value (const char *key); | 1143 | extern const char *ns_get_defaults_value (const char *key); |
| 1144 | extern void ns_init_locale (void); | ||
| 1145 | |||
| 1144 | 1146 | ||
| 1145 | /* in nsmenu */ | 1147 | /* in nsmenu */ |
| 1146 | extern void update_frame_tool_bar (struct frame *f); | 1148 | extern void update_frame_tool_bar (struct frame *f); |
diff --git a/src/nsterm.m b/src/nsterm.m index f77aadba67c..43d1377f8a7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -586,6 +586,27 @@ ns_load_path (void) | |||
| 586 | 586 | ||
| 587 | 587 | ||
| 588 | void | 588 | void |
| 589 | ns_init_locale (void) | ||
| 590 | /* OS X doesn't set any environment variables for the locale when run | ||
| 591 | from the GUI. Get the locale from the OS and set LANG. */ | ||
| 592 | { | ||
| 593 | NSLocale *locale = [NSLocale currentLocale]; | ||
| 594 | |||
| 595 | NSTRACE ("ns_init_locale"); | ||
| 596 | |||
| 597 | @try | ||
| 598 | { | ||
| 599 | /* Set LANG to locale, but not if LANG is already set. */ | ||
| 600 | setenv("LANG", [[locale localeIdentifier] UTF8String], 0); | ||
| 601 | } | ||
| 602 | @catch (NSException *e) | ||
| 603 | { | ||
| 604 | NSLog (@"Locale detection failed: %@: %@", [e name], [e reason]); | ||
| 605 | } | ||
| 606 | } | ||
| 607 | |||
| 608 | |||
| 609 | void | ||
| 589 | ns_release_object (void *obj) | 610 | ns_release_object (void *obj) |
| 590 | /* -------------------------------------------------------------------------- | 611 | /* -------------------------------------------------------------------------- |
| 591 | Release an object (callable from C) | 612 | Release an object (callable from C) |