From dec79825baf9cbd07f9cf5e8533897f53c436a26 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 31 Oct 2023 09:22:28 +0200 Subject: [PATCH] Fix project-mode-line-format breaking buffer-file-coding-system (bug#66825) * lisp/progmodes/project.el (project-mode-line-format): Let-bind 'last-coding-system-used' to prevent changing 'buffer-file-coding-system' in 'basic-save-buffer'. --- lisp/progmodes/project.el | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index bb44cfefa54..580394a22ed 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -2074,14 +2074,21 @@ is part of the default mode line beginning with Emacs 30." (defun project-mode-line-format () "Compose the project mode-line." (when-let ((project (project-current))) - (concat - " " - (propertize - (project-name project) - 'face project-mode-line-face - 'mouse-face 'mode-line-highlight - 'help-echo "mouse-1: Project menu" - 'local-map project-mode-line-map)))) + ;; Preserve the global value of 'last-coding-system-used' + ;; that 'write-region' needs to set for 'basic-save-buffer', + ;; but updating the mode line might occur at the same time + ;; during saving the buffer and 'project-name' can change + ;; 'last-coding-system-used' when reading the project name + ;; from .dir-locals.el also enables flyspell-mode (bug#66825). + (let ((last-coding-system-used last-coding-system-used)) + (concat + " " + (propertize + (project-name project) + 'face project-mode-line-face + 'mouse-face 'mode-line-highlight + 'help-echo "mouse-1: Project menu" + 'local-map project-mode-line-map))))) (provide 'project) ;;; project.el ends here -- 2.39.2