[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 9e03890 478/486: Create rust-compile.el from exi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 9e03890 478/486: Create rust-compile.el from existing code |
Date: |
Sat, 7 Aug 2021 09:26:18 -0400 (EDT) |
branch: elpa/rust-mode
commit 9e03890863fc1c1aca696e576d0a5b1daf1eed01
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: brotzeit <brotzeitmacher@gmail.com>
Create rust-compile.el from existing code
For the time being `require' the new library from "rust-mode.el".
In the mid-term we should stop doing that, so that users can load
it if and only if they want to do so.
---
Makefile | 1 +
rust-compile.el | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rust-mode.el | 76 ++--------------------------------------------------
3 files changed, 86 insertions(+), 74 deletions(-)
diff --git a/Makefile b/Makefile
index 4460970..396b722 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ EMACS ?= emacs
EMACS_ARGS ?=
ELS = rust-mode.el
+ELS += rust-compile.el
ELCS = $(ELS:.el=.elc)
DEPS =
diff --git a/rust-compile.el b/rust-compile.el
new file mode 100644
index 0000000..6c73901
--- /dev/null
+++ b/rust-compile.el
@@ -0,0 +1,83 @@
+;;; rust-compile.el --- Compile facilities -*-lexical-binding: t-*-
+;;; Commentary:
+
+;; This library teaches `compilation-mode' about "rustc" output.
+
+;;; Code:
+
+(require 'compile)
+
+;;; _
+
+(defvar rustc-compilation-location
+ (let ((file "\\([^\n]+\\)")
+ (start-line "\\([0-9]+\\)")
+ (start-col "\\([0-9]+\\)"))
+ (concat "\\(" file ":" start-line ":" start-col "\\)")))
+
+(defvar rustc-compilation-regexps
+ (let ((re (concat "^\\(?:error\\|\\(warning\\)\\|\\(note\\)\\)[^\0]+?--> "
+ rustc-compilation-location)))
+ (cons re '(4 5 6 (1 . 2) 3)))
+ "Specifications for matching errors in rustc invocations.
+See `compilation-error-regexp-alist' for help on their format.")
+
+(defvar rustc-colon-compilation-regexps
+ (let ((re (concat "^ *::: " rustc-compilation-location)))
+ (cons re '(2 3 4 0 1)))
+ "Specifications for matching `:::` hints in rustc invocations.
+See `compilation-error-regexp-alist' for help on their format.")
+
+(defvar rustc-refs-compilation-regexps
+ (let ((re "^\\([0-9]+\\)[[:space:]]*|"))
+ (cons re '(nil 1 nil 0 1)))
+ "Specifications for matching code references in rustc invocations.
+See `compilation-error-regexp-alist' for help on their format.")
+
+;; Match test run failures and panics during compilation as
+;; compilation warnings
+(defvar cargo-compilation-regexps
+ '("^\\s-+thread '[^']+' panicked at \\('[^']+', \\([^:]+\\):\\([0-9]+\\)\\)"
+ 2 3 nil nil 1)
+ "Specifications for matching panics in cargo test invocations.
+See `compilation-error-regexp-alist' for help on their format.")
+
+(defun rustc-scroll-down-after-next-error ()
+ "In the new style error messages, the regular expression
+matches on the file name (which appears after `-->`), but the
+start of the error appears a few lines earlier. This hook runs
+after `next-error' (\\[next-error]); it simply scrolls down a few lines in
+the compilation window until the top of the error is visible."
+ (save-selected-window
+ (when (eq major-mode 'rust-mode)
+ (select-window (get-buffer-window next-error-last-buffer 'visible))
+ (when (save-excursion
+ (beginning-of-line)
+ (looking-at " *-->"))
+ (let ((start-of-error
+ (save-excursion
+ (beginning-of-line)
+ (while (not (looking-at "^[a-z]+:\\|^[a-z]+\\[E[0-9]+\\]:"))
+ (forward-line -1))
+ (point))))
+ (set-window-start (selected-window) start-of-error))))))
+
+(eval-after-load 'compile
+ '(progn
+ (add-to-list 'compilation-error-regexp-alist-alist
+ (cons 'rustc-refs rustc-refs-compilation-regexps))
+ (add-to-list 'compilation-error-regexp-alist 'rustc-refs)
+ (add-to-list 'compilation-error-regexp-alist-alist
+ (cons 'rustc rustc-compilation-regexps))
+ (add-to-list 'compilation-error-regexp-alist 'rustc)
+ (add-to-list 'compilation-error-regexp-alist-alist
+ (cons 'rustc-colon rustc-colon-compilation-regexps))
+ (add-to-list 'compilation-error-regexp-alist 'rustc-colon)
+ (add-to-list 'compilation-error-regexp-alist-alist
+ (cons 'cargo cargo-compilation-regexps))
+ (add-to-list 'compilation-error-regexp-alist 'cargo)
+ (add-hook 'next-error-hook 'rustc-scroll-down-after-next-error)))
+
+;;; _
+(provide 'rust-compile)
+;;; rust-compile.el ends here
diff --git a/rust-mode.el b/rust-mode.el
index 21fdd24..221259c 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -14,9 +14,8 @@
;;; Code:
-(eval-when-compile (require 'rx)
- (require 'compile)
- (require 'url-vars))
+(eval-when-compile (require 'rx))
+(eval-when-compile (require 'url-vars))
(require 'json)
(require 'thingatpt)
@@ -1973,77 +1972,6 @@ Return the created process."
(or (rust--format-error-handler)
(message "rustfmt detected problems, see *rustfmt* for more."))))))
-;;; Compilation
-
-(defvar rustc-compilation-location
- (let ((file "\\([^\n]+\\)")
- (start-line "\\([0-9]+\\)")
- (start-col "\\([0-9]+\\)"))
- (concat "\\(" file ":" start-line ":" start-col "\\)")))
-
-(defvar rustc-compilation-regexps
- (let ((re (concat "^\\(?:error\\|\\(warning\\)\\|\\(note\\)\\)[^\0]+?--> "
- rustc-compilation-location)))
- (cons re '(4 5 6 (1 . 2) 3)))
- "Specifications for matching errors in rustc invocations.
-See `compilation-error-regexp-alist' for help on their format.")
-
-(defvar rustc-colon-compilation-regexps
- (let ((re (concat "^ *::: " rustc-compilation-location)))
- (cons re '(2 3 4 0 1)))
- "Specifications for matching `:::` hints in rustc invocations.
-See `compilation-error-regexp-alist' for help on their format.")
-
-(defvar rustc-refs-compilation-regexps
- (let ((re "^\\([0-9]+\\)[[:space:]]*|"))
- (cons re '(nil 1 nil 0 1)))
- "Specifications for matching code references in rustc invocations.
-See `compilation-error-regexp-alist' for help on their format.")
-
-;; Match test run failures and panics during compilation as
-;; compilation warnings
-(defvar cargo-compilation-regexps
- '("^\\s-+thread '[^']+' panicked at \\('[^']+', \\([^:]+\\):\\([0-9]+\\)\\)"
- 2 3 nil nil 1)
- "Specifications for matching panics in cargo test invocations.
-See `compilation-error-regexp-alist' for help on their format.")
-
-(defun rustc-scroll-down-after-next-error ()
- "In the new style error messages, the regular expression
-matches on the file name (which appears after `-->`), but the
-start of the error appears a few lines earlier. This hook runs
-after `next-error' (\\[next-error]); it simply scrolls down a few lines in
-the compilation window until the top of the error is visible."
- (save-selected-window
- (when (eq major-mode 'rust-mode)
- (select-window (get-buffer-window next-error-last-buffer 'visible))
- (when (save-excursion
- (beginning-of-line)
- (looking-at " *-->"))
- (let ((start-of-error
- (save-excursion
- (beginning-of-line)
- (while (not (looking-at "^[a-z]+:\\|^[a-z]+\\[E[0-9]+\\]:"))
- (forward-line -1))
- (point))))
- (set-window-start (selected-window) start-of-error))))))
-
-(eval-after-load 'compile
- '(progn
- (add-to-list 'compilation-error-regexp-alist-alist
- (cons 'rustc-refs rustc-refs-compilation-regexps))
- (add-to-list 'compilation-error-regexp-alist 'rustc-refs)
- (add-to-list 'compilation-error-regexp-alist-alist
- (cons 'rustc rustc-compilation-regexps))
- (add-to-list 'compilation-error-regexp-alist 'rustc)
- (add-to-list 'compilation-error-regexp-alist-alist
- (cons 'rustc-colon rustc-colon-compilation-regexps))
- (add-to-list 'compilation-error-regexp-alist 'rustc-colon)
- (add-to-list 'compilation-error-regexp-alist-alist
- (cons 'cargo cargo-compilation-regexps))
- (add-to-list 'compilation-error-regexp-alist 'cargo)
- (add-hook 'next-error-hook 'rustc-scroll-down-after-next-error)))
-
;;; Secondary Commands
(defun rust-playpen-region (begin end)
- [nongnu] elpa/rust-mode 6f1abc3 438/486: Expand README to include more information about features (#358), (continued)
- [nongnu] elpa/rust-mode 6f1abc3 438/486: Expand README to include more information about features (#358), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e04e485 441/486: rustc-compilation-regexps: handle `note` case as compilation-info., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 39f32cc 447/486: In emacs >= 26.2, use replace-buffer-contents after formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eca55c0 451/486: Check for -> and => early in rust-ordinary-lt-gt-p, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ca7d99c 469/486: Set default directory when compiling., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c5c7ed3 471/486: Update README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4e394ac 475/486: Add Makefile, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 09b4320 476/486: test: Suppress some noisy messages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode afeddec 325/486: Merge pull request #224 from tromey/beginning-of-defun, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7fd78f0 444/486: rust-goto-format-problem: make sure to always just to a buffer that exists., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9e03890 478/486: Create rust-compile.el from existing code,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 41642f0 481/486: rust-end-of-string: Move definition, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d548425 483/486: Create rust-playpen.el from existing code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eb5270b 437/486: rust-before-save-hook: log errors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2df6cf7 439/486: Don't fail on re-search-forward. (#359), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ca415e9 470/486: Add rust-check function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e327658 274/486: Merge pull request #178 from ryuslash/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7e2533f 415/486: Fix rustc-compilation-regexps: match error messages with dashes. (#331), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9107989 424/486: review, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d0f3f45 431/486: imenu: fn items: match async/const and all pub variants. (#346), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7afad7b 464/486: rearrange II: Regexp variables and functions, ELPA Syncer, 2021/08/07