diff --git a/Cask b/Cask index faf002db..dcf9c834 100644 --- a/Cask +++ b/Cask @@ -9,7 +9,8 @@ (depends-on "f" "0.18.2") (depends-on "projectile" "0.14.0") (depends-on "markdown-mode" "2.3") - +(depends-on "spinner" "1.7.3") + (development (depends-on "ert-runner") (depends-on "f")) \ No newline at end of file diff --git a/rustic-babel.el b/rustic-babel.el index 732b1fd8..3fc812c4 100644 --- a/rustic-babel.el +++ b/rustic-babel.el @@ -110,7 +110,9 @@ execution with rustfmt." (org-babel-update-block-body (with-current-buffer "rustic-babel-format-buffer" (buffer-string))))))) - (kill-buffer "rustic-babel-format-buffer"))) + (kill-buffer "rustic-babel-format-buffer")) + (rustic-babel-stop-spinner) + (setq mode-line-process nil)) (defun rustic-babel-generate-project () "Create rust project in `org-babel-temporary-directory'." @@ -160,6 +162,10 @@ execution with rustfmt." (rustic-babel-cargo-toml dir params) (setq rustic-info (org-babel-get-src-block-info)) (setq rustic-babel-params params) + (setq mode-line-process + '(rustic-babel-spinner + (":Executing " (:eval (spinner-print rustic-babel-spinner))))) + (rustic-babel-start-spinner) (let ((default-directory dir)) (write-region (concat "#![allow(non_snake_case)]\n" body) nil main nil 0) (rustic-babel-eval dir) @@ -167,5 +173,39 @@ execution with rustfmt." (make-marker) (point) (current-buffer))) project))) + +;;;;;;;;;;;; +;; Spinner + +(defvar rustic-babel-spinner nil) + +(eval-and-compile (require 'spinner)) +(defcustom rustic-babel-spinner-type 'horizontal-moving + "Holds the type of spinner to be used in the mode-line. +Takes a value accepted by `spinner-start'." + :type `(choice (choice :tag "Choose a spinner by name" + ,@(mapcar (lambda (c) (list 'const (car c))) + spinner-types)) + (const :tag "A random spinner" random) + (repeat :tag "A list of symbols from `spinner-types' to randomly choose from" + (choice :tag "Choose a spinner by name" + ,@(mapcar (lambda (c) (list 'const (car c))) + spinner-types))) + (vector :tag "A user defined vector" + (repeat :inline t string))) + :group 'rustic-babel) + +(defun rustic-babel-start-spinner () + (when (spinner-p rustic-babel-spinner) + (spinner-stop rustic-babel-spinner)) + (setq rustic-babel-spinner + (make-spinner rustic-babel-spinner-type t 10)) + (spinner-start rustic-babel-spinner)) + +(defun rustic-babel-stop-spinner () + (when (spinner-p rustic-babel-spinner) + (spinner-stop rustic-babel-spinner)) + (setq rustic-babel-spinner nil)) + (provide 'rustic-babel) ;;; rustic-babel.el ends here diff --git a/rustic.el b/rustic.el index 30684277..89ee918c 100644 --- a/rustic.el +++ b/rustic.el @@ -4,7 +4,7 @@ ;; Author: Mozilla ;; ;; Keywords: languages -;; Package-Requires: ((emacs "26.1") (xterm-color "1.6") (dash "2.13.0") (s "1.10.0") (f "0.18.2") (projectile "0.14.0") (markdown-mode "2.3")) +;; Package-Requires: ((emacs "26.1") (xterm-color "1.6") (dash "2.13.0") (s "1.10.0") (f "0.18.2") (projectile "0.14.0") (markdown-mode "2.3") (spinner "1.7.3")) ;; This file is distributed under the terms of both the MIT license and the ;; Apache License (version 2.0).