From 58f1e33a5210b385d37d9d01b106f0b67ae5d054 Mon Sep 17 00:00:00 2001 From: myuhe Date: Sat, 3 Aug 2013 15:57:40 +0900 Subject: [PATCH 1/2] Add scratch-log-start --- scratch-log.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scratch-log.el b/scratch-log.el index 2d779b6..cdd1aa5 100644 --- a/scratch-log.el +++ b/scratch-log.el @@ -87,8 +87,8 @@ (insert-file-contents sl-prev-scratch-string-file) (or (not (eq (point-max) scratch-point-max)) (not (eq (compare-buffer-substrings - (current-buffer) 0 (point-max) - it 0 scratch-point-max) + (current-buffer) (point-min) (point-max) + it (point-min) scratch-point-max) 0))))))) (defun sl-make-prev-scratch-string-file () @@ -113,13 +113,17 @@ (defun sl-scratch-buffer-p () (if (string= "*scratch*" (buffer-name)) nil t)) -(add-hook 'kill-buffer-hook 'sl-dump-scratch-when-kill-buf) -(add-hook 'kill-emacs-hook 'sl-dump-scratch-when-kill-emacs) -(add-hook 'emacs-startup-hook 'sl-restore-scratch) -(when sl-prohibit-kill-scratch-buffer-p - (add-hook 'kill-buffer-query-functions 'sl-scratch-buffer-p)) -(when sl-use-timer - (run-with-idle-timer sl-timer-interval t 'sl-dump-scratch-for-timer)) + +;;;###autoload +(defun scratch-log-start () + (interactive) + (add-hook 'kill-buffer-hook 'sl-dump-scratch-when-kill-buf) + (add-hook 'kill-emacs-hook 'sl-dump-scratch-when-kill-emacs) + (add-hook 'emacs-startup-hook 'sl-restore-scratch) + (when sl-prohibit-kill-scratch-buffer-p + (add-hook 'kill-buffer-query-functions 'sl-scratch-buffer-p)) + (when sl-use-timer + (run-with-idle-timer sl-timer-interval t 'sl-dump-scratch-for-timer))) ;;;; Bug report (defvar scratch-log-maintainer-mail-address From 17640452ae940e48cb10b9025fcbfb09486dcf87 Mon Sep 17 00:00:00 2001 From: myuhe Date: Sat, 3 Aug 2013 16:34:02 +0900 Subject: [PATCH 2/2] Remove add-hook --- scratch-log.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scratch-log.el b/scratch-log.el index cdd1aa5..ea87a80 100644 --- a/scratch-log.el +++ b/scratch-log.el @@ -114,12 +114,14 @@ (if (string= "*scratch*" (buffer-name)) nil t)) +(add-hook 'kill-buffer-hook 'sl-dump-scratch-when-kill-buf) +(add-hook 'kill-emacs-hook 'sl-dump-scratch-when-kill-emacs) +(add-hook 'emacs-startup-hook 'sl-restore-scratch) + + ;;;###autoload (defun scratch-log-start () (interactive) - (add-hook 'kill-buffer-hook 'sl-dump-scratch-when-kill-buf) - (add-hook 'kill-emacs-hook 'sl-dump-scratch-when-kill-emacs) - (add-hook 'emacs-startup-hook 'sl-restore-scratch) (when sl-prohibit-kill-scratch-buffer-p (add-hook 'kill-buffer-query-functions 'sl-scratch-buffer-p)) (when sl-use-timer