Update elisp/arch-ros2.el

This commit is contained in:
Alexander Rosenberg 2025-02-20 20:28:42 -08:00
parent 0fd70fb03c
commit 2d072241a7
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -83,9 +83,17 @@ This will prepend the values to VAR."
(setenv var (string-join (seq-difference parts (cdr entry)) ":"))))) (setenv var (string-join (seq-difference parts (cdr entry)) ":")))))
(remhash var arch-ros2--saved-env-vars))) (remhash var arch-ros2--saved-env-vars)))
(defmacro arch-ros2-with-modify-global-env (&rest body)
"Execute BODY, modifying the default toplevel `process-environment'."
`(let ((process-environment (default-toplevel-value 'process-environment)))
(unwind-protect
(progn ,@body)
(set-default-toplevel-value 'process-environment process-environment))))
(defun arch-ros2-activate () (defun arch-ros2-activate ()
"Activate a ROS2 development environment." "Activate a ROS2 development environment."
(interactive) (interactive)
(arch-ros2-with-modify-global-env
(setq arch-ros2-active t) (setq arch-ros2-active t)
(add-to-list 'mode-line-misc-info arch-ros2-mode-line-format) (add-to-list 'mode-line-misc-info arch-ros2-mode-line-format)
(arch-ros2--add-to-path "/opt/ros/humble/bin/") (arch-ros2--add-to-path "/opt/ros/humble/bin/")
@ -111,11 +119,12 @@ This will prepend the values to VAR."
arch-ros2-root))) arch-ros2-root)))
(arch-ros2--add-file-to-var "PYTHONPATH" (arch-ros2--add-file-to-var "PYTHONPATH"
(expand-file-name "dist-packages" python-dir) (expand-file-name "dist-packages" python-dir)
(expand-file-name "site-packages" python-dir)))) (expand-file-name "site-packages" python-dir)))))
(defun arch-ros2-deactivate () (defun arch-ros2-deactivate ()
"Deactivate the ROS2 development environment." "Deactivate the ROS2 development environment."
(interactive) (interactive)
(arch-ros2-with-modify-global-env
(setq arch-ros2-active nil (setq arch-ros2-active nil
mode-line-misc-info (cl-remove arch-ros2-mode-line-format mode-line-misc-info (cl-remove arch-ros2-mode-line-format
mode-line-misc-info mode-line-misc-info
@ -127,7 +136,7 @@ This will prepend the values to VAR."
((eq k 'exec-path) ((eq k 'exec-path)
(setq exec-path (seq-difference exec-path v)) (setq exec-path (seq-difference exec-path v))
(remhash 'exec-path arch-ros2--saved-env-vars)))) (remhash 'exec-path arch-ros2--saved-env-vars))))
arch-ros2--saved-env-vars)) arch-ros2--saved-env-vars)))
(provide 'arch-ros2) (provide 'arch-ros2)
;;; arch-ros2.el ends here ;;; arch-ros2.el ends here