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).
This commit is contained in:
parent
1155826c98
commit
ab79950009
2 changed files with 32 additions and 2 deletions
5
etc/NEWS
5
etc/NEWS
|
@ -3844,6 +3844,11 @@ locales. They are also available as aliases 'ebcdic-cp-*' (e.g.,
|
|||
'cp278' for 'ibm278'). There are also new charsets 'ibm2xx' to
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue