Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Restore point after formatting source code
Browse files Browse the repository at this point in the history
Part of #8.
  • Loading branch information
lucaswerkmeister committed May 13, 2017
1 parent 972e39d commit 9f2c55b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ceylon-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ The region must contain code that looks like a compilation unit
so that `ceylon.formatter' can parse it, usually one or more
complete declarations."
(interactive)
(shell-command-on-region (region-beginning) (region-end) "ceylon format --pipe" t t (get-buffer-create "*ceylon-format-errors*") t))
;; remember whether point was at beginning or end of region before formatting
(setq point-at-end (eq (point) (region-end)))
;; pipe region through ceylon.formatter
(shell-command-on-region (region-beginning) (region-end) "ceylon format --pipe" t t (get-buffer-create "*ceylon-format-errors*") t)
;; shell-command-on-region places point at beginning of region, move to end if it was there before formatting
(if point-at-end (goto-char (region-end))))

(define-key mode-specific-map "\C-f" 'ceylon-format-region)

Expand Down

0 comments on commit 9f2c55b

Please sign in to comment.