summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorMiodrag Milenkovic <miodrag.milenkovic@gmail.com>2019-02-28 12:54:25 -0500
committerMiodrag Milenkovic <miodrag.milenkovic@gmail.com>2019-02-28 12:54:25 -0500
commitdd231edbd8a2805aaf0728fb5800a356ed1d14ce (patch)
treeab1c11b3e9e43b32e48ffa52299e9e92dfae101b /rust-mode.el
parent54a9c3d3f501620cdf3f2d86f239571c1cc87fc6 (diff)
downloadrust-mode-dd231edbd8a2805aaf0728fb5800a356ed1d14ce.tar.gz
Avoid signaling "Beginning of buffer" in rust-lookng-back-macro
Also save some work if we don't have at least two characters behind us in the buffer, we know we can't be looking at a macro then. The signal occurs when one tries 'racer-describe' when positioned over "String", which eventually ends up calling (with-temp-buffer (insert "<Target=str>") (delay-mode-hooks (rust-mode)) (font-lock-ensure)) This simpler block will also trigger the error (with-temp-buffer (insert "<>") (rust-mode) (font-lock-ensure)) (font-lock-ensure) call ends up calling (rust-looking-back-macro).
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/rust-mode.el b/rust-mode.el
index a433d8d..c3d132a 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -80,7 +80,8 @@ Like `looking-back' but for fixed strings rather than regexps (so that it's not
(defun rust-looking-back-macro ()
"Non-nil if looking back at an ident followed by a !"
- (save-excursion (backward-char) (and (= ?! (char-after)) (rust-looking-back-ident))))
+ (if (> (point) 2)
+ (save-excursion (backward-char) (and (= ?! (char-after)) (rust-looking-back-ident)))))
;; Syntax definitions and helpers
(defvar rust-mode-syntax-table
@@ -1594,7 +1595,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
(when rust-format-on-save
(unless (executable-find rust-rustfmt-bin)
(error "Could not locate executable \"%s\"" rust-rustfmt-bin))))
-
+
(defvar rustc-compilation-regexps
(let ((file "\\([^\n]+\\)")
(start-line "\\([0-9]+\\)")