defunkt / coffee-mode

Emacs Major Mode for CoffeeScript
http://ozmm.org/posts/coffee_mode.html
574 stars 147 forks source link

have a different first indent width (eg for litcoffee) #279

Open hans-d opened 9 years ago

hans-d commented 9 years ago

AFAIK the current indent/tab width is the same for every level.

My normal indent is 2 spaces. When writing litcoffee, I would like to use as first indent 4 (or more) spaces, to make it more distinct from the markdown text.

syohex commented 9 years ago
(defun my/coffee-indent-line ()
  (interactive)
  (if (zerop (current-column))
      (insert "    ")
    (call-interactively 'coffee-indent-line)))

(defun my/coffee-mode-hook ()
  (when (string-match-p "\\.litcoffee\\'" (buffer-name))
    (setq indent-line-function 'my/coffee-indent-line)))
(add-hook 'coffee-mode-hook 'my/coffee-mode-hook)
(add-to-list 'auto-mode-alist '("\\.litcoffee\\'" . coffee-mode))

I suppose we should discussion this topic at literate-coffee-mode.