ah Lee wrote:
Suggestions on Emacs's Scratch Buffer.
pasted below my sig
Could you give a summary english what does your changes achieve at the
or how it differs from the proposal and the code that comes with it?
Thanks for your code. I see even C code... i don't know C.
On Sep 27, 5:42 am, Cheta< < XXXX@XXXXX.COM >t> wrote:
Here are my changes.
;;; Buffer created by this function is a temp buffer. It has no auto-
save. It is saved by
;;; save-some-buffers only with prefix argument, will not be saved by
M-x compile etc.
(defun create-new-buffer(name &optional scratch)
"Generate a new buffer with the specified name in default major
mode. There is no auto save for this buffer until a file name is
specified. The optional argument scratch specifies if the buffer is
for scratch purposes and will not be deleted."
(let ((buf (generate-new-buffer name)))
(setq buffer-offer-save (not scratch))))
;;; save-some-buffers C-x s will not save it
;;; save-buffer C-x C-s will ask for a file name if not specified
;;; no auto save since there is no recovery
(defun new-buffer(&optional name mode)
"Create a new buffer that can be saved later to a file."
(let ((default-major-mode (or mode 'text-mode)))
(create-new-buffer (or (stringp name) "Untitled")))
(add-hook 'kill-buffer-query-functions 'buffer-kill-query nil t))
(defun new-scratch-buffer(&optional arg)
"Create a new temporary buffer."
(create-new-buffer "*scratch*" t))
(defun choice (msg possibilities)
(let ((cursor-in-echo-area t) nmsg answer)
(while (not (memq answer possibilities))
(setq nmsg (format "%s [%s] " msg
(mapconcat (function (lambda(x) (char-to-
string (downcase x)))) possibilities "/")))
(message "%s" (propertize nmsg 'face 'minibuffer-prompt))
(setq answer (capitalize (read-char-exclusive))))
(setq answer (capitalize (string-to-char (read-from-
(defun buffer-kill-choice (msg)
(let ((possibilities (list ?C ?K ?S)) answer ev)
(setq answer (choice msg possibilities))
(cond ((eq answer ?C) (message "Buffer retained.") nil)
((eq answer ?K) t)
((eq answer ?S) (save-buffer) t))))
(defun buffer-kill-query ()
(cond ((and buffer-offer-save
(cond ((and (null buffer-file-name)
>(> (buffer-size) 0))
(buffer-kill-choice (format "Buffer %s has not been
saved to a file. Cancel/Kill/Save?"
(when (featurep 'menu-bar)
(list (list 'new-buffer
"Create New Buffer"
:help "Create a new buffer and select it
in the current window")))))
Diff -U3 from 22.3 version of file
@@ -90,9 +90,8 @