[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 19bc0e9 121/486: Merge pull request #30 from Mic
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 19bc0e9 121/486: Merge pull request #30 from MicahChalmer/emacs23-fixup |
Date: |
Sat, 7 Aug 2021 09:25:02 -0400 (EDT) |
branch: elpa/rust-mode
commit 19bc0e9ef1dd72bfde10644037a13719a38777fc
Merge: d2c6d6c 2038365
Author: Felix S Klock II <pnkfelix@pnkfx.org>
Commit: Felix S Klock II <pnkfelix@pnkfx.org>
Merge pull request #30 from MicahChalmer/emacs23-fixup
Emacs 23 Fixups
---
.travis.yml | 1 +
README.md | 7 ++++++-
rust-mode-tests.el | 15 ++++++++++++++-
rust-mode.el | 43 +++++++++++++------------------------------
4 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 63221ed..04231a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,7 @@ language: generic
env:
matrix:
+ - EMACS=emacs23
- EMACS=emacs24
- EMACS=emacs-snapshot
diff --git a/README.md b/README.md
index 24470c2..6823f8b 100644
--- a/README.md
+++ b/README.md
@@ -76,4 +76,9 @@ the packages for you (under `~/.emacs.d/elpa/`).
The file `rust-mode-tests.el` contains tests that can be run via
[ERT](http://www.gnu.org/software/emacs/manual/html_node/ert/index.html).
You can use `run_rust_emacs_tests.sh` to run them in batch mode, if
-Emacs is somewhere in your `$PATH`.
+you set the environment variable EMACS to a program that runs emacs.
+
+To test it under emacs 23, which does not ship with ERT, download ert.el from
+https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el
+and put it in a place where emacs can find it. (ERT has shipped with emacs
+since emacs 24.)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index a0e27b0..36e59df 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -289,7 +289,11 @@ very very very long string
(rust-test-manip-code
deindented
1
- (lambda () (indent-region 1 (buffer-size)))
+ (lambda ()
+ ;; The indentation will fial in some cases if the syntax properties are
+ ;; not set. This only happens when font-lock fontifies the buffer.
+ (font-lock-fontify-buffer)
+ (indent-region 1 (buffer-size)))
indented)))
@@ -1008,3 +1012,12 @@ fn main() {
}
"
)))
+
+(ert-deftest indent-method-chains-after-comment ()
+ (let ((rust-indent-method-chain t)) (test-indent
+ "
+fn main() { // comment here should not push next line out
+ foo.bar()
+}
+"
+ )))
diff --git a/rust-mode.el b/rust-mode.el
index b2e0d5d..43afd9a 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -116,7 +116,7 @@
;; be undone via tab.
(when (looking-at (concat "\s*\." rust-re-ident))
- (previous-line)
+ (previous-logical-line)
(end-of-line)
(let
@@ -131,7 +131,7 @@
;;
((skip-dot-identifier
(lambda ()
- (when (looking-back (concat "\." rust-re-ident))
+ (when (looking-back (concat "\\." rust-re-ident))
(backward-word 1)
(backward-char)
(- (current-column) rust-indent-offset)))))
@@ -311,6 +311,14 @@
("fn" . font-lock-function-name-face)
("static" . font-lock-constant-face)))))
+(defvar rust-mode-font-lock-syntactic-keywords
+ (mapcar (lambda (re) (list re '(1 "\"") '(2 "\"")))
+ '("\\('\\)[^']\\('\\)"
+ "\\('\\)\\\\['nrt]\\('\\)"
+ "\\('\\)\\\\x[[:xdigit:]]\\{2\\}\\('\\)"
+ "\\('\\)\\\\u[[:xdigit:]]\\{4\\}\\('\\)"
+ "\\('\\)\\\\U[[:xdigit:]]\\{8\\}\\('\\)")))
+
(defun rust-fill-prefix-for-comment-start (line-start)
"Determine what to use for `fill-prefix' based on what is at the beginning
of a line."
(let ((result
@@ -569,7 +577,7 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(setq-local indent-line-function 'rust-mode-indent-line)
;; Fonts
- (setq-local font-lock-defaults '(rust-mode-font-lock-keywords nil nil nil
nil))
+ (setq-local font-lock-defaults '(rust-mode-font-lock-keywords nil nil nil
nil (font-lock-syntactic-keywords . rust-mode-font-lock-syntactic-keywords)))
;; Misc
(setq-local comment-start "// ")
@@ -591,33 +599,8 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(setq-local beginning-of-defun-function 'rust-beginning-of-defun)
(setq-local end-of-defun-function 'rust-end-of-defun)
(setq-local parse-sexp-lookup-properties t)
- (add-hook 'syntax-propertize-extend-region-functions
'rust-syntax-propertize-extend-region)
- (add-hook 'post-self-insert-hook 'rust-match-angle-bracket-hook)
- (setq-local syntax-propertize-function 'rust-syntax-propertize))
-
-(defun rust-syntax-propertize-extend-region (start end)
- (save-excursion
- (goto-char start)
- (beginning-of-defun)
- (cons
- (point)
- (progn
- (goto-char end)
- (end-of-defun)
- (point)))))
-
-(defun rust-syntax-propertize (start end)
- ;; Find character literals and make the syntax table recognize the single
quote as the string delimiter
- (dolist (char-lit-re
- '("'[^']'"
- "'\\\\['nrt]'"
- "'\\\\x[[:xdigit:]]\\{2\\}'"
- "'\\\\u[[:xdigit:]]\\{4\\}'"
- "'\\\\U[[:xdigit:]]\\{8\\}'"))
- (save-excursion
- (goto-char start)
- (while (re-search-forward char-lit-re end t)
- (put-text-property (match-beginning 0) (match-end 0) 'syntax-table
rust-mode-character-literal-syntax-table)))))
+ (setq-local syntax-begin-function 'beginning-of-defun)
+ (add-hook 'post-self-insert-hook 'rust-match-angle-bracket-hook))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
- [nongnu] elpa/rust-mode 0800660 068/486: Emacs: stay at the correct position when indenting, (continued)
- [nongnu] elpa/rust-mode 0800660 068/486: Emacs: stay at the correct position when indenting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bc78d17 075/486: rust-mode cleanup., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5e34201 061/486: Add defun motions for rust-mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0e58eb3 076/486: emacs: Add 'box' to keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 226102c 086/486: emacs: Add shebang to test script, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 186583d 096/486: Mark _ as a word constituent to avoid highlighting parts of identifiers as keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 04e4b49 103/486: Add .travis.yml, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ec81a95 114/486: Merge pull request #22 from nikomatsakis/align-method-chain, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 351cc91 112/486: Merge pull request #16 from MicahChalmer/add-travis, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b3f87b9 122/486: Make the test driver script a little more informative., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 19bc0e9 121/486: Merge pull request #30 from MicahChalmer/emacs23-fixup,
ELPA Syncer <=
- [nongnu] elpa/rust-mode bddc933 124/486: Fix typo in comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 97f6445 132/486: Merge pull request #38 from MicahChalmer/fix-issue-36, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 42730b1 144/486: Merge pull request #49 from huonw/playpen, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 249e3ce 134/486: Merge pull request #40 from MicahChalmer/fix-comment-typos, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 31ceb60 135/486: Indent inside strings after ending backslash, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 22c8cfa 138/486: Merge pull request #43 from MicahChalmer/indent-backslash-strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ce976b9 145/486: Fix "-> Type" on a single line indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f2f4d67 158/486: Merge pull request #59 from lunaryorn/fix-byte-compiler-warnings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ddf45ed 146/486: Use (goto-char (point-max)) instead of (end-of-buffer) to silence warning., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0077bbf 160/486: Fix package.el URL, ELPA Syncer, 2021/08/07