Search code examples
emacsdebianindentationauto-indent

Emacs bad auto indent on Debian 9


I've installed a fresh Debian 9 Stretch and Emacs GNU Emacs 24.5.1and when i tried to paste a docker-compose.yml from github (raw mode) into a emacs file with or without an extension (yml, conf, etc...) there is no auto indent and this is what I have:

enter image description here

There is my .emacs file

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq c-basic-offset 4)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))))

and this is the link to the file https://raw.githubusercontent.com/plexinc/pms-docker/master/docker-compose-bridge.yml.template


Solution

  • as Drew said on his answer : https://emacs.stackexchange.com/a/5941

    Disable electric-indent-mode:

    (when (fboundp 'electric-indent-mode) (electric-indent-mode -1)) That works with any Emacs version. This annoyance or shiny-new-feature, depending on your point of view, was introduced as the default in Emacs 24.4.