Merge branch 'master' of https://github.com/p2j4d2c/rust into rollup
This commit is contained in:
commit
b19c2ed8f3
1 changed files with 11 additions and 6 deletions
|
@ -29,6 +29,11 @@
|
||||||
|
|
||||||
table))
|
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-paren-level () (nth 0 (syntax-ppss)))
|
||||||
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
|
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
|
||||||
(defun rust-rewind-past-str-cmnt () (goto-char (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)))
|
(let ((level (rust-paren-level)))
|
||||||
(cond
|
(cond
|
||||||
;; A function return type is 1 level indented
|
;; 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
|
;; 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:
|
;; If we're in any other token-tree / sexp, then:
|
||||||
;; - [ or ( means line up with the opening token
|
;; - [ or ( means line up with the opening token
|
||||||
|
@ -70,18 +75,18 @@
|
||||||
(goto-char pt)
|
(goto-char pt)
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(if (looking-at "\\<else\\>")
|
(if (looking-at "\\<else\\>")
|
||||||
(* default-tab-width (+ 1 level))
|
(* rust-indent-offset (+ 1 level))
|
||||||
(progn
|
(progn
|
||||||
(goto-char pt)
|
(goto-char pt)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(rust-rewind-irrelevant)
|
(rust-rewind-irrelevant)
|
||||||
(end-of-line)
|
(end-of-line)
|
||||||
(if (looking-back "[{};,]")
|
(if (looking-back "[{};,]")
|
||||||
(* default-tab-width level)
|
(* rust-indent-offset level)
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(if (looking-at "#")
|
(if (looking-at "#")
|
||||||
(* default-tab-width level)
|
(* rust-indent-offset level)
|
||||||
(* default-tab-width (+ 1 level))))))))))
|
(* rust-indent-offset (+ 1 level))))))))))
|
||||||
|
|
||||||
;; Otherwise we're in a column-zero definition
|
;; Otherwise we're in a column-zero definition
|
||||||
(t 0))))))
|
(t 0))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue