9

If I type emacs test.sh Emacs insists on putting me in Shell-script mode. Another time I want to edit the file help.txt and then Emacs puts me in Text mode. But sometimes I don't want any of this, especially when I am doing a large paste into Emacs from some other source.

How do I start Emacs in "nothing" mode? No special indenting, spacing, etc., and Emacs simply takes the characters in as they are entered.

UPDATE: Here is an example. Copy the following text to your clipboard, open emacs (even in fundamental mode) and paste.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 ID="FARM20190311T2248"
 Name="https://www.example.com/"
 entityID="https://www.example.com/" validUntil="2020-03-11T22:48:12Z"><ds:Signature>
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>

Emacs insists on changing the spacing (even in fundamental mode and using -q) to this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 ID="FARM20190311T2248"
  Name="https://www.example.com/"
   entityID="https://www.example.com/" validUntil="2020-03-11T22:48:12Z"><ds:Signature>
   <ds:SignedInfo>
   <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>

Try the same experiment with vi or nano. Those programs (at least on my computer) do not change the spacing.

I am using GNU Emacs 24.5.1 on Debian stretch.

  • "Emacs [24.5.1] insists on changing the spacing (even in fundamental mode and using -q)" -- I cannot reproduce that in Emacs 25.3 or 26.1. Test again with emacs -Q to ensure Debian hasn't installed some site-lisp which is causing this? If that doesn't change things, try a newer version of Emacs? – phils Mar 30 at 23:53
  • 1
    It sounds like your real question is asked and answered here: emacs.stackexchange.com/questions/28008/… – npostavs Mar 31 at 2:57
15

When you use M-x find-file-literally Emacs will not invoke a mode that is based on the file name. Instead, it uses fundamental-mode as the major mode.

From the command line you can use something like this:

emacs --eval '(find-file-literally "yourfile.ext")'
  • This does not solve my problem. I have clarified the issue with an example. – rlandster Mar 30 at 21:37
11

Emacs modes are established for each file you open, so opening Emacs in "nothing mode" doesn't necessarily accomplish what you're after. Each file you open after starting Emacs will get its own mode applied.

You can use the command @clemera provides to open a file in fundamental mode from the command line. You can do the same from an already-running Emacs via M-x find-file-literally. You can "turn-off" the major mode for a file you've already opened by selecting fundamental mode (which is basically "nothing mode"): M-x fundamental-mode

6

I'm running:
GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-08-26, modified by Debian

$ emacs yourfile.txt --eval '(fundamental-mode)'

You have to put the --eval after the file name or it appears to set the mode based on the file name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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