Skip to content

Commit

Permalink
Initialize local scratch buffers with a major mode
Browse files Browse the repository at this point in the history
  • Loading branch information
florommel committed Nov 30, 2023
1 parent ea61e1f commit 9fd36ab
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bufferlo.el
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ For example, create a dedicated local scratch buffer for all tabs and frames:
You can set this to \"*scratch*\"."
:type 'string)

(defcustom bufferlo-local-scratch-buffer-initial-major-mode nil
"The initial major mode for local scratch buffers.
If nil, the local scratch buffers' major mode is set to `initial-major-mode'."
:type 'function)

(defvar bufferlo--desktop-advice-active nil)
(defvar bufferlo--desktop-advice-active-force nil)

Expand Down Expand Up @@ -623,9 +628,15 @@ This is like `bufferlo-find-buffer' but additionally selects the buffer."
"\\(<[0-9]*>\\)?$")
(buffer-name b)))
(bufferlo-buffer-list nil nil t))))
(or buffer
(get-buffer-create
(generate-new-buffer-name bufferlo-local-scratch-buffer-name)))))
(unless buffer
(setq buffer (get-buffer-create
(generate-new-buffer-name bufferlo-local-scratch-buffer-name)))
(with-current-buffer buffer
(when (eq major-mode 'fundamental-mode)
(funcall (or bufferlo-local-scratch-buffer-initial-major-mode
initial-major-mode
#'ignore)))))
buffer))

(defun bufferlo-create-local-scratch-buffer ()
"Create a local scratch buffer and return it."
Expand Down

0 comments on commit 9fd36ab

Please sign in to comment.