about summary refs log tree commit diff
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-08-10 13:02:44 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-08-10 13:02:44 -0700
commitb19c2ed8f3b04a872520c5f47782fe04d39de24c (patch)
treebdff49b6d828660942d631c154c149f7387848ab
parent4e92faad13b235f6924024db3c4de86fdc8e6a30 (diff)
parent3596f666bb0255d249dbfa0a4ef0d273b63c5666 (diff)
Merge branch 'master' of https://github.com/p2j4d2c/rust into rollup
-rw-r--r--src/etc/emacs/rust-mode.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el
index 87c505e69d0..ecb223f896c 100644
--- a/src/etc/emacs/rust-mode.el
+++ b/src/etc/emacs/rust-mode.el
@@ -29,6 +29,11 @@
 
     table))
 
+(defcustom rust-indent-offset default-tab-width
+  "*Indent Rust code by this number of spaces.
+
+The initializer is `DEFAULT-TAB-WIDTH'.")
+
 (defun rust-paren-level () (nth 0 (syntax-ppss)))
 (defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
 (defun rust-rewind-past-str-cmnt () (goto-char (nth 8 (syntax-ppss))))
@@ -49,10 +54,10 @@
            (let ((level (rust-paren-level)))
              (cond
               ;; A function return type is 1 level indented
-              ((looking-at "->") (* default-tab-width (+ level 1)))
+              ((looking-at "->") (* rust-indent-offset (+ level 1)))
 
               ;; A closing brace is 1 level unindended
-              ((looking-at "}") (* default-tab-width (- level 1)))
+              ((looking-at "}") (* rust-indent-offset (- level 1)))
 
               ;; If we're in any other token-tree / sexp, then:
               ;;  - [ or ( means line up with the opening token
@@ -70,18 +75,18 @@
                      (goto-char pt)
                      (back-to-indentation)
                      (if (looking-at "\\<else\\>")
-                         (* default-tab-width (+ 1 level))
+                         (* rust-indent-offset (+ 1 level))
                        (progn
                          (goto-char pt)
                          (beginning-of-line)
                          (rust-rewind-irrelevant)
                          (end-of-line)
                          (if (looking-back "[{};,]")
-                             (* default-tab-width level)
+                             (* rust-indent-offset level)
                            (back-to-indentation)
                            (if (looking-at "#")
-                               (* default-tab-width level)
-                             (* default-tab-width (+ 1 level))))))))))
+                               (* rust-indent-offset level)
+                             (* rust-indent-offset (+ 1 level))))))))))
 
               ;; Otherwise we're in a column-zero definition
               (t 0))))))