Update elisp/arch-ros2.el
This commit is contained in:
		@ -83,51 +83,60 @@ This will prepend the values to VAR."
 | 
			
		||||
         (setenv var (string-join (seq-difference parts (cdr entry)) ":")))))
 | 
			
		||||
    (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 ()
 | 
			
		||||
  "Activate a ROS2 development environment."
 | 
			
		||||
  (interactive)
 | 
			
		||||
  (setq arch-ros2-active t)
 | 
			
		||||
  (add-to-list 'mode-line-misc-info arch-ros2-mode-line-format)
 | 
			
		||||
  (arch-ros2--add-to-path "/opt/ros/humble/bin/")
 | 
			
		||||
  (arch-ros2--set-env-var "AMENT_PREFIX_PATH" arch-ros2-root)
 | 
			
		||||
  (arch-ros2--set-env-var "CMAKE_PREFIX_PATH" arch-ros2-root)
 | 
			
		||||
  (arch-ros2--set-env-var "COLCON_PREFIX_PATH" arch-ros2-root)
 | 
			
		||||
  (arch-ros2--set-env-var "ROS_DISTRO" arch-ros2-distro)
 | 
			
		||||
  (arch-ros2--set-env-var "ROS_LOCALHOST_ONLY" "0")
 | 
			
		||||
  (arch-ros2--set-env-var "ROS_PYTHON_VERSION"
 | 
			
		||||
                          (car (split-string arch-ros2-python-version "\\.")))
 | 
			
		||||
  (arch-ros2--set-env-var "ROS_VERSION"
 | 
			
		||||
                          (number-to-string arch-ros2-version))
 | 
			
		||||
  (arch-ros2--add-file-to-var
 | 
			
		||||
   "LD_LIBRARY_PATH"
 | 
			
		||||
   (expand-file-name "opt/rviz_ogre_vendor/lib"
 | 
			
		||||
                     arch-ros2-root)
 | 
			
		||||
   (expand-file-name "lib"
 | 
			
		||||
                     arch-ros2-root))
 | 
			
		||||
  (arch-ros2--add-file-to-var
 | 
			
		||||
   "PKG_CONFIG_PATH" (expand-file-name "lib/pkgconfig" arch-ros2-root))
 | 
			
		||||
  (let ((python-dir (expand-file-name
 | 
			
		||||
                     (concat "lib/python" arch-ros2-python-version)
 | 
			
		||||
                     arch-ros2-root)))
 | 
			
		||||
    (arch-ros2--add-file-to-var "PYTHONPATH"
 | 
			
		||||
                                (expand-file-name "dist-packages" python-dir)
 | 
			
		||||
                                (expand-file-name "site-packages" python-dir))))
 | 
			
		||||
  (arch-ros2-with-modify-global-env
 | 
			
		||||
   (setq arch-ros2-active t)
 | 
			
		||||
   (add-to-list 'mode-line-misc-info arch-ros2-mode-line-format)
 | 
			
		||||
   (arch-ros2--add-to-path "/opt/ros/humble/bin/")
 | 
			
		||||
   (arch-ros2--set-env-var "AMENT_PREFIX_PATH" arch-ros2-root)
 | 
			
		||||
   (arch-ros2--set-env-var "CMAKE_PREFIX_PATH" arch-ros2-root)
 | 
			
		||||
   (arch-ros2--set-env-var "COLCON_PREFIX_PATH" arch-ros2-root)
 | 
			
		||||
   (arch-ros2--set-env-var "ROS_DISTRO" arch-ros2-distro)
 | 
			
		||||
   (arch-ros2--set-env-var "ROS_LOCALHOST_ONLY" "0")
 | 
			
		||||
   (arch-ros2--set-env-var "ROS_PYTHON_VERSION"
 | 
			
		||||
                           (car (split-string arch-ros2-python-version "\\.")))
 | 
			
		||||
   (arch-ros2--set-env-var "ROS_VERSION"
 | 
			
		||||
                           (number-to-string arch-ros2-version))
 | 
			
		||||
   (arch-ros2--add-file-to-var
 | 
			
		||||
    "LD_LIBRARY_PATH"
 | 
			
		||||
    (expand-file-name "opt/rviz_ogre_vendor/lib"
 | 
			
		||||
                      arch-ros2-root)
 | 
			
		||||
    (expand-file-name "lib"
 | 
			
		||||
                      arch-ros2-root))
 | 
			
		||||
   (arch-ros2--add-file-to-var
 | 
			
		||||
    "PKG_CONFIG_PATH" (expand-file-name "lib/pkgconfig" arch-ros2-root))
 | 
			
		||||
   (let ((python-dir (expand-file-name
 | 
			
		||||
                      (concat "lib/python" arch-ros2-python-version)
 | 
			
		||||
                      arch-ros2-root)))
 | 
			
		||||
     (arch-ros2--add-file-to-var "PYTHONPATH"
 | 
			
		||||
                                 (expand-file-name "dist-packages" python-dir)
 | 
			
		||||
                                 (expand-file-name "site-packages" python-dir)))))
 | 
			
		||||
 | 
			
		||||
(defun arch-ros2-deactivate ()
 | 
			
		||||
  "Deactivate the ROS2 development environment."
 | 
			
		||||
  (interactive)
 | 
			
		||||
  (setq arch-ros2-active nil
 | 
			
		||||
        mode-line-misc-info (cl-remove arch-ros2-mode-line-format
 | 
			
		||||
                                       mode-line-misc-info
 | 
			
		||||
                                       :test 'equal))
 | 
			
		||||
  (maphash (lambda (k v)
 | 
			
		||||
             (cond
 | 
			
		||||
              ((stringp k)
 | 
			
		||||
               (arch-ros2--restore-env-var k))
 | 
			
		||||
              ((eq k 'exec-path)
 | 
			
		||||
               (setq exec-path (seq-difference exec-path v))
 | 
			
		||||
               (remhash 'exec-path arch-ros2--saved-env-vars))))
 | 
			
		||||
           arch-ros2--saved-env-vars))
 | 
			
		||||
  (arch-ros2-with-modify-global-env
 | 
			
		||||
   (setq arch-ros2-active nil
 | 
			
		||||
         mode-line-misc-info (cl-remove arch-ros2-mode-line-format
 | 
			
		||||
                                        mode-line-misc-info
 | 
			
		||||
                                        :test 'equal))
 | 
			
		||||
   (maphash (lambda (k v)
 | 
			
		||||
              (cond
 | 
			
		||||
               ((stringp k)
 | 
			
		||||
                (arch-ros2--restore-env-var k))
 | 
			
		||||
               ((eq k 'exec-path)
 | 
			
		||||
                (setq exec-path (seq-difference exec-path v))
 | 
			
		||||
                (remhash 'exec-path arch-ros2--saved-env-vars))))
 | 
			
		||||
            arch-ros2--saved-env-vars)))
 | 
			
		||||
 | 
			
		||||
(provide 'arch-ros2)
 | 
			
		||||
;;; arch-ros2.el ends here
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user