summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorMicah Chalmer <micah@micahchalmer.net>2014-03-11 20:23:32 -0400
committerAlex Crichton <alex@alexcrichton.com>2014-03-12 15:01:25 -0700
commit2d12c3ed21b581d44376d8f068ddfdaad4a901e9 (patch)
tree1e8c2d3180ac0120a716e99baa264f554eeee6e1 /rust-mode.el
parent4f4015623453d4c4fb54d0a72d5f066c6cfe42fc (diff)
downloadrust-mode-2d12c3ed21b581d44376d8f068ddfdaad4a901e9.tar.gz
Emacs: always jump the cursor if needed on indent
The rust-mode-indent-line function had a check, which ran after all the calculations for how to indent had already happened, that skipped actually performing the indent if the line was already at the right indentation. Because of that, the cursor did not jump to the indentation if the line wasn't changing. This was particularly annoying if there was nothing but spaces on the line and you were at the beginning of it--it looked like the indent just wasn't working. This removes the check and adds test cases to cover this.
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el16
1 files changed, 8 insertions, 8 deletions
diff --git a/rust-mode.el b/rust-mode.el
index b304df8..3a99af3 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -140,14 +140,14 @@
;; Otherwise, we are continuing the same expression from the previous line,
;; so add one additional indent level
(+ baseline rust-indent-offset))))))))))
- (when (not (eq (current-indentation) indent))
- ;; If we're at the beginning of the line (before or at the current
- ;; indentation), jump with the indentation change. Otherwise, save the
- ;; excursion so that adding the indentations will leave us at the
- ;; equivalent position within the line to where we were before.
- (if (<= (current-column) (current-indentation))
- (indent-line-to indent)
- (save-excursion (indent-line-to indent))))))
+
+ ;; If we're at the beginning of the line (before or at the current
+ ;; indentation), jump with the indentation change. Otherwise, save the
+ ;; excursion so that adding the indentations will leave us at the
+ ;; equivalent position within the line to where we were before.
+ (if (<= (current-column) (current-indentation))
+ (indent-line-to indent)
+ (save-excursion (indent-line-to indent)))))
;; Font-locking definitions and helpers