Skip to content

Commit d7458c2

Browse files
committed
set open-paren-in-column-0-is-defun-start to nil
Set open-paren-in-column-0-is-defun-start to nil in rust-mode. This setting is a performance hack in Emacs, at the expense of correctness in some cases. However, due to the syntax-ppss cache, I doubt whether this hack is needed for Rust code. Fixes #107
1 parent 0de149a commit d7458c2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

rust-mode-tests.el

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,21 @@ pub fn foo<T,
18761876
hello();
18771877
}"))
18781878

1879+
(ert-deftest indent-open-paren-in-column0 ()
1880+
;; Just pass the same text for the "deindented" argument. This
1881+
;; avoids the extra spaces normally inserted, which would mess up
1882+
;; the test because string contents aren't touched by reindentation.
1883+
(let ((text "
1884+
const a: &'static str = r#\"
1885+
{}\"#;
1886+
fn main() {
1887+
let b = \"//\";
1888+
let c = \"\";
1889+
1890+
}
1891+
"))
1892+
(test-indent text text)))
1893+
18791894
(defun rust-test-matching-parens (content pairs &optional nonparen-positions)
18801895
"Assert that in rust-mode, given a buffer with the given `content',
18811896
emacs's paren matching will find all of the pairs of positions

rust-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
14561456
(setq-local comment-start "// ")
14571457
(setq-local comment-end "")
14581458
(setq-local indent-tabs-mode nil)
1459+
(setq-local open-paren-in-column-0-is-defun-start nil)
14591460

14601461
;; Auto indent on }
14611462
(setq-local

0 commit comments

Comments
 (0)