Function: with-locale-environment

with-locale-environment is a macro defined in mule-cmds.el.gz.

Signature

(with-locale-environment LOCALE-NAME &rest BODY)

Documentation

Execute BODY with the locale set to LOCALE-NAME.

Note that changing the locale modifies settings that affect the display, such as terminal-coding-system and standard-display-table, but this macro does not by itself perform redisplay. If BODY needs to display something with LOCALE-NAME's settings, include a call to redraw-frame in BODY.

Probably introduced at or before Emacs version 29.1.

Source Code

;; Defined in /usr/src/emacs/lisp/international/mule-cmds.el.gz
(defmacro with-locale-environment (locale-name &rest body)
  "Execute BODY with the locale set to LOCALE-NAME.

Note that changing the locale modifies settings that affect
the display, such as `terminal-coding-system' and `standard-display-table',
but this macro does not by itself perform redisplay.  If BODY needs to
display something with LOCALE-NAME's settings, include a call
to `redraw-frame' in BODY."
  (declare (indent 1) (debug (sexp def-body)))
  (cl-with-gensyms (current)
    `(let ((,current current-locale-environment))
       (unwind-protect
           (progn
             (set-locale-environment ,locale-name nil t)
             ,@body)
         (set-locale-environment ,current nil t)))))