Skip to content

Commit

Permalink
Imporoved `elscreen' support
Browse files Browse the repository at this point in the history
  • Loading branch information
elim committed Jun 5, 2012
1 parent a5108f5 commit 0277a00
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions auto-save-buffers-enhanced.el
Expand Up @@ -138,6 +138,9 @@ not CVS or Subversion.")
"*If non-nil, *scratch* buffer will be saved into the file same
as other normal files.")

(defvar auto-save-buffers-enhanced-cooperate-elscreen-p nil
"*If non-nil, insert scratch data to elscreen default window.")

(defvar auto-save-buffers-enhanced-file-related-with-scratch-buffer
(expand-file-name "~/.scratch")
"*File which scratch buffer to be save into.")
Expand All @@ -158,7 +161,9 @@ auto-saving."
(run-with-idle-timer
auto-save-buffers-enhanced-interval t 'auto-save-buffers-enhanced-save-buffers))
(when auto-save-buffers-enhanced-save-scratch-buffer-to-file-p
(add-hook 'after-init-hook 'auto-save-buffers-enhanced-scratch-read-after-init-hook)))
(add-hook 'after-init-hook 'auto-save-buffers-enhanced-scratch-read-after-init-hook))
(when auto-save-buffers-enhanced-cooperate-elscreen-p
(add-hook 'elscreen-create-hook 'auto-save-buffers-enhanced-cooperate-elscreen-default-window)))

(defun auto-save-buffers-enhanced-scratch-read-after-init-hook ()
(let ((scratch-buf (get-buffer "*scratch*")))
Expand All @@ -167,6 +172,9 @@ auto-saving."
(erase-buffer)
(insert-file-contents auto-save-buffers-enhanced-file-related-with-scratch-buffer)))))

(defalias 'auto-save-buffers-enhanced-cooperate-elscreen-default-window
'auto-save-buffers-enhanced-scratch-read-after-init-hook)

(defun auto-save-buffers-enhanced-include-only-checkout-path (flag)
"If `flag' is non-nil, `auto-save-buffers-enhanced' saves only
the directories under VCS."
Expand Down Expand Up @@ -217,13 +225,19 @@ the directories under VCS."
auto-save-buffers-enhanced-exclude-regexps buffer-file-name))
(file-writable-p buffer-file-name))
(save-buffer)
(progn
(when (and auto-save-buffers-enhanced-save-scratch-buffer-to-file-p
(equal buffer (get-buffer "*scratch*"))
(buffer-modified-p)
(not (string= initial-scratch-message (buffer-string))))
(write-file auto-save-buffers-enhanced-file-related-with-scratch-buffer nil)))
))))
(when (and auto-save-buffers-enhanced-save-scratch-buffer-to-file-p
(equal buffer (get-buffer "*scratch*"))
(buffer-modified-p)
(not (string= initial-scratch-message (buffer-string))))
(let
((scratch-buffer-string (buffer-string)))
(progn
(with-temp-buffer
(insert scratch-buffer-string)
(write-region nil nil
auto-save-buffers-enhanced-file-related-with-scratch-buffer
nil -1))
(set-buffer-modified-p nil))))))))

;;;; Internal Functions
;;;; -------------------------------------------------------------------------
Expand Down

0 comments on commit 0277a00

Please sign in to comment.