Skip to content

Commit ea9ab4c

Browse files
committed
tweak(core): minor tweak and documentation change
1 parent 99645cf commit ea9ab4c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/me-lib.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,16 +1981,18 @@ If prefix ARG, delete all persistent scratches."
19811981
(message "Successfully deleted %S" (abbreviate-file-name file))))))
19821982

19831983
(defun +scratch-replace-with-persistent-scratch (&optional arg project-p)
1984-
"Replace the *scratch* buffer with a persistent one."
1984+
"Replace the *scratch* buffer with a persistent one.
1985+
1986+
ARG and PROJECT-P are passed to `+scratch-open-buffer'."
19851987
(interactive "P")
19861988
(when-let ((buf (current-buffer))
19871989
(s (get-buffer "*scratch*")))
19881990
;; Load the default persistent scratch buffer
19891991
(+scratch-open-buffer arg project-p 'same-window)
19901992
;; Kill the Emacs' default scratch buffer
19911993
(kill-buffer s)
1992-
;; Switch to the previous buffer
1993-
(when (and (buffer-live-p buf) (string-match-p (rx bol (not " ")) (buffer-name buf)))
1994+
;; Switch to the previous buffer, unless it has been killed (we was in *scratch*) or it is a hidden buffer
1995+
(when (and (buffer-live-p buf) (string-match-p "^[^ ]" (buffer-name buf)))
19941996
(switch-to-buffer buf))))
19951997

19961998
(with-eval-after-load 'project

0 commit comments

Comments
 (0)