From b858acde25160631ce7e0e13adc579ca1a4135fb Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 30 Sep 2022 16:14:20 +0200 Subject: [PATCH] Don't refresh the frame in with-locale-environment * lisp/international/mule-cmds.el (with-locale-environment): Inhibit refresh so that there's no flickering (bug#58193). (set-locale-environment): Allow inhibiting the refresh. * lisp/international/mule.el (set-terminal-coding-system): Ditto. --- lisp/international/mule-cmds.el | 13 ++++++++----- lisp/international/mule.el | 11 ++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index e1d0df6e3ed..51147943dc2 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2666,11 +2666,11 @@ For example, translate \"swedish\" into \"sv_SE.ISO8859-1\"." `(let ((,current current-locale-environment)) (unwind-protect (progn - (set-locale-environment ,locale-name) + (set-locale-environment ,locale-name nil t) ,@body) - (set-locale-environment ,current))))) + (set-locale-environment ,current nil t))))) -(defun set-locale-environment (&optional locale-name frame) +(defun set-locale-environment (&optional locale-name frame inhibit-refresh) "Set up multilingual environment for using LOCALE-NAME. This sets the language environment, the coding system priority, the default input method and sometimes other things. @@ -2699,6 +2699,9 @@ This function sets the `current-locale-environment' variable. To change the locale temporarily, `with-locale-environment' can be used. +By default, this function will redraw the current frame. If +INHIBIT-REFRESH is non-nil, this isn't done. + See also `locale-charset-language-names', `locale-language-names', `locale-preferred-coding-systems' and `locale-coding-system'." (interactive (list (completing-read "Set environment for locale: " @@ -2865,7 +2868,7 @@ See also `locale-charset-language-names', `locale-language-names', (or output-coding (setq output-coding code-page-coding)) (unless frame (setq locale-coding-system locale-coding)) (set-keyboard-coding-system code-page-coding frame) - (set-terminal-coding-system output-coding frame) + (set-terminal-coding-system output-coding frame inhibit-refresh) (setq default-file-name-coding-system ansi-code-page-coding)))) (when (eq system-type 'darwin) @@ -2876,7 +2879,7 @@ See also `locale-charset-language-names', `locale-language-names', ;; the locale. (when (and (null window-system) (equal (getenv "TERM_PROGRAM" frame) "Apple_Terminal")) - (set-terminal-coding-system 'utf-8) + (set-terminal-coding-system 'utf-8 nil inhibit-refresh) (set-keyboard-coding-system 'utf-8))) ;; Default to A4 paper if we're not in a C, POSIX or US locale. diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 5cca5bf707e..7aa6e68103d 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -1362,7 +1362,8 @@ to CODING-SYSTEM." This is normally set according to the selected language environment. See also the command `set-terminal-coding-system'.") -(defun set-terminal-coding-system (coding-system &optional terminal) +(defun set-terminal-coding-system (coding-system &optional terminal + inhibit-refresh) "Set coding system of terminal output to CODING-SYSTEM. All text output to TERMINAL will be encoded with the specified coding system. @@ -1373,7 +1374,10 @@ or by the previous use of this command. TERMINAL may be a terminal object, a frame, or nil for the selected frame's terminal. The setting has no effect on -graphical terminals." +graphical terminals. + +By default, this function will redraw the current frame. If +INHIBIT-REFRESH is non-nil, this isn't done." (interactive (list (let ((default (if (and (not (terminal-coding-system)) default-terminal-coding-system) @@ -1387,7 +1391,8 @@ graphical terminals." (if coding-system (setq default-terminal-coding-system coding-system)) (set-terminal-coding-system-internal coding-system terminal) - (redraw-frame)) + (unless inhibit-refresh + (redraw-frame))) (defvar default-keyboard-coding-system nil "Default value of the keyboard coding system. -- 2.39.2