help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get rid of *GNU Emacs* buffer on start-up?


From: Chetan
Subject: Re: How to get rid of *GNU Emacs* buffer on start-up?
Date: Sat, 27 Sep 2008 05:42:23 -0700
User-agent: Emacs Gnus

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)))
    (set-buffer-major-mode buf)
    (switch-to-buffer buf)
    (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."
  (interactive)
  (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."
  (interactive)
  (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 "/")))
      (cond (t
             (message "%s" (propertize nmsg 'face 'minibuffer-prompt))
             (setq answer (capitalize (read-char-exclusive))))
            (nil
             (setq answer (capitalize (string-to-char (read-from-minibuffer 
nmsg)))))))
    answer))

(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
                (buffer-modified-p))
           (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?"
                                              (buffer-name))))
                 (t t)))
          (t t)))

(when (featurep 'menu-bar)
  (setq menu-bar-buffers-menu-command-entries
        (append menu-bar-buffers-menu-command-entries
                (list (list 'new-buffer
                            'menu-item
                            "Create New Buffer"
                            'new-buffer
                            :help "Create a new buffer and select it in the 
current window")))))

;;; end

===============
Diff -U3 from 22.3 version of file

--- simple.org.el       
+++ simple.el   
@@ -90,9 +90,8 @@
                             buffer visible-ok frame)
       (get-next-valid-buffer (nreverse (buffer-list frame))
                             buffer visible-ok frame)
-      (progn
-       (set-buffer-major-mode (get-buffer-create "*scratch*"))
-       (get-buffer "*scratch*"))))
+      (get-buffer "*scratch*")
+      (current-buffer)))
 
 (defun next-buffer ()
   "Switch to the next buffer in cyclic order."

===============
File buffer.c function Fother_buffer.

  if (NILP (buf))
    {
#if 0
      buf = Fget_buffer_create (build_string ("*scratch*"));
      Fset_buffer_major_mode (buf);
#else
      buf = buffer;
#endif
    }
  return buf;
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]