diff options
| author | mrBliss <dewinant@gmail.com> | 2016-09-09 10:02:16 +0200 |
|---|---|---|
| committer | mrBliss <dewinant@gmail.com> | 2016-09-09 10:02:16 +0200 |
| commit | a789a257c703d1e0041b6b193a41429124f90b44 (patch) | |
| tree | 3453ac4638a5900fd8d9858ee980a1b3adb60d41 | |
| parent | 5cfb9197af67e00ebd5bbcb05c28545c9014ea32 (diff) | |
| download | rust-mode-a789a257c703d1e0041b6b193a41429124f90b44.tar.gz | |
Fix #168: use while in rust-rewind-irrelevant
Rewrite the recursive function `rust-rewind-irrelevant`, which causes a
stack overflow in #168, using a `while` loop.
| -rw-r--r-- | rust-mode.el | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/rust-mode.el b/rust-mode.el index 4867e77..2c97433 100644 --- a/rust-mode.el +++ b/rust-mode.el @@ -201,14 +201,20 @@ function or trait. When nil, where will be aligned with fn or trait." (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)))) + (defun rust-rewind-irrelevant () - (let ((starting (point))) - (skip-chars-backward "[:space:]\n") - (if (rust-looking-back-str "*/") (backward-char)) - (if (rust-in-str-or-cmnt) - (rust-rewind-past-str-cmnt)) - (if (/= starting (point)) - (rust-rewind-irrelevant)))) + (let ((continue t)) + (while continue + (let ((starting (point))) + (skip-chars-backward "[:space:]\n") + (when (rust-looking-back-str "*/") + (backward-char)) + (when (rust-in-str-or-cmnt) + (rust-rewind-past-str-cmnt)) + ;; Rewind until the point no longer moves + (setq continue (/= starting (point))))))) + + (defun rust-in-macro () (save-excursion (when (> (rust-paren-level) 0) |
