Skip to content

Commit

Permalink
Merge pull request #3 from brotzeit/babel
Browse files Browse the repository at this point in the history
add spinner for rustic babel processes
  • Loading branch information
brotzeit authored Jul 26, 2018
2 parents 5b27d62 + 70d3c6b commit 797a400
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Cask
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
42 changes: 41 additions & 1 deletion rustic-babel.el
Original file line number Diff line number Diff line change
Expand Up @@ -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'."
Expand Down Expand Up @@ -160,12 +162,50 @@ 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)
(setq rustic-babel-src-location (set-marker
(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
2 changes: 1 addition & 1 deletion rustic.el
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 797a400

Please sign in to comment.