Skip to content

Commit

Permalink
Indent using the number of lines in a region instead of the location …
Browse files Browse the repository at this point in the history
…of point within the original region.
  • Loading branch information
Sterlingg committed Jan 10, 2015
1 parent 2d8a301 commit 40efeb4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sws-mode.el
Expand Up @@ -82,17 +82,19 @@
(defun sws-move-region (begin end prog)
"Moves left is dir is null, otherwise right. prog is '+ or '-"
(save-excursion
(let (first-indent indent-diff)
(let ((first-indent indent-diff)
(num-lines-indented (count-lines-region begin end))
)
(goto-char begin)
(setq first-indent (current-indentation))
(sws-indent-to
(funcall prog first-indent sws-tab-width))
(setq indent-diff (- (current-indentation) first-indent))
(forward-line 1)
;; move other lines based on movement of first line
(while (< (point) end)
(forward-line 1)
(if (< (point) end)
(sws-indent-to (+ (current-indentation) indent-diff)))))))
(dotimes (i (- num-lines-indented 1))
(sws-indent-to (+ (current-indentation) indent-diff))
(forward-line 1)))))

(defun sws-indent-region (begin end)
"Indents the selected region"
Expand Down

0 comments on commit 40efeb4

Please sign in to comment.