Skip to content

Commit

Permalink
Add auto-start support
Browse files Browse the repository at this point in the history
  • Loading branch information
seblemaguer committed Dec 3, 2017
1 parent da9ab59 commit e3bf2e6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions prodigy.el
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ The list is a property list with the following properties:
Call this function with (service, output), each time process gets
new output.
`auto-start'
Autostart the service
`ready-message'
The text that a service displays when it is ready. Will be
matched as a regexp.")
Expand All @@ -236,6 +239,7 @@ these (see `prodigy-services' doc-string for more information):
* `kill-process-buffer-on-stop'
* `on-output'
* `truncate-output'
* `auto-start'
These properties are also valid for a tag:
Expand Down Expand Up @@ -1200,6 +1204,14 @@ started."
(prodigy-with-refresh
(-each (prodigy-relevant-services) 'prodigy-start-service)))


(defun prodigy-start-auto-start-service (service)
"Start service if indicated as auto-service."
(interactive)
(prodigy-with-refresh
(when (plist-get service :auto-start)
(prodigy-start-service service))))

(defun prodigy-stop (&optional force)
"Stop service at line or marked services.
Expand Down Expand Up @@ -1427,6 +1439,31 @@ beginning of the line."
(font-lock-mode 1)
(use-local-map prodigy-view-mode-map))


;;;###autoload
(defun prodigy-auto-start ()
"Start service at line or marked services."
(interactive)
(let ((saved-buffer (current-buffer))
(buffer-p (prodigy-buffer))
(buffer (get-buffer-create prodigy-buffer-name)))

(set-buffer buffer)
(unless buffer-p
(prodigy-mode))
(prodigy-start-status-check-timer)

;; And now start the services
(prodigy-with-refresh
(progn
(prodigy-mark-all)
(-each (prodigy-relevant-services) 'prodigy-start-auto-start-service)
(prodigy-unmark-all)))

;; Go back to the previous one
(set-buffer saved-buffer)))


;;;###autoload
(defun prodigy ()
"Manage external services from within Emacs."
Expand Down

0 comments on commit e3bf2e6

Please sign in to comment.