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'.
This commit is contained in:
Stefan Kangas 2024-12-27 05:02:55 +01:00
parent 577714e3fe
commit 4f942b4994
4 changed files with 6 additions and 9 deletions

View file

@ -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)

View file

@ -1020,8 +1020,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

View file

@ -9103,9 +9103,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))

View file

@ -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))