emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] scratch/rust-mode 01df37d523: Add email to `Maintainer:`; vario


From: Stefan Monnier
Subject: [nongnu] scratch/rust-mode 01df37d523: Add email to `Maintainer:`; various cosmetic changes
Date: Tue, 28 Jun 2022 15:17:11 -0400 (EDT)

branch: scratch/rust-mode
commit 01df37d52386b89fad3bebcc93d87d755ae92fa0
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Add email to `Maintainer:`; various cosmetic changes
---
 .gitignore         |  1 +
 rust-cargo.el      |  2 +-
 rust-compile.el    |  2 +-
 rust-mode-tests.el | 51 ++++++++++++++++++++++--------------
 rust-mode.el       | 77 +++++++++++++++++++++++-------------------------------
 rust-rustfmt.el    | 10 +++----
 6 files changed, 71 insertions(+), 72 deletions(-)

diff --git a/.gitignore b/.gitignore
index 2835be648c..8663ddfd6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 *.elc
 *-autoloads.el
+/rust-mode-pkg.el
 
 .eask
 /dist
diff --git a/rust-cargo.el b/rust-cargo.el
index 090945a16d..0c35ddb150 100644
--- a/rust-cargo.el
+++ b/rust-cargo.el
@@ -64,7 +64,7 @@
   (when rust-always-locate-project-on-open
     (rust-update-buffer-project)))
 
-(add-hook 'rust-mode-hook 'rust-maybe-initialize-buffer-project)
+(add-hook 'rust-mode-hook #'rust-maybe-initialize-buffer-project)
 
 ;;; Internal
 
diff --git a/rust-compile.el b/rust-compile.el
index 78a53cf1d6..1bb31030ee 100644
--- a/rust-compile.el
+++ b/rust-compile.el
@@ -76,7 +76,7 @@ the compilation window until the top of the error is visible."
      (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)))
+     (add-hook 'next-error-hook #'rustc-scroll-down-after-next-error)))
 
 ;;; _
 (provide 'rust-compile)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 8e3ee45f2b..011663c449 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -7,16 +7,19 @@
 (require 'imenu)
 
 (defconst rust-test-fill-column 32)
+;; FIXME: Loading a file shouldn't cause such changes.
 (setq-default indent-tabs-mode nil)
 
+;; FIXME: This macro doesn't obey the `rust-' namespace.
 (defmacro test-silence (messages &rest body)
-  `(cl-letf* (((symbol-function 'm)
-               (symbol-function #'message))
-              ((symbol-function #'message)
-              (lambda (format-string &rest args)
-                (unless (member format-string ,messages)
-                  (apply 'm format-string args)))))
-     ,@body))
+  `(let ((f (lambda (orig-fun format-string &rest args)
+             (unless (member format-string ,messages)
+               (apply orig-fun format-string args)))))
+     (unwind-protect
+         (progn
+           (advice-add 'message :around f)
+           ,@body)
+       (advice-remove 'message f))))
 
 (defun rust-compare-code-after-manip (_original _point-pos _manip-func 
expected got)
   (equal expected got))
@@ -53,6 +56,7 @@
     (should (rust-compare-code-after-manip
              original point-pos manip-func expected (buffer-string)))))
 
+;; FIXME: This function doesn't obey the `rust-' namespace.
 (defun test-fill-paragraph (unfilled expected &optional start-pos end-pos)
   "We're going to run through many scenarios here--the point should be able to 
be anywhere from the start-pos (defaults to 1) through end-pos (defaults to the 
length of what was passed in) and (fill-paragraph) should return the same 
result.  It should also work with fill-region from start-pos to end-pos.
 
@@ -253,6 +257,7 @@ fn bar() { }"
 /// even more.
 fn bar() { }" 14 85))
 
+;; FIXME: This function doesn't obey the `rust-' namespace.
 (defun test-auto-fill (initial position inserted expected)
   (rust-test-manip-code
    initial
@@ -312,6 +317,7 @@ very very very long string
  */"
    ))
 
+;; FIXME: This function doesn't obey the `rust-' namespace.
 (defun test-indent (indented &optional deindented)
   (let ((deindented (or deindented (replace-regexp-in-string "^[[:blank:]]*" " 
     " indented))))
     (rust-test-manip-code
@@ -392,11 +398,11 @@ not_a_string();
 
 "
 
-   (apply 'append (mapcar (lambda (s) (list s 'font-lock-string-face))
-                          '("r\"foo\\\"" "\"bar\"" "r\"bar\""
-                            "r\"foo\\.\"" "\"bar\"" "r\"bar\""
-                            "r\"foo\\..\"" "\"bar\"" "r\"foo\\..\\bar\""
-                            "r\"\\\"" "\"foo\"" "r\"\\foo\"")))
+   (apply #'append (mapcar (lambda (s) (list s 'font-lock-string-face))
+                           '("r\"foo\\\"" "\"bar\"" "r\"bar\""
+                             "r\"foo\\.\"" "\"bar\"" "r\"bar\""
+                             "r\"foo\\..\"" "\"bar\"" "r\"foo\\..\\bar\""
+                             "r\"\\\"" "\"foo\"" "r\"\\foo\"")))
    ))
 
 (ert-deftest font-lock-raw-string-after-normal-string-ending-in-r ()
@@ -3305,7 +3311,10 @@ type Foo<T> where T: Copy = Box<T>;
 (ert-deftest redo-syntax-after-change-far-from-point ()
   (let*
       ((tmp-file-name (make-temp-file "rust-mdoe-test-issue104"))
-       (base-contents (apply 'concat (append '("fn foo() {\n\n}\n") (make-list 
500 "// More stuff...\n") '("fn bar() {\n\n}\n")))))
+       (base-contents (apply #'concat
+                             (append '("fn foo() {\n\n}\n")
+                                     (make-list 500 "// More stuff...\n")
+                                     '("fn bar() {\n\n}\n")))))
     ;; Create the temp file...
     (with-temp-file tmp-file-name
       (insert base-contents))
@@ -3325,6 +3334,7 @@ type Foo<T> where T: Copy = Box<T>;
     )
   )
 
+;; FIXME: This function doesn't obey the `rust-' namespace.
 (defun test-imenu (code expected-items)
   (with-temp-buffer
     (rust-mode)
@@ -3480,12 +3490,12 @@ impl Two<'a> {
    #'rust-dbg-wrap-or-unwrap
    "let x = dbg!(\"foo, bar\")"))
 
-(when (executable-find rust-cargo-bin)
-  (ert-deftest rust-test-project-located ()
-    (let* ((test-dir (expand-file-name "test-project/" default-directory))
-           (manifest-file (expand-file-name "Cargo.toml" test-dir)))
-      (let ((default-directory test-dir))
-        (should (equal (expand-file-name (rust-buffer-project)) 
manifest-file))))))
+(ert-deftest rust-test-project-located ()
+  (skip-unless (executable-find rust-cargo-bin))
+  (let* ((test-dir (expand-file-name "test-project/" default-directory))
+         (manifest-file (expand-file-name "Cargo.toml" test-dir)))
+    (let ((default-directory test-dir))
+      (should (equal (expand-file-name (rust-buffer-project)) 
manifest-file)))))
 
 (defun rust-collect-matches (spec)
   (let ((matches nil))
@@ -3631,5 +3641,6 @@ impl Two<'a> {
          `(should
            (or
             (string-match "Prefix Command" ,match)
-            (string-match "^C-c C" ,match)))))
+            (string-match "^C-c C" ,match)))
+         t))
       (should (< 0 match-count)))))
diff --git a/rust-mode.el b/rust-mode.el
index dda79942e2..53c595c13d 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -2,6 +2,7 @@
 
 ;; Version: 1.0.5
 ;; Author: Mozilla
+;; Maintainer: brotzeit <brotzeitmacher@gmail.com>
 ;; Url: https://github.com/rust-lang/rust-mode
 ;; Keywords: languages
 ;; Package-Requires: ((emacs "25.1"))
@@ -57,33 +58,28 @@ This variable might soon be remove again.")
 (defcustom rust-indent-offset 4
   "Indent Rust code by this number of spaces."
   :type 'integer
-  :group 'rust-mode
   :safe #'integerp)
 
 (defcustom rust-indent-method-chain nil
   "Indent Rust method chains, aligned by the `.' operators."
   :type 'boolean
-  :group 'rust-mode
   :safe #'booleanp)
 
 (defcustom rust-indent-where-clause nil
   "Indent lines starting with the `where' keyword following a function or 
trait.
 When nil, `where' will be aligned with `fn' or `trait'."
   :type 'boolean
-  :group 'rust-mode
   :safe #'booleanp)
 
 (defcustom rust-match-angle-brackets t
   "Whether to enable angle bracket (`<' and `>') matching where appropriate."
   :type 'boolean
-  :safe #'booleanp
-  :group 'rust-mode)
+  :safe #'booleanp)
 
 (defcustom rust-indent-return-type-to-arguments t
   "Indent a line starting with the `->' (RArrow) following a function, aligning
 to the function arguments.  When nil, `->' will be indented one level."
   :type 'boolean
-  :group 'rust-mode
   :safe #'booleanp)
 
 ;;; Faces
@@ -99,28 +95,23 @@ to the function arguments.  When nil, `->' will be indented 
one level."
 
 (defface rust-unsafe
   '((t :inherit font-lock-warning-face))
-  "Face for the `unsafe' keyword."
-  :group 'rust-mode)
+  "Face for the `unsafe' keyword.")
 
 (defface rust-question-mark
   '((t :weight bold :inherit font-lock-builtin-face))
-  "Face for the question mark operator."
-  :group 'rust-mode)
+  "Face for the question mark operator.")
 
 (defface rust-ampersand-face
   '((t :inherit default))
-  "Face for the ampersand reference mark."
-  :group 'rust-mode)
+  "Face for the ampersand reference mark.")
 
 (defface rust-builtin-formatting-macro
   '((t :inherit font-lock-builtin-face))
-  "Face for builtin formatting macros (print! &c.)."
-  :group 'rust-mode)
+  "Face for builtin formatting macros (print! &c.).")
 
 (defface rust-string-interpolation
   '((t :slant italic :inherit font-lock-string-face))
-  "Face for interpolating braces in builtin formatting macro strings."
-  :group 'rust-mode)
+  "Face for interpolating braces in builtin formatting macro strings.")
 
 ;;; Syntax
 
@@ -236,15 +227,15 @@ See `prettify-symbols-compose-predicate'."
 
 (defvar rust-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-c C-d") 'rust-dbg-wrap-or-unwrap)
+    (define-key map (kbd "C-c C-d") #'rust-dbg-wrap-or-unwrap)
     (when rust-load-optional-libraries
-      (define-key map (kbd "C-c C-c C-u") 'rust-compile)
-      (define-key map (kbd "C-c C-c C-k") 'rust-check)
-      (define-key map (kbd "C-c C-c C-t") 'rust-test)
-      (define-key map (kbd "C-c C-c C-r") 'rust-run)
-      (define-key map (kbd "C-c C-c C-l") 'rust-run-clippy)
-      (define-key map (kbd "C-c C-f") 'rust-format-buffer)
-      (define-key map (kbd "C-c C-n") 'rust-goto-format-problem))
+      (define-key map (kbd "C-c C-c C-u") #'rust-compile)
+      (define-key map (kbd "C-c C-c C-k") #'rust-check)
+      (define-key map (kbd "C-c C-c C-t") #'rust-test)
+      (define-key map (kbd "C-c C-c C-r") #'rust-run)
+      (define-key map (kbd "C-c C-c C-l") #'rust-run-clippy)
+      (define-key map (kbd "C-c C-f") #'rust-format-buffer)
+      (define-key map (kbd "C-c C-n") #'rust-goto-format-problem))
     map)
   "Keymap for Rust major mode.")
 
@@ -253,14 +244,12 @@ See `prettify-symbols-compose-predicate'."
   "Major mode for Rust code.
 
 \\{rust-mode-map}"
-  :group 'rust-mode
-  :syntax-table rust-mode-syntax-table
 
   ;; Syntax
   (setq-local syntax-propertize-function #'rust-syntax-propertize)
 
   ;; Indentation
-  (setq-local indent-line-function 'rust-mode-indent-line)
+  (setq-local indent-line-function #'rust-mode-indent-line)
 
   ;; Fonts
   (setq-local font-lock-defaults
@@ -286,21 +275,22 @@ See `prettify-symbols-compose-predicate'."
                       comment-start-skip
                       "\\|\\*/?[[:space:]]*\\|\\)$"))
   (setq-local paragraph-separate paragraph-start)
-  (setq-local normal-auto-fill-function 'rust-do-auto-fill)
-  (setq-local fill-paragraph-function 'rust-fill-paragraph)
-  (setq-local fill-forward-paragraph-function 'rust-fill-forward-paragraph)
-  (setq-local adaptive-fill-function 'rust-find-fill-prefix)
+  (setq-local normal-auto-fill-function #'rust-do-auto-fill)
+  (setq-local fill-paragraph-function #'rust-fill-paragraph)
+  (setq-local fill-forward-paragraph-function #'rust-fill-forward-paragraph)
+  (setq-local adaptive-fill-function #'rust-find-fill-prefix)
   (setq-local adaptive-fill-first-line-regexp "")
   (setq-local comment-multi-line t)
-  (setq-local comment-line-break-function 'rust-comment-indent-new-line)
+  (setq-local comment-line-break-function #'rust-comment-indent-new-line)
   (setq-local imenu-generic-expression rust-imenu-generic-expression)
   (setq-local imenu-syntax-alist '((?! . "w"))) ; For macro_rules!
-  (setq-local beginning-of-defun-function 'rust-beginning-of-defun)
-  (setq-local end-of-defun-function 'rust-end-of-defun)
+  (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)
   (setq-local electric-pair-inhibit-predicate
-              'rust-electric-pair-inhibit-predicate-wrap)
-  (setq-local electric-pair-skip-self 'rust-electric-pair-skip-self-wrap)
+              #'rust-electric-pair-inhibit-predicate-wrap)
+  (add-function :before-until (local 'electric-pair-skip-self)
+                #'rust-electric-pair-skip-self)
   ;; Configure prettify
   (setq prettify-symbols-alist rust-prettify-symbols-alist)
   (setq prettify-symbols-compose-predicate #'rust--prettify-symbols-compose-p)
@@ -1317,13 +1307,10 @@ This wraps the default defined by 
`electric-pair-inhibit-predicate'."
        (rust-is-lt-char-operator)))
    (funcall (default-value 'electric-pair-inhibit-predicate) char)))
 
-(defun rust-electric-pair-skip-self-wrap (char)
+(defun rust-electric-pair-skip-self (char)
   "Skip CHAR instead of inserting a second closing character.
-This wraps the default defined by `electric-pair-skip-self'."
-  (or
-   (= ?> char)
-   (let ((skip-self (default-value 'electric-pair-skip-self)))
-     (and skip-self (funcall skip-self char)))))
+This is added to the default skips defined by `electric-pair-skip-self'."
+  (= ?> char))
 
 (defun rust-ordinary-lt-gt-p ()
   "Test whether the `<' or `>' at point is an ordinary operator of some kind.
@@ -1543,10 +1530,10 @@ This handles multi-line comments with a * prefix on 
each line."
       (lambda ()
         (let
             ((fill-paragraph-function
-              (if (not (eq fill-paragraph-function 'rust-fill-paragraph))
+              (if (not (eq fill-paragraph-function #'rust-fill-paragraph))
                   fill-paragraph-function))
              (fill-paragraph-handle-comment t))
-          (apply 'fill-paragraph args)
+          (apply #'fill-paragraph args)
           t))))))
 
 (defun rust-do-auto-fill (&rest args)
@@ -1554,7 +1541,7 @@ This handles multi-line comments with a * prefix on each 
line."
 This handles multi-line comments with a * prefix on each line."
   (rust-with-comment-fill-prefix
    (lambda ()
-     (apply 'do-auto-fill args)
+     (apply #'do-auto-fill args)
      t)))
 
 (defun rust-fill-forward-paragraph (arg)
diff --git a/rust-rustfmt.el b/rust-rustfmt.el
index 025ec32a8f..bb8864728c 100644
--- a/rust-rustfmt.el
+++ b/rust-rustfmt.el
@@ -47,7 +47,7 @@
       (erase-buffer)
       (insert-buffer-substring buf)
       (let* ((tmpf (make-temp-file "rustfmt"))
-             (ret (apply 'call-process-region
+             (ret (apply #'call-process-region
                          (point-min)
                          (point-max)
                          rust-rustfmt-bin
@@ -152,7 +152,7 @@ rustfmt complain in the echo area."
 (defconst rust--format-word "\
 \\b\\(else\\|enum\\|fn\\|for\\|if\\|let\\|loop\\|\
 match\\|struct\\|union\\|unsafe\\|while\\)\\b")
-(defconst rust--format-line "\\([\n]\\)")
+(defconst rust--format-line "\\(\n\\)")
 
 ;; Counts number of matches of regex beginning up to max-beginning,
 ;; leaving the point at the beginning of the last match.
@@ -239,7 +239,7 @@ match\\|struct\\|union\\|unsafe\\|while\\)\\b")
 Return the created process."
   (interactive)
   (unless (executable-find rust-rustfmt-bin)
-    (error "Could not locate executable \%s\"" rust-rustfmt-bin))
+    (error "Could not locate executable %S" rust-rustfmt-bin))
   (let* ((buffer
           (with-current-buffer
               (get-buffer-create "*rustfmt-diff*")
@@ -247,14 +247,14 @@ Return the created process."
               (erase-buffer))
             (current-buffer)))
          (proc
-          (apply 'start-process
+          (apply #'start-process
                  "rustfmt-diff"
                  buffer
                  rust-rustfmt-bin
                  "--check"
                  (cons (buffer-file-name)
                        rust-rustfmt-switches))))
-    (set-process-sentinel proc 'rust-format-diff-buffer-sentinel)
+    (set-process-sentinel proc #'rust-format-diff-buffer-sentinel)
     proc))
 
 (defun rust-format-diff-buffer-sentinel (process _e)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]