A minor mode for Emacs to build and deploy FRC robot code under GradleRIO.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
;;; frc-mode.el --- Emacs integration with WPILib+GradleRIO -*- lexical-binding: t -*-
;; Copyright (C) 2020 by Hazel Levine
;; Author: Hazel Levine <email@example.com>
;; Maintainer: Hazel Levine <firstname.lastname@example.org>
;; URL: https://github.com/ralsei/frc-mode
;; Version: 0.0.1
;; Keywords: gradle, robotics, first
;; Package-Requires: ((s "1.12.0") (projectile "2.1.0"))
;; This file is NOT part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; Emacs integration with WPILib + GradleRIO via compile-mode and projectile.
(defun frc-is-frc-project (dir)
"Determines if this DIR is a valid WPILib 2019+ project.
Due to the way WPILib under Visual Studio Code functions, this insists that
gradlew exists. More complex setups may cause this to break."
(and (file-exists-p (expand-file-name "build.gradle" dir))
(file-exists-p (expand-file-name "gradlew" dir))
(defun frc-kill-compilation-buffer ()
"Kill the compile buffer."
(if (get-buffer "*compilation*")
(delete-windows-on (get-buffer "*compilation*"))
(defun frc-run-gradlew (params)
"Run gradlew with the parameters or tasks PARAMS."
(if (not (projectile-project-root))
(error "Not a projectile project!")
(if (not (frc-is-frc-project (projectile-project-root)))
(error "Not an FRC project!")))
(let ((default-directory (projectile-project-root)))
(compile (s-join " " (list "./gradlew" params)))))
;;; INTERACTIVE FUNCTIONS
(defun frc-build ()
"Build the robot code without deploying it to the roboRIO."
(defun frc-deploy ()
"Build the robot code and deploy it to the roboRIO."
(defun frc-execute (params)
"Execute gradlew with the tasks specified by PARAMS."
(interactive "sType gradlew parameters: ")
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-f b") 'frc-build)
(define-key map (kbd "C-c C-f d") 'frc-deploy)
(define-key map (kbd "C-c C-f r") 'frc-execute)
"Keymap for FRC minor mode.")
"Emacs minor mode for integration with WPILib and GradleRIO."
:lighter " FRC"
;;; frc-mode.el ends here