[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 1d42d69 416/486: Speed up line indentation insid
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 1d42d69 416/486: Speed up line indentation inside strings (#313) |
Date: |
Sat, 7 Aug 2021 09:26:05 -0400 (EDT) |
branch: elpa/rust-mode
commit 1d42d6981877100bff4e643f6374cee0a15e733f
Author: Chris Rayner <riscy@users.noreply.github.com>
Commit: Nathan Moreau <nathan.moreau@m4x.org>
Speed up line indentation inside strings (#313)
---
rust-mode.el | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 7b14d04..b912140 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -365,11 +365,8 @@ buffer."
((nth 3 (syntax-ppss))
(let*
((string-begin-pos (nth 8 (syntax-ppss)))
- (end-of-prev-line-pos (when (> (line-number-at-pos) 1)
- (save-excursion
- (forward-line -1)
- (end-of-line)
- (point)))))
+ (end-of-prev-line-pos (unless (rust--same-line-p (point)
(point-min))
+ (line-end-position 0))))
(when
(and
;; If the string begins with an "r" it's a raw string and
@@ -389,7 +386,7 @@ buffer."
;; Indent to the same level as the previous line, or the
;; start of the string if the previous line starts the
string
- (if (= (line-number-at-pos end-of-prev-line-pos)
(line-number-at-pos string-begin-pos))
+ (if (rust--same-line-p end-of-prev-line-pos
string-begin-pos)
;; The previous line is the start of the string.
;; If the backslash is the only character after the
;; string beginning, indent to the next indent
@@ -530,6 +527,11 @@ buffer."
(indent-line-to indent)
(save-excursion (indent-line-to indent))))))
+(defun rust--same-line-p (pos1 pos2)
+ "Return non-nil if POS1 and POS2 are on the same line."
+ (save-excursion (= (progn (goto-char pos1) (line-end-position))
+ (progn (goto-char pos2) (line-end-position)))))
+
;; Font-locking definitions and helpers
(defconst rust-mode-keywords
- [nongnu] elpa/rust-mode 216faf2 353/486: Do not indent where clause by default (follow standard) #257, (continued)
- [nongnu] elpa/rust-mode 216faf2 353/486: Do not indent where clause by default (follow standard) #257, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e201404 367/486: Fix font-locking of "let ref", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8d32dc6 370/486: Add keywords `async` and `try`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 54a9c3d 380/486: Merge pull request #296 from dekellum/indent-return-type-defcustom, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ce7a27f 381/486: Add compilation mode warning face, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c1059d6 387/486: Added angle bracket tests, some of which fail without the fix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 06f1c68 389/486: Merge pull request #300 from mmilenko/rust-looking-back-macro--backward-char--fix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 48290d3 399/486: Merge pull request #318 from kraai/patch-1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f6ebcbd 400/486: Update travis scripts to use EVM, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 077cba7 402/486: Add local docker based tests runner, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1d42d69 416/486: Speed up line indentation inside strings (#313),
ELPA Syncer <=
- [nongnu] elpa/rust-mode 4a7a860 480/486: Properly markup two additional section headings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a789a25 266/486: Fix #168: use while in rust-rewind-irrelevant, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 936a187 276/486: handle indirect buffers and multiple windows in rust-format-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 09efc45 320/486: Merge pull request #219 from Aankhen/highlight-question-mark, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b10ad41 326/486: Merge pull request #220 from Aankhen/highlight-string-interpolation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d71fe94 307/486: restore points when an error occurs too, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1b3db88 422/486: Add a function wrap and unwrap with the dbg! macro., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8733792 448/486: Drop Emacs-24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9eb2c63 460/486: Fix README internal link (#389), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 13c4335 462/486: Improve doc-strings, ELPA Syncer, 2021/08/07