From: Stefan Kangas Date: Fri, 27 Dec 2024 04:02:55 +0000 (+0100) Subject: Use with-environment-variables in more places X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3343d43ef3871a4279e59045d7f31a35d3ce3892;p=emacs.git Use with-environment-variables in more places * lisp/gnus/gnus-search.el (gnus-search-run-search): * lisp/man.el (Man-completion-table): * lisp/progmodes/cperl-mode.el (cperl-pod-to-manpage): * test/src/fileio-tests.el (fileio-tests--relative-HOME): Prefer 'with-environment-variables'. (cherry picked from commit 4f942b4994df82b9ba7ee10a75008b2338e38fc3) --- diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index c25163ac770..30f971721f7 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -1591,8 +1591,7 @@ fudges a relevancy score of 100." ;; I can't tell if this is actually necessary. (cl-defmethod gnus-search-run-search :around ((_e gnus-search-namazu) _server _query _groups) - (let ((process-environment (copy-sequence process-environment))) - (setenv "LC_MESSAGES" "C") + (with-environment-variables (("LC_MESSAGES" "C")) (cl-call-next-method))) (cl-defmethod gnus-search-indexed-search-command ((engine gnus-search-namazu) diff --git a/lisp/man.el b/lisp/man.el index 4b20aec1bbf..f7bbe9e8ce2 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -1019,8 +1019,8 @@ foo(sec)[, bar(sec) [, ...]] [other stuff] - description" ;; whereas under macOS it seems to be BRE-style and doesn't ;; accept backslashes at all. Let's not bother to ;; quote anything. - (let ((process-environment (copy-sequence process-environment))) - (setenv "COLUMNS" "999") ;; don't truncate long names + (with-environment-variables + (("COLUMNS" "999")) ; don't truncate long names ;; manual-program might not even exist. And since it's ;; run differently in Man-getpage-in-background, an error ;; here may not necessarily mean that we'll also get an diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index f8e565eb8f7..ba78f66c652 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -9094,9 +9094,8 @@ the appropriate statement modifier." (bufname (concat "Man " buffer-file-name)) (buffer (generate-new-buffer bufname))) (with-current-buffer buffer - (let ((process-environment (copy-sequence process-environment))) - ;; Prevent any attempt to use display terminal fanciness. - (setenv "TERM" "dumb") + ;; Prevent any attempt to use display terminal fanciness. + (with-environment-variables (("TERM" "dumb")) (set-process-sentinel (start-process pod2man-program buffer "sh" "-c" (format (cperl-pod2man-build-command) pod2man-args)) diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 750de8444c9..29177fee7ad 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -100,8 +100,7 @@ Also check that an encoding error can appear in a symlink." (ert-deftest fileio-tests--relative-HOME () "Test that `expand-file-name' works even when HOME is relative." - (let ((process-environment (copy-sequence process-environment))) - (setenv "HOME" "a/b/c") + (with-environment-variables (("HOME" "a/b/c")) (should (equal (expand-file-name "~/foo") (expand-file-name "a/b/c/foo"))) (when (memq system-type '(ms-dos windows-nt))