Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created February 15, 2012 05:52
Show Gist options
  • Save mahmoud/1833619 to your computer and use it in GitHub Desktop.
Save mahmoud/1833619 to your computer and use it in GitHub Desktop.
less major mode indentation
(defun less-css-calculate-indentation ()
"Return the column to which the current line should be indented."
(save-excursion
(end-of-line)
(let ((indent-level 0))
(while (not (bobp))
;; TODO search backwards
(backward-char)
(cond ((looking-at "{") (setq indent-level (+ 1 indent-level)))
((looking-at "}") (setq indent-level (- indent-level 1)))))
indent-level)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment