From 986331f3a36eac5bafd5ce5681bf299594703bc1 Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Sun, 8 Mar 2026 21:22:29 +0100 Subject: [PATCH] Use with-locale-environment if defined else use current locale --- man/.dir-locals.el | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/man/.dir-locals.el b/man/.dir-locals.el index 61756c53..4ef27bb0 100644 --- a/man/.dir-locals.el +++ b/man/.dir-locals.el @@ -1,20 +1,24 @@ ((texinfo-mode . ((before-save-hook . (lambda () - (with-locale-environment "en_US.utf8" - (let ((day (string-trim (format-time-string "%e" (current-time)))) - (month (capitalize (format-time-string "%B" (current-time)))) - (year (format-time-string "%Y" (current-time)))) - (save-excursion - (goto-char (point-min)) - (when (re-search-forward "\\(@set UPDATED [[:word:]]+ [[:digit:]]+, [[:digit:]]+\\)" nil t) - (replace-match (format "@set UPDATED %s %s, %s" month day year) nil t nil nil)) - (goto-char (point-min)) - (when (re-search-forward "\\(@set UPDATED-MONTH [[:word:]]+ [[:digit:]]+\\)" nil t) - (replace-match (format "@set UPDATED-MONTH %s %s" month year) nil t nil nil)) - (goto-char (point-min)) - (when (re-search-forward "\\(Printed [[:word:]]+ [[:digit:]]+, [[:digit:]]+\.\\)" nil t) - (replace-match (format "Printed %s %s, %s." month day year) nil t nil nil)) - (goto-char (point-min)) - (when (re-search-forward "\\([[:word:]]+ [[:digit:]]+, [[:digit:]]+ @c AUTO-REPLACE-ON-SAVE\\)" nil t) - (replace-match (format "%s %s, %s @c AUTO-REPLACE-ON-SAVE" month day year) nil t nil nil)))))))))) + (let ((our-set-env + (lambda () (let ((day (string-trim (format-time-string "%e" (current-time)))) + (month (capitalize (format-time-string "%B" (current-time)))) + (year (format-time-string "%Y" (current-time)))) + (save-excursion + (goto-char (point-min)) + (when (re-search-forward "\\(@set UPDATED [[:word:]]+ [[:digit:]]+, [[:digit:]]+\\)" nil t) + (replace-match (format "@set UPDATED %s %s, %s" month day year) nil t nil nil)) + (goto-char (point-min)) + (when (re-search-forward "\\(@set UPDATED-MONTH [[:word:]]+ [[:digit:]]+\\)" nil t) + (replace-match (format "@set UPDATED-MONTH %s %s" month year) nil t nil nil)) + (goto-char (point-min)) + (when (re-search-forward "\\(Printed [[:word:]]+ [[:digit:]]+, [[:digit:]]+\.\\)" nil t) + (replace-match (format "Printed %s %s, %s." month day year) nil t nil nil)) + (goto-char (point-min)) + (when (re-search-forward "\\([[:word:]]+ [[:digit:]]+, [[:digit:]]+ @c AUTO-REPLACE-ON-SAVE\\)" nil t) + (replace-match (format "%s %s, %s @c AUTO-REPLACE-ON-SAVE" month day year) nil t nil nil))))))) + (if (fboundp 'with-locale-environment) + (with-locale-environment "en_US.utf8" + (funcall our-set-env)) + (funcall our-set-env))))))))