spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

Add option to disable spacemacs buffer on startup

Open padde opened this issue 8 years ago • 21 comments

I would like to have just a scratch buffer on startup, and it seems this cannot be achieved easily at the moment. Currently I am using the following workaround:

(defun dotspacemacs/user-config ()
  ;; ...
  (when (string= "*scratch*" (buffer-name))
    (spacemacs/switch-to-scratch-buffer))
  )

However, it would be nice to be able to disable it altogether with a proper configuration option. This way I wouldn't have to wait for the spacemacs buffer to be built and displayed, just to discard it immediately.

padde avatar Aug 23 '16 14:08 padde

For everyone who are confused, the key point is to not switch buffer if Emacs is called with filename arguments.

TheBB avatar Aug 23 '16 14:08 TheBB

+1 on that @TheBB - I like the home buffer if I'm starting without arguments.

vaz avatar Aug 24 '16 05:08 vaz

Edit file ~/.emacs.d/core/core-spacemacs.el Comment out the following lines:

  (setq inhibit-startup-screen t)
  (spacemacs-buffer/goto-buffer)

to

(setq inhibit-startup-screen nil)
;; (setq inhibit-startup-screen t)
;;  (spacemacs-buffer/goto-buffer)

ginhton avatar Jun 07 '17 14:06 ginhton

Any update on this? So far the code from @padde is the only way I can avoid a brief flashing of the big *spacemacs* buffer when launching emacsclient from command line. Assuming the *scratch* buffer is blank.

lzhang10 avatar Aug 24 '17 13:08 lzhang10

What about this?

(defun dotspacemacs/user-config ()
  (kill-buffer "*spacemacs*"))

tasmo avatar Feb 10 '18 19:02 tasmo

This worked https://github.com/syl20bnr/spacemacs/issues/6899#issuecomment-306805429 Thanks @ginhton

P.S. Remember to restart the daemon if a daemon is in use!

thammegowda avatar Mar 16 '18 21:03 thammegowda

add this at dotspacemacs/user-config

 (add-hook 'server-switch-hook (lambda nil ( (kill-buffer "*scratch*"))))

jiahut avatar Apr 04 '18 10:04 jiahut

@ginhton this worked, thanks! But has a warning:

Warning (initialization): An error occurred while loading ‘/home/lee/.emacs.d/init.el’:

Search failed: Search in Spacemacs]

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

And when start emacs with --debug-init, this warn disappeared

lixianyang avatar May 03 '18 06:05 lixianyang

@tasmo's comment seem to do it for me - would love a built in option

diego898 avatar Aug 30 '18 21:08 diego898

I'm thinking, an spacemacs varibale should be provied that spacemacs buffer shoulnd't be created during startup, this will descrease the time of startup of spacemacs.

c02y avatar May 17 '19 07:05 c02y

This snippet makes *scratch* the initial buffer instead:

(defun dotspacemacs/user-config ()
  (setq initial-buffer-choice (lambda () (get-buffer "*scratch*"))))

Mic92 avatar Feb 05 '20 15:02 Mic92

Mic92's suggestion doesn't seem to be working for me. The Spacemacs buffer is still shown on startup.

The variables value after starting says:

initial-buffer-choice is a variable defined in ‘startup.el’. Its value is (closure (t) nil (get-buffer "scratch")) Original value was nil

Windows 1903
#### System Info :computer:
- OS: windows-nt
- Emacs: 26.3
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 7f92a4388)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(autohotkey auto-completion command-log emacs-lisp git github helm imenu-list markdown multiple-cursors org
            (shell :variables shell-default-shell 'shell shell-default-height 30 shell-default-position 'bottom)
            spell-checking syntax-checking treemacs version-control)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2

duianto avatar Feb 07 '20 10:02 duianto

Mic92's suggestion doesn't seem to be working for me

Are you running emacs in daemon/server mode by chance?

peterhoeg avatar Feb 11 '20 12:02 peterhoeg

@peterhoeg Yes. I do: https://github.com/Mic92/dotfiles/blob/master/nixpkgs-config/emacs.nix#L74

Mic92 avatar Feb 11 '20 14:02 Mic92

Are you running emacs in daemon/server mode by chance?

That first test wasn't with a running as a daemon/server setup.

But now when starting: emacs --daemon and: emacsclient -c Then a Spacemacs frame opens at the scratch buffer.

duianto avatar Feb 14 '20 21:02 duianto

Redefining the following 2 functions in your .spacemacs file removes the startup screen

(defun spacemacs-buffer/goto-buffer (&optional refresh))
(defun spacemacs-buffer/display-startup-note ())
(defun spacemacs-buffer//startup-hook ())

That being said, they are the 3 functions that would need to be investigated to disable this functionality via a variable.

russell avatar Aug 25 '20 05:08 russell

Thanks @russell ....

That worked for me like a champ!

susoooo avatar Apr 22 '21 15:04 susoooo

Thanks @russell, this also worked for me :)

ghost avatar Nov 28 '21 02:11 ghost

@russell solution gives me a warning... Error (use-package): vi-tilde-fringe/:init: No buffer named *spacemacs*

GiulioCocconi avatar Dec 10 '21 08:12 GiulioCocconi

In my case I solved it by inserting the definitions in the init.el file, otherwise I got an error during the startup:

(if (not (version<= spacemacs-emacs-min-version emacs-version))
    (error (concat "Your version of Emacs (%s) is too old. "
                   "Spacemacs requires Emacs version %s or above.")
           emacs-version spacemacs-emacs-min-version)
  ;; Disable file-name-handlers for a speed boost during init
  (let ((file-name-handler-alist nil))
    (require 'core-spacemacs)
    (defun spacemacs-buffer/goto-buffer (&optional refresh))

    ;; here the new redefined functions
    (defun spacemacs-buffer/display-startup-note ())
    (defun spacemacs-buffer//startup-hook ())
    (spacemacs/dump-restore-load-path)

    (configuration-layer/load-lock-file)
    (spacemacs/init)
    (configuration-layer/stable-elpa-init)
    (configuration-layer/load)
    (spacemacs-buffer/display-startup-note)
    (spacemacs/setup-startup-hook)
    (spacemacs/dump-eval-delayed-functions)
    (when (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p)))
      (require 'server)
      (when dotspacemacs-server-socket-dir
        (setq server-socket-dir dotspacemacs-server-socket-dir))
      (unless (server-running-p)
        (message "Starting a server...")
        (server-start)))))

rkachach avatar Feb 14 '22 21:02 rkachach

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

github-actions[bot] avatar May 01 '24 16:05 github-actions[bot]