Smarter dumb indentation
This commit is contained in:
parent
628e495536
commit
22c82d63e6
1 changed files with 5 additions and 4 deletions
|
@ -75,11 +75,12 @@ whitespace as possible, or just one char if that's not possible."
|
||||||
(t (backward-delete-char-untabify 1))))
|
(t (backward-delete-char-untabify 1))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun narf/dumb-indent ()
|
(defun narf/dumb-indent (&optional smart)
|
||||||
"Inserts a tab character (or spaces x tab-width). Checks if the
|
"Inserts a tab character (or spaces x tab-width). Checks if the
|
||||||
auto-complete window is open."
|
auto-complete window is open."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if indent-tabs-mode
|
(if (or (and smart (looking-back "^[\s\t]*"))
|
||||||
|
indent-tabs-mode)
|
||||||
(insert "\t")
|
(insert "\t")
|
||||||
(let* ((movement (% (current-column) tab-width))
|
(let* ((movement (% (current-column) tab-width))
|
||||||
(spaces (if (zerop movement) tab-width (- tab-width movement))))
|
(spaces (if (zerop movement) tab-width (- tab-width movement))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue