[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bufferlo 9fd36ab644 1/2: Initialize local scratch buffe
From: |
ELPA Syncer |
Subject: |
[elpa] externals/bufferlo 9fd36ab644 1/2: Initialize local scratch buffers with a major mode |
Date: |
Thu, 30 Nov 2023 18:57:33 -0500 (EST) |
branch: externals/bufferlo
commit 9fd36ab6442ba2b1f4bddc4aaa5f0560fc3a44b6
Author: Florian Rommel <mail@florommel.de>
Commit: Florian Rommel <mail@florommel.de>
Initialize local scratch buffers with a major mode
---
bufferlo.el | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/bufferlo.el b/bufferlo.el
index aa4df519d5..8a7dd5fad1 100644
--- a/bufferlo.el
+++ b/bufferlo.el
@@ -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)
@@ -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."