[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ab79950: Make `set-locale-environment' complete over locale names
From: |
Lars Ingebrigtsen |
Subject: |
master ab79950: Make `set-locale-environment' complete over locale names |
Date: |
Wed, 25 Aug 2021 11:33:12 -0400 (EDT) |
branch: master
commit ab799500094fb36b3f26b9c8a4147848b204cf0a
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make `set-locale-environment' complete over locale names
* lisp/international/mule-cmds.el (get-locale-names): New function.
(set-locale-environment): Use it to allow completion (bug#9655).
---
etc/NEWS | 5 +++++
lisp/international/mule-cmds.el | 29 +++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 2575061..2c929e4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3845,6 +3845,11 @@ locales. They are also available as aliases
'ebcdic-cp-*' (e.g.,
support these coding-systems.
---
+** New function 'get-locale-names'.
+This utility function returns a list of locale names on the current
+system.
+
+---
** 'while-no-input-ignore-events' accepts more special events.
The special events 'dbus-event' and 'file-notify' are now ignored in
'while-no-input' when added to this variable.
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 71e2653..dc09dad 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2610,6 +2610,31 @@ is returned. Thus, for instance, if charset
\"ISO8859-2\",
(declare-function w32-get-console-codepage "w32proc.c" ())
(declare-function w32-get-console-output-codepage "w32proc.c" ())
+(defun get-locale-names ()
+ "Return a list of locale names."
+ (cond
+ ;; On Windows we have a built-in method to get the names.
+ ((and (fboundp 'w32-get-locale-info)
+ (fboundp 'w32-get-valid-locale-ids))
+ (mapcar #'w32-get-locale-info (w32-get-valid-locale-ids)))
+ ;; Unix-ey hosts should have a command to output locales currently
+ ;; defined by the OS.
+ ((executable-find "locale")
+ (split-string (shell-command-to-string "locale -a")))
+ ;; Fall back on the list of all defined locales.
+ ((and locale-translation-file-name
+ (file-exists-p locale-translation-file-name))
+ (with-temp-buffer
+ (insert-file-contents locale-translation-file-name)
+ (let ((locales nil))
+ (while (not (eobp))
+ (unless (looking-at-p "#")
+ (push (cadr (split-string (buffer-substring
+ (point) (line-end-position))))
+ locales))
+ (forward-line 1))
+ (nreverse locales))))))
+
(defun locale-translate (locale)
"Expand LOCALE according to `locale-translation-file-name', if possible.
For example, translate \"swedish\" into \"sv_SE.ISO8859-1\"."
@@ -2650,8 +2675,8 @@ touch session-global parameters like the language
environment.
See also `locale-charset-language-names', `locale-language-names',
`locale-preferred-coding-systems' and `locale-coding-system'."
- (interactive "sSet environment for locale: ")
-
+ (interactive (list (completing-read "Set environment for locale: "
+ (get-locale-names))))
;; Do this at runtime for the sake of binaries possibly transported
;; to a system without X.
(setq locale-translation-file-name
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ab79950: Make `set-locale-environment' complete over locale names,
Lars Ingebrigtsen <=