Skip to content

Instantly share code, notes, and snippets.

@danilomo
Last active March 1, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danilomo/07779d8cf28e067f47ee98f1c3432583 to your computer and use it in GitHub Desktop.
Save danilomo/07779d8cf28e067f47ee98f1c3432583 to your computer and use it in GitHub Desktop.
.emacs with a new untitled buffer in text mode and *GNU Emacs* and *scratch* killed
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(defun xah-new-empty-buffer ()
"Create a new empty buffer.
New buffer will be named “untitled” or “untitled<2>”, “untitled<3>”, etc.
It returns the buffer (for elisp programing).
URL `http://ergoemacs.org/emacs/emacs_new_empty_buffer.html'
Version 2017-11-01"
(interactive)
(let (($buf (generate-new-buffer "untitled")))
(switch-to-buffer $buf)
(funcall initial-major-mode)
(setq buffer-offer-save t)
$buf
))
(defun buffer-hook-function ()
(when (equal (format "%s" (buffer-list)) *default-buffer-list*)
(remove-hook 'buffer-list-update-hook 'buffer-hook-function)
(init-emacs-custom)
)
)
(defun init-emacs-custom ()
(kill-buffer "*GNU Emacs*")
(kill-buffer "*scratch*")
(let ((b (xah-new-empty-buffer)))
(set-buffer b)
)
(text-mode)
)
(setq *default-buffer-list* "(*GNU Emacs* *scratch* *Minibuf-0* *Messages* *code-conversion-work* *Echo Area 0* *Echo Area 1*)")
(add-hook 'buffer-list-update-hook 'buffer-hook-function)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment