0

Here is a simple Emacs config file:

(menu-bar-mode -1) 
(tool-bar-mode -1) 
(scroll-bar-mode -1) 
(desktop-save-mode 1)

The toolbar should not appear, right? From some reason, it does. But if I remove the (desktop-save-mode 1) line, the toolbar does disappear.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • 1
    close Emacs. delete your existing `.emacs.desktop` file. start Emacs again. – nega Apr 29 '23 at 18:23
  • @nega Good idea. I tried it --> did not help. – Refael Sheinker Apr 29 '23 at 18:34
  • Then it's possibly something in your config. Using only those 4 lines as my `init.el` I can 1) mimic your behavior 2) confirm @NickD 's hypothesis and 3) correct the mis-behavior by removing the `.emacs.desktop` file. – nega Apr 29 '23 at 18:37
  • 1
    @nega I had 2 different .emacs.desktop files. I don know why. One is at ~/.config/emcas/ and the other at ~/.emacs.d/. When I deleted the second one, everything started working as expected. Thank you very much, Please make it an answer and I will accept it. – Refael Sheinker Apr 29 '23 at 18:46
  • 1
    glad you found it – nega Apr 29 '23 at 18:59

2 Answers2

2

My guess is that you ran a session with tool-bar-mode on and desktop-save-mode on. When you exited that session, a desktop file was saved and that desktop file included tool-bar-mode on. Now you add the three lines to turn off the three modes (but you don't turn off tool-bar-mode explicitly in the session) and you restart emacs. The init file turns off the three modes to begin with and then restores the desktop from the saved desktop file, which turns on tool-bar-mode since it is part of what was saved. And since it's on in this new session, it will be saved in the desktop file when you exit and the process will be repeated ad infinitum,

My suggestion is to change the order: enable desktop-save-mode first so that the desktop file will be read to setup the current session, then turn off the three modes in the current session. That way, they will be off when the desktop file is saved at the end of the session and when emacs is restarted they are not going to be part of the saved configuration, thereby breaking the cycle.

I have not tested any of this and I don't really know what desktop-save-mode saves, so this may be wrong, but it looks plausible to me. If you put the (desktop-save-mode 1) first, do you still see the problem?

NickD
  • 27,023
  • 3
  • 23
  • 42
2

Quit Emacs. Find and delete your .emacs.desktop file(s). Restart Emacs.

There maybe more than one .emacs.desktop file depending on what your current state was when you last saved. Check ~/.emacs.d/.emacs.desktop or in your working directory.

nega
  • 3,091
  • 15
  • 21