summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2024-05-16 19:37:42 +0100
committerSean Whitton <spwhitton@spwhitton.name>2024-05-16 19:38:47 +0100
commitb1a366cfcd66e09f95230f077af821389ff74917 (patch)
tree7c52d3a9dc77c28adba86cb67f57f90de45c5b49
parentd3a9d5237d46e908352957e7ec409aef73fab6aa (diff)
downloaddotfiles-b1a366cfcd66e09f95230f077af821389ff74917.tar.gz
spw/perltidy-region: use process-environment rather than setenv
-rw-r--r--.emacs.d/init.el19
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