diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2024-05-16 19:37:42 +0100 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2024-05-16 19:38:47 +0100 |
commit | b1a366cfcd66e09f95230f077af821389ff74917 (patch) | |
tree | 7c52d3a9dc77c28adba86cb67f57f90de45c5b49 | |
parent | d3a9d5237d46e908352957e7ec409aef73fab6aa (diff) | |
download | dotfiles-b1a366cfcd66e09f95230f077af821389ff74917.tar.gz |
spw/perltidy-region: use process-environment rather than setenv
-rw-r--r-- | .emacs.d/init.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 89644aa1..b3e79bef 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -5620,16 +5620,15 @@ We don't use the FILES parameter in the entry for \"d\" in (defun spw/perltidy-region (begin end) (interactive "r") - (let ((perltidy-env (getenv "PERLTIDY"))) - (setenv "PERLTIDY" - (or (concat (expand-file-name - (locate-dominating-file - (buffer-file-name) - ".perltidyrc")) ".perltidyrc") - perltidy-env)) - (shell-command-on-region begin end "perltidy -q" nil t) - (font-lock-ensure) - (setenv "PERLTIDY" perltidy-env))) + (let* ((dominating (locate-dominating-file default-directory ".perltidyrc")) + (process-environment + (if dominating + (cons (format "PERLTIDY=%s" + (expand-file-name ".perltidyrc" dominating)) + process-environment) + process-environment))) + (shell-command-on-region begin end "perltidy -q" nil t)) + (font-lock-ensure)) ;; an older version of this would use the region if it's active, but that ;; rarely produces good results -- perltidy would get the indentation wrong |