Skip to content

Commit d7637cd

Browse files
authored
Merge pull request #892 from rswgnu/pr_fix_dir_locales_for_emacs_28
Use with-locale-environment if defined else use current locale
2 parents 7fdc937 + 986331f commit d7637cd

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

man/.dir-locals.el

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
((texinfo-mode
22
. ((before-save-hook
33
. (lambda ()
4-
(with-locale-environment "en_US.utf8"
5-
(let ((day (string-trim (format-time-string "%e" (current-time))))
6-
(month (capitalize (format-time-string "%B" (current-time))))
7-
(year (format-time-string "%Y" (current-time))))
8-
(save-excursion
9-
(goto-char (point-min))
10-
(when (re-search-forward "\\(@set UPDATED [[:word:]]+ [[:digit:]]+, [[:digit:]]+\\)" nil t)
11-
(replace-match (format "@set UPDATED %s %s, %s" month day year) nil t nil nil))
12-
(goto-char (point-min))
13-
(when (re-search-forward "\\(@set UPDATED-MONTH [[:word:]]+ [[:digit:]]+\\)" nil t)
14-
(replace-match (format "@set UPDATED-MONTH %s %s" month year) nil t nil nil))
15-
(goto-char (point-min))
16-
(when (re-search-forward "\\(Printed [[:word:]]+ [[:digit:]]+, [[:digit:]]+\.\\)" nil t)
17-
(replace-match (format "Printed %s %s, %s." month day year) nil t nil nil))
18-
(goto-char (point-min))
19-
(when (re-search-forward "\\([[:word:]]+ [[:digit:]]+, [[:digit:]]+ @c AUTO-REPLACE-ON-SAVE\\)" nil t)
20-
(replace-match (format "%s %s, %s @c AUTO-REPLACE-ON-SAVE" month day year) nil t nil nil))))))))))
4+
(let ((our-set-env
5+
(lambda () (let ((day (string-trim (format-time-string "%e" (current-time))))
6+
(month (capitalize (format-time-string "%B" (current-time))))
7+
(year (format-time-string "%Y" (current-time))))
8+
(save-excursion
9+
(goto-char (point-min))
10+
(when (re-search-forward "\\(@set UPDATED [[:word:]]+ [[:digit:]]+, [[:digit:]]+\\)" nil t)
11+
(replace-match (format "@set UPDATED %s %s, %s" month day year) nil t nil nil))
12+
(goto-char (point-min))
13+
(when (re-search-forward "\\(@set UPDATED-MONTH [[:word:]]+ [[:digit:]]+\\)" nil t)
14+
(replace-match (format "@set UPDATED-MONTH %s %s" month year) nil t nil nil))
15+
(goto-char (point-min))
16+
(when (re-search-forward "\\(Printed [[:word:]]+ [[:digit:]]+, [[:digit:]]+\.\\)" nil t)
17+
(replace-match (format "Printed %s %s, %s." month day year) nil t nil nil))
18+
(goto-char (point-min))
19+
(when (re-search-forward "\\([[:word:]]+ [[:digit:]]+, [[:digit:]]+ @c AUTO-REPLACE-ON-SAVE\\)" nil t)
20+
(replace-match (format "%s %s, %s @c AUTO-REPLACE-ON-SAVE" month day year) nil t nil nil)))))))
21+
(if (fboundp 'with-locale-environment)
22+
(with-locale-environment "en_US.utf8"
23+
(funcall our-set-env))
24+
(funcall our-set-env))))))))

0 commit comments

Comments
 (0)