Skip to content

Commit

Permalink
fix(core): fix persistent scratch hooks/functions
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 14, 2023
1 parent e2ad2ea commit 309e5a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions core/me-loaddefs.el
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,17 @@ Return a scratchpad buffer in major MODE.
(fn &optional DONT-RESTORE-P MODE DIRECTORY PROJECT-NAME)")
(autoload '+scratch-persist-buffer-h "../elisp/+scratch" "\
Save the current buffer to `+scratch-dir'.")
Save the current buffer to `+scratch-dir'.
(fn &rest _)")
(autoload '+scratch-persist-buffers-h "../elisp/+scratch" "\
Save all scratch buffers to `+scratch-dir'.")
Save all scratch buffers to `+scratch-dir'.
(fn &rest _)")
(autoload '+scratch-persist-buffers-after-switch-h "../elisp/+scratch" "\
Kill scratch buffers when they are no longer visible, saving them to disk.")
Kill scratch buffers when they are no longer visible, saving them to disk.
(fn &rest _)")
(unless noninteractive (add-hook 'kill-emacs-hook #'+scratch-persist-buffers-h))
(autoload '+scratch-open-buffer "../elisp/+scratch" "\
Pop up a persistent scratch buffer.
Expand Down
6 changes: 3 additions & 3 deletions elisp/+scratch.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ the first, fresh scratch buffer you create. This accepts:
;;; Persistent scratch buffer

;;;###autoload
(defun +scratch-persist-buffer-h ()
(defun +scratch-persist-buffer-h (&rest _)
"Save the current buffer to `+scratch-dir'."
(let ((content (buffer-substring-no-properties (point-min) (point-max)))
(point (point))
Expand All @@ -97,7 +97,7 @@ the first, fresh scratch buffer you create. This accepts:
(current-buffer)))))

;;;###autoload
(defun +scratch-persist-buffers-h ()
(defun +scratch-persist-buffers-h (&rest _)
"Save all scratch buffers to `+scratch-dir'."
(setq +scratch-buffers
(cl-delete-if-not #'buffer-live-p +scratch-buffers))
Expand All @@ -106,7 +106,7 @@ the first, fresh scratch buffer you create. This accepts:
(+scratch-persist-buffer-h))))

;;;###autoload
(defun +scratch-persist-buffers-after-switch-h ()
(defun +scratch-persist-buffers-after-switch-h (&rest _)
"Kill scratch buffers when they are no longer visible, saving them to disk."
(unless (cl-some #'get-buffer-window +scratch-buffers)
(mapc #'kill-buffer +scratch-buffers)
Expand Down

0 comments on commit 309e5a5

Please sign in to comment.