Skip to content

Commit

Permalink
New M2-indent-to function for indenting to a specific column
Browse files Browse the repository at this point in the history
Simplifies M2-electric-tab and will also be used by new M2-simple-doc-mode
  • Loading branch information
d-torrance committed Mar 5, 2021
1 parent 107c863 commit d9aef9b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions M2.el
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,17 @@ be sent can be entered, with history."
(self-insert-command 1)
(and (eolp) (M2-next-line-blank) (< (M2-paren-change) 0) (newline nil t)))

(defun M2-indent-to (indent-amount)
(save-excursion
(delete-region (progn (beginning-of-line) (point))
(progn (back-to-indentation) (point)))
(indent-to indent-amount))
(if (< (current-column) (current-indentation))
(back-to-indentation)))

(defun M2-electric-tab ()
(interactive)
(save-excursion
(delete-region (progn (beginning-of-line) (point))
(progn (back-to-indentation) (point)))
(indent-to (M2-this-line-indent-amount)))
(if (< (current-column) (current-indentation))
(back-to-indentation)))
(interactive)
(M2-indent-to (M2-this-line-indent-amount)))

(defvar M2-demo-buffer
(save-excursion
Expand Down

0 comments on commit d9aef9b

Please sign in to comment.