[Have been using Emacs for at least 40 years, but still ...] What to put in .emacs so that Emacs opens in text mode?

I have tried:

(setq initial-major-mode #'text-mode)
(setq default-major-mode #'text-mode)
(setq-default major-mode #'text-mode)
(setq major-mode #'text-mode)

I use: GNU Emacs 22.2.1 GNU Emacs 25.1.1

They open always with Lisp Interaction mode. No need to tell me that I can use: M-x text-mode. And opening a file with a .txt extension. So?

  • Say what you mean by open in ___ mode. By default, the *scratch* buffer is in Lisp Interaction Mode. Is that what you're asking about - how to have that buffer use some other mode? "Emacs" doesn't start in a mode. A minor mode can be global, so I suppose you could say that Emacs is in such a mode, if it's turned on. But major modes are for buffers.
    – Drew
    Jul 21, 2020 at 22:45
  • So far, your question is not very clear. Try providing a step-by-step recipe to repro the problem, saying just what you see at each step and what you want to see instead.
    – Drew
    Jul 21, 2020 at 22:46
  • Phew. I do not want to type meta-x text-mode to obtain text-mode. Now clear?
    – DdC
    Jul 21, 2020 at 22:52
  • The mode you get when you open Emacs without specifying any file is unrelated to the mode you get after opening a .txt file. Typing M-x foo-mode just before you open a file has no effect on the mode you get for that file. By default after you open a .txt file, you should be in text-mode. If that's not the case for you, then there's something funny going on (e.g. in your ~/.emacs).
    – Stefan
    Jul 22, 2020 at 13:41

1 Answer 1


Put this at the end of your configuration file:

(setq initial-major-mode 'text-mode)

I see that you have tried putting it in your .emacs but it could be the case that it is somewhat dependent on where you put it. I tried putting this at either end of my .emacs and both worked. The *scratch* buffer is in text-mode. If you continue to have problems, try using the customisation system to change the value of initial-major-mode. Easy way to get there is C-h v initial-major-mode then take the option to customise this variable.

  • 1
    Thanks a LOT for the advice. No success when putting that line at the end of .emacs. Regarding the approach to customize with: C-h v initial-major-mode: No idea how that works. I suspect that 'M-x text-mode' triggers something like: (foo 'text-mode) If so, what is foo?
    – DdC
    Jul 22, 2020 at 1:09
  • Yes, I get the scratch buffer. The major mode is (Lisp Interaction) - assuming that is what you ask. Still no idea what is your "C-h v initial-major-mode", especially "C-h". Moreover I want to put something in .emacs so that I do not have to type "M-x text-mode' when the scratch buffer has ALWAYS (Lisp Interaction).
    – DdC
    Jul 22, 2020 at 1:47
  • Thanks again!! Per your advice I made a .emacs file with only: "(setq initial-major-mode 'text-mode)" This produced a buffer with (Emacs-Lisp). Downloaded emacs 26.3. This produced a buffer with (Fundamental). It does read .emacs because it also accepts (display-time). This is all happening on window 7 & 8 and ALSO on my ubuntu box. Baffled now.
    – DdC
    Jul 22, 2020 at 16:45
  • Problem SOLVED. I was changing the file _emacs instead of .emacs. [Somehow one had to use _emacs in a deep past.] OK now on XP, W7, W8 & ubuntu - with YOUR line. Thanks a LOT.
    – DdC
    Jul 22, 2020 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.