Skip to content

Commit

Permalink
Don't fail with an error when starting in a terminal environment with…
Browse files Browse the repository at this point in the history
…out the "locale" command (fixes #6)
  • Loading branch information
purcell committed Nov 24, 2011
1 parent 6816b18 commit 78c438b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions init-locales.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
(when (or window-system (string-match "UTF-8" (shell-command-to-string "locale")))
(defun locale-is-utf8-p ()
"Return t iff the \"locale\" command or environment variables prefer UTF-8."
(flet ((is-utf8 (v) (and v (string-match "UTF-8" v))))
(or (is-utf8 (and (executable-find "locale") (shell-command-to-string "locale")))
(is-utf8 (getenv "LC_ALL"))
(is-utf8 (getenv "LC_CTYPE"))
(is-utf8 (getenv "LANG")))))

(when (or window-system (locale-is-utf8-p))
(setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(set-language-environment 'utf-8)
(when *is-carbon-emacs*
Expand All @@ -9,4 +17,4 @@
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8))

(provide 'init-locales)
(provide 'init-locales)

0 comments on commit 78c438b

Please sign in to comment.