Add narf/smart-indent and narf/dumb-dedent
This commit is contained in:
parent
643743b021
commit
8cd21a0fff
1 changed files with 22 additions and 4 deletions
|
@ -79,13 +79,31 @@ whitespace as possible, or just one char if that's not possible."
|
||||||
"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 (or (and smart (looking-back "^[\s\t]*"))
|
(if indent-tabs-mode
|
||||||
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))))
|
||||||
(insert (s-repeat spaces " ")))))
|
(insert (s-repeat spaces " ")))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/smart-indent ()
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(back-to-indentation)
|
||||||
|
(narf/dumb-indent)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/dumb-dedent ()
|
||||||
|
(interactive)
|
||||||
|
(if indent-tabs-mode
|
||||||
|
(delete-char -1)
|
||||||
|
(save-excursion
|
||||||
|
(unless (looking-back "^[\s\t]*")
|
||||||
|
(evil-first-non-blank))
|
||||||
|
(let* ((movement (% (current-column) tab-width))
|
||||||
|
(spaces (if (zerop movement) tab-width (- tab-width movement))))
|
||||||
|
(delete-char (- spaces))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun narf/inflate-space-maybe ()
|
(defun narf/inflate-space-maybe ()
|
||||||
"Checks if point is surrounded by {} [] () delimiters and adds a
|
"Checks if point is surrounded by {} [] () delimiters and adds a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue