This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Emacs frontend automatically launches session

  • Loading branch information...
technomancy committed Jul 25, 2008
1 parent 23ef0a9 commit cd330288158ab770c2cceded89c873e2e33766ca
Showing with 22 additions and 15 deletions.
  1. +2 −1 lib/conspire.rb
  2. +20 −14 lib/conspire/support/conspire.el
View
@@ -11,7 +11,7 @@
module Conspire
VERSION = '0.1.0'
DEFAULTS = { :port => 7456, :name => 'conspiracy', :sync_interval => 0.5 }
- HOSTNAME = `hostname`.chomp
+ HOSTNAME = `hostname`.chomp # TODO: is there a better way?
@conspirators = Set.new
@@ -22,6 +22,7 @@ def start(path, options)
@options = options
@path = path
Gitjour::Application.init @path
+ FileUtils.touch(@path + '/.git/conspire')
@thread = Thread.new do
Gitjour::Application.serve(@path, @options.name, @options.port)
end
@@ -40,36 +40,42 @@
;;; TODO:
;; Automatically launch conspire executable.
+;; Don't bother with *Async Shell Command* output buffer
;; Color lines based on which conspirator wrote them?
;;; Code:
-(defvar conspire-interval 0.33
+(defvar conspire-interval 0.25
"Number of seconds to wait before syncing with conspire.")
(defvar conspire-timer nil
"A timer to activate conspire synchronizing.")
-(make-variable-buffer-local 'conspire-mode)
-
-;;;###autoload
-(defun conspire-mode ()
- "Activate conspire-mode for real-time collaborative editing."
- (interactive)
- (setq conspire-mode t)
- (setq conspire-timer
- (run-with-idle-timer conspire-interval :repeat 'conspire-sync-buffer)))
-
-
(defun conspire-sync-buffer ()
"Synchronize buffer with Conspire repository."
(when conspire-mode
(when (buffer-modified-p)
(save-buffer)
(shell-command (format "git add %s && git commit -m \"conspire\""
buffer-file-name)))
- (revert-buffer nil t)
- ;; revert resets local variables; heh
+ (revert-buffer nil t) ;; revert resets local variables; heh
(setq conspire-mode t)))
+;;;###autoload
+(define-minor-mode conspire-mode
+ "Toggle conspire-mode for real-time collaborative editing.
+
+If the current buffer isn't part of a conspiracy session, a new
+session will be started."
+ :lighter "-conspire"
+ (unless (file-exists-p (concat (file-name-directory buffer-file-name)
+ ".git/conspire"))
+ (shell-command (format "conspire %s >& /dev/null &"
+ (file-name-directory buffer-file-name))))
+ (setq conspire-timer
+ (or conspire-timer
+ (run-with-idle-timer conspire-interval :repeat
+ 'conspire-sync-buffer))))
+
+(provide 'conspire)
;;; conspire.el ends here

0 comments on commit cd33028

Please sign in to comment.