Skip to content

Instantly share code, notes, and snippets.

@the-frey
Created September 5, 2019 11:33
Show Gist options
  • Save the-frey/ce724b55e0e21c43afd7fb1358ba6875 to your computer and use it in GitHub Desktop.
Save the-frey/ce724b55e0e21c43afd7fb1358ba6875 to your computer and use it in GitHub Desktop.
Some stuff for indenting properly
;; adapted from http://blog.binchen.org/posts/easy-indentation-setup-in-emacs-for-web-development.html
(defun setup-indent (n)
;; java/c/c++
(setq-local c-basic-offset n)
;; web development
(setq-local coffee-tab-width n) ; coffeescript
(setq-local javascript-indent-level n) ; javascript-mode
(setq-local js-indent-level n) ; js-mode
(setq-local js2-basic-offset n) ; js2-mode, in latest js2-mode, it's alias of js-indent-level
(setq-local web-mode-markup-indent-offset n) ; web-mode, html tag in html file
(setq-local web-mode-css-indent-offset n) ; web-mode, css in html file
(setq-local web-mode-code-indent-offset n) ; web-mode, js code in html file
(setq-local css-indent-offset n) ; css-mode
)
(defun set-indent-style ()
(interactive)
(message "Spaces, 2 per tab")
;; use space instead of tab
(setq indent-tabs-mode nil)
;; indent 2 spaces width
(setup-indent 2))
(set-indent-style)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment