5 votes
Accepted

"Dissasociate" auto-mode for specific files (in ESS)

The issue is mostly caused by autoloads. In julia-mode.el you can see that (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode)) is marked as to be autoloaded. If you were to look at ~/.emacs.d/...
  • 2,036
5 votes
Accepted

does one has to explicity enable python-mode etc. to work with python files?

python-mode.el (from https://gitlab.com/python-mode-devs/python-mode) has more "bells-and-whistles" than python.el (included with Emacs). Things like better integration with IPython and auto-...
  • 2,368
4 votes
Accepted

How do I associate a file such as git's `COMMIT_EDITMSG` with a specific mode?

(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist)) That \\.md should be \\.md\\' otherwise it'll match every filename containing the sequence .md anywhere. (I.e. You ...
  • 44.3k
3 votes
Accepted

How to enable a major + a minor mode on loading a file?

To use rainbow-mode in clojure-mode only under a certain directory, add a .dir-locals.el file to the directory, containing: ((clojure-mode . ((eval . (rainbow-mode 1))))) You can also use M-x add-dir-...
  • 44.3k
3 votes

Enable diff-mode for files with diff-ish content

C-h v magic-mode-alist says this: magic-mode-alist is a variable defined in files.el. Its value is nil This variable can be risky when used as a file-local variable. Documentation: ...
  • 71k
3 votes

Do m-x command on entering buffer with a specific file type

The usual mechanism is called a hook: a hook is a variable containing a list of functions, and when the hook is run, every function in the list is executed. Every major mode has an associated hook ...
  • 21.2k
2 votes

How to make Emacs edit JSON data in `json-mode`?

Install json-mode might be the simplest. In my set up (I use straight.el) simply (use-package json-mode)
  • 758
2 votes
Accepted

Is There a Way To Set "Lisp-Interaction-Mode" to be Default?

Update auto-mode-alist, to give it an association between *.el and lisp-interaction-mode. (add-to-list 'auto-mode-alist (cons "\\.el\\'" #'lisp-interaction-mode)) See the Elisp manual, node Auto ...
  • 71k
2 votes
Accepted

Using two programming languages with the same file extension

You're lucky that the files for the different languages are segregated by directory like that. You can define directory-local values for variable auto-mode-alist. See the Elisp manual, node Directory ...
  • 71k
2 votes
Accepted

How can I make sure that Emacs opens files with extension `*.rec` as normal text files?

To tell Emacs that *.rec files should be opened in text-mode: (add-to-list 'auto-mode-alist '("\\.rec\\'" . text-mode))
  • 44.3k
2 votes

Trim a suffix before applying auto-mode-alist

M-x elisp-index-search RET auto-mode-alist says: When you visit a file whose expanded file name (*note File Name Expansion::), with version numbers and backup suffixes removed using ‘file-name-sans-...
  • 44.3k
1 vote

When is the major-mode assigned to an input file determined by its file extension?

One question per question, if you see what I am saying. Emacs calls normal-mode after opening the file, which determines what mode it should be in and changes to it. You can actually call it yourself ...
  • 12.6k
1 vote
Accepted

`use-package` :defer prevents :mode from actually inserting something in auto-mode-alist

The culprit was quack, which overwrote auto-mode-alist to prefer scheme-mode to racket-mode when opening .rkt files. Disabling it worked perfectly.
1 vote
Accepted

same files.el.gz, different auto-mode-alist

I don't know how Debian does things, but... auto-mode-alist is a variable, and (as with any variable) any and all elisp code may modify that value. files.el merely defines its default value. What ...
  • 44.3k
1 vote

How can I make sure that Emacs opens files with extension `*.rec` as normal text files?

Use M-x find-file-literally Emacs will use fundamental-mode as the major mode. Then change to txt mode.

Only top scored, non community-wiki answers of a minimum length are eligible