From a773e7ed865a1a7eb5bf00b9f0481e888534831a Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Sat, 9 Nov 2024 13:04:13 +0100 Subject: Upgrade markdown-mode, nginx-mode, rust-mode, yaml-mode and python-mode/property_getter --- .emacs.d/lisp/markdown-mode.el | 262 ++++++++++++++++++---------------- .emacs.d/lisp/nginx-mode.el | 30 ++-- .emacs.d/lisp/rust-cargo-tests.el | 53 +++++++ .emacs.d/lisp/rust-cargo.el | 55 ++++--- .emacs.d/lisp/rust-mode-treesitter.el | 13 +- .emacs.d/lisp/rust-mode.el | 10 +- .emacs.d/lisp/rust-prog-mode.el | 3 +- .emacs.d/lisp/rust-rustfmt.el | 4 +- .emacs.d/lisp/yaml-mode.el | 2 +- 9 files changed, 261 insertions(+), 171 deletions(-) create mode 100644 .emacs.d/lisp/rust-cargo-tests.el (limited to '.emacs.d/lisp') diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 33f7476..89d8962 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el @@ -684,52 +684,36 @@ This may also be a cons cell where the behavior for `C-a' and `C-e' is set separately." :group 'markdown :type '(choice - (const :tag "off" nil) - (const :tag "on: after hashes/bullet and before closing tags first" t) - (const :tag "reversed: true line boundary first" reversed) - (cons :tag "Set C-a and C-e separately" - (choice :tag "Special C-a" - (const :tag "off" nil) - (const :tag "on: after hashes/bullet first" t) - (const :tag "reversed: before hashes/bullet first" reversed)) - (choice :tag "Special C-e" - (const :tag "off" nil) - (const :tag "on: before closing tags first" t) - (const :tag "reversed: after closing tags first" reversed)))) + (const :tag "off" nil) + (const :tag "on: after hashes/bullet and before closing tags first" t) + (const :tag "reversed: true line boundary first" reversed) + (cons :tag "Set C-a and C-e separately" + (choice :tag "Special C-a" + (const :tag "off" nil) + (const :tag "on: after hashes/bullet first" t) + (const :tag "reversed: before hashes/bullet first" reversed)) + (choice :tag "Special C-e" + (const :tag "off" nil) + (const :tag "on: before closing tags first" t) + (const :tag "reversed: after closing tags first" reversed)))) :package-version '(markdown-mode . "2.7")) ;;; Markdown-Specific `rx' Macro ============================================== ;; Based on python-rx from python.el. -(eval-and-compile - (defconst markdown-rx-constituents - `((newline . ,(rx "\n")) - ;; Note: #405 not consider markdown-list-indent-width however this is never used - (indent . ,(rx (or (repeat 4 " ") "\t"))) - (block-end . ,(rx (and (or (one-or-more (zero-or-more blank) "\n") line-end)))) - (numeral . ,(rx (and (one-or-more (any "0-9#")) "."))) - (bullet . ,(rx (any "*+:-"))) - (list-marker . ,(rx (or (and (one-or-more (any "0-9#")) ".") - (any "*+:-")))) - (checkbox . ,(rx "[" (any " xX") "]"))) - "Markdown-specific sexps for `markdown-rx'") - - (defun markdown-rx-to-string (form &optional no-group) - "Markdown mode specialized `rx-to-string' function. -This variant supports named Markdown expressions in FORM. -NO-GROUP non-nil means don't put shy groups around the result." - (let ((rx-constituents (append markdown-rx-constituents rx-constituents))) - (rx-to-string form no-group))) - - (defmacro markdown-rx (&rest regexps) - "Markdown mode specialized rx macro. +(defmacro markdown-rx (&rest regexps) + "Markdown mode specialized rx macro. This variant of `rx' supports common Markdown named REGEXPS." - (cond ((null regexps) - (error "No regexp")) - ((cdr regexps) - (markdown-rx-to-string `(and ,@regexps) t)) - (t - (markdown-rx-to-string (car regexps) t))))) + `(rx-let ((newline "\n") + ;; Note: #405 not consider markdown-list-indent-width however this is never used + (indent (or (repeat 4 " ") "\t")) + (block-end (and (or (one-or-more (zero-or-more blank) "\n") line-end))) + (numeral (and (one-or-more (any "0-9#")) ".")) + (bullet (any "*+:-")) + (list-marker (or (and (one-or-more (any "0-9#")) ".") + (any "*+:-"))) + (checkbox (seq "[" (any " xX") "]"))) + (rx ,@regexps))) ;;; Regular Expressions ======================================================= @@ -1157,7 +1141,8 @@ Group 4 matches the text inside the delimiters.") "Property list of all Markdown syntactic properties.") (defvar markdown-literal-faces - '(markdown-inline-code-face + '(markdown-code-face + markdown-inline-code-face markdown-pre-face markdown-math-face markdown-url-face @@ -2804,8 +2789,9 @@ They does not include square brackets)." uris :test #'equal))) (reverse uris)))) -(defun markdown-inline-code-at-pos (pos) - "Return non-nil if there is an inline code fragment at POS. +(defun markdown-inline-code-at-pos (pos &optional from) + "Return non-nil if there is an inline code fragment at POS starting at FROM. +Uses the beginning of the block if FROM is nil. Return nil otherwise. Set match data according to `markdown-match-code' upon success. This function searches the block for a code fragment that @@ -2822,7 +2808,9 @@ Group 3 matches the closing backquotes." (let ((old-point (point)) (end-of-block (progn (markdown-end-of-text-block) (point))) found) - (markdown-beginning-of-text-block) + (if from + (goto-char from) + (markdown-beginning-of-text-block)) (while (and (markdown-match-code end-of-block) (setq found t) (< (match-end 0) old-point))) @@ -2970,28 +2958,42 @@ When FACELESS is non-nil, do not return matches where faces have been applied." (defun markdown-match-bold (last) "Match inline bold from the point to LAST." - (when (markdown-match-inline-generic markdown-regex-bold last) - (let ((is-gfm (derived-mode-p 'gfm-mode)) - (begin (match-beginning 2)) - (end (match-end 2))) - (if (or (markdown-inline-code-at-pos-p begin) - (markdown-inline-code-at-pos-p end) - (markdown-in-comment-p) - (markdown-range-property-any - begin begin 'face '(markdown-url-face - markdown-plain-url-face)) - (markdown-range-property-any - begin end 'face '(markdown-hr-face - markdown-math-face)) - (and is-gfm (not (markdown--gfm-markup-underscore-p begin end)))) - (progn (goto-char (min (1+ begin) last)) - (when (< (point) last) - (markdown-match-bold last))) - (set-match-data (list (match-beginning 2) (match-end 2) - (match-beginning 3) (match-end 3) - (match-beginning 4) (match-end 4) - (match-beginning 5) (match-end 5))) - t)))) + (let (done + retval + last-inline-code) + (while (not done) + (if (markdown-match-inline-generic markdown-regex-bold last) + (let ((is-gfm (derived-mode-p 'gfm-mode)) + (begin (match-beginning 2)) + (end (match-end 2))) + (if (or + (and last-inline-code + (>= begin (car last-inline-code)) + (< begin (cdr last-inline-code))) + (save-match-data + (when (markdown-inline-code-at-pos begin (cdr last-inline-code)) + (setq last-inline-code `(,(match-beginning 0) . ,(match-end 0))))) + (markdown-inline-code-at-pos-p end) + (markdown-in-comment-p) + (markdown-range-property-any + begin begin 'face '(markdown-url-face + markdown-plain-url-face)) + (markdown-range-property-any + begin end 'face '(markdown-hr-face + markdown-math-face)) + (and is-gfm (not (markdown--gfm-markup-underscore-p begin end)))) + (progn (goto-char (min (1+ begin) last)) + (unless (< (point) last) + (setq + done t))) + (set-match-data (list (match-beginning 2) (match-end 2) + (match-beginning 3) (match-end 3) + (match-beginning 4) (match-end 4) + (match-beginning 5) (match-end 5))) + (setq done t + retval t))) + (setq done t))) + retval)) (defun markdown-match-italic (last) "Match inline italics from the point to LAST." @@ -2999,37 +3001,51 @@ When FACELESS is non-nil, do not return matches where faces have been applied." (regex (if is-gfm markdown-regex-gfm-italic markdown-regex-italic))) - (when (and (markdown-match-inline-generic regex last) - (not (markdown--face-p - (match-beginning 1) - '(markdown-html-attr-name-face markdown-html-attr-value-face)))) - (let ((begin (match-beginning 1)) - (end (match-end 1)) - (close-end (match-end 4))) - (if (or (eql (char-before begin) (char-after begin)) - (markdown-inline-code-at-pos-p begin) - (markdown-inline-code-at-pos-p (1- end)) - (markdown-in-comment-p) - (markdown-range-property-any - begin begin 'face '(markdown-url-face - markdown-plain-url-face - markdown-markup-face)) - (markdown-range-property-any - begin end 'face '(markdown-bold-face - markdown-list-face - markdown-hr-face - markdown-math-face)) - (and is-gfm - (or (char-equal (char-after begin) (char-after (1+ begin))) ;; check bold case - (not (markdown--gfm-markup-underscore-p begin close-end))))) - (progn (goto-char (min (1+ begin) last)) - (when (< (point) last) - (markdown-match-italic last))) - (set-match-data (list (match-beginning 1) (match-end 1) - (match-beginning 2) (match-end 2) - (match-beginning 3) (match-end 3) - (match-beginning 4) (match-end 4))) - t))))) + (let (done + retval + last-inline-code) + (while (not done) + (if (and (markdown-match-inline-generic regex last) + (not (markdown--face-p + (match-beginning 1) + '(markdown-html-attr-name-face markdown-html-attr-value-face)))) + (let ((begin (match-beginning 1)) + (end (match-end 1)) + (close-end (match-end 4))) + (if (or (eql (char-before begin) (char-after begin)) + (and last-inline-code + (>= begin (car last-inline-code)) + (< begin (cdr last-inline-code))) + (save-match-data + (when (markdown-inline-code-at-pos begin (cdr last-inline-code)) + (setq last-inline-code `(,(match-beginning 0) . ,(match-end 0))))) + + (markdown-inline-code-at-pos-p (1- end)) + (markdown-in-comment-p) + (markdown-range-property-any + begin begin 'face '(markdown-url-face + markdown-plain-url-face + markdown-markup-face)) + (markdown-range-property-any + begin end 'face '(markdown-bold-face + markdown-list-face + markdown-hr-face + markdown-math-face)) + (and is-gfm + (or (char-equal (char-after begin) (char-after (1+ begin))) ;; check bold case + (not (markdown--gfm-markup-underscore-p begin close-end))))) + (progn (goto-char (min (1+ begin) last)) + (unless (< (point) last) + (setq + done t))) + (set-match-data (list (match-beginning 1) (match-end 1) + (match-beginning 2) (match-end 2) + (match-beginning 3) (match-end 3) + (match-beginning 4) (match-end 4))) + (setq done t + retval t))) + (setq done t))) + retval))) (defun markdown--match-highlighting (last) (when markdown-enable-highlighting-syntax @@ -3543,30 +3559,25 @@ SEQ may be an atom or a sequence." (add-text-properties (match-beginning 3) (match-end 3) rule-props))) ;; atx heading - (let ((header-end + (let ((fontified-start + (if (or markdown-hide-markup (not markdown-fontify-whole-heading-line)) + (match-beginning 5) + (match-beginning 0))) + (fontified-end (if markdown-fontify-whole-heading-line (min (point-max) (1+ (match-end 0))) - (match-end 0)))) + (match-end 5)))) (add-text-properties (match-beginning 4) (match-end 4) left-markup-props) ;; If closing tag is present (if (match-end 6) (progn - (if markdown-hide-markup - (progn - (add-text-properties - (match-beginning 5) header-end heading-props) - (add-text-properties - (match-beginning 6) (match-end 6) right-markup-props)) - (add-text-properties - (match-beginning 5) (match-end 5) heading-props) - (add-text-properties - (match-beginning 6) header-end right-markup-props))) + (add-text-properties fontified-start fontified-end heading-props) + (when (or markdown-hide-markup (not markdown-fontify-whole-heading-line)) + (add-text-properties (match-beginning 6) (match-end 6) right-markup-props))) ;; If closing tag is not present - (add-text-properties - (match-beginning 5) header-end heading-props)) - ))) + (add-text-properties fontified-start fontified-end heading-props))))) t)) (defun markdown-fontify-tables (last) @@ -3812,12 +3823,12 @@ prefixed with an integer from 1 to the length of (when (and beg skip-space) (save-excursion (goto-char beg) - (skip-chars-forward "[ \t]") + (skip-chars-forward " \t") (setq beg (point)))) (when (and end skip-space) (save-excursion (goto-char end) - (skip-chars-backward "[ \t]") + (skip-chars-backward " \t") (setq end (point)))) (markdown-wrap-or-insert start-delim end-delim nil beg end)) (if (markdown--face-p (point) (list face)) @@ -4894,7 +4905,7 @@ footnote text is found, NIL is returned." (save-excursion (goto-char (point-min)) (when (re-search-forward (concat "^ \\{0,3\\}\\[" id "\\]:") nil t) - (skip-chars-forward "[ \t]") + (skip-chars-forward " \t") (point)))) (defun markdown-footnote-marker-positions () @@ -7692,12 +7703,14 @@ Return the name of the output buffer used." Insert the output in the buffer named OUTPUT-BUFFER-NAME." (interactive) (setq output-buffer-name (markdown output-buffer-name)) - (with-current-buffer output-buffer-name - (set-buffer output-buffer-name) - (unless (markdown-output-standalone-p) - (markdown-add-xhtml-header-and-footer output-buffer-name)) - (goto-char (point-min)) - (html-mode)) + (let ((css-path markdown-css-paths)) + (with-current-buffer output-buffer-name + (set-buffer output-buffer-name) + (setq-local markdown-css-paths css-path) + (unless (markdown-output-standalone-p) + (markdown-add-xhtml-header-and-footer output-buffer-name)) + (goto-char (point-min)) + (html-mode))) output-buffer-name) (defun markdown-other-window (&optional output-buffer-name) @@ -9139,7 +9152,7 @@ position." (remove-text-properties start end '(face nil)) (with-current-buffer (get-buffer-create - (concat " markdown-code-fontification:" (symbol-name lang-mode))) + (format " *markdown-code-fontification:%s*" (symbol-name lang-mode))) ;; Make sure that modification hooks are not inhibited in ;; the org-src-fontification buffer in case we're called ;; from `jit-lock-function' (Bug#25132). @@ -10292,6 +10305,11 @@ rows and columns and the column alignment." (setq markdown-link-space-sub-char "-") (setq markdown-wiki-link-search-subdirectories t) (setq-local markdown-table-at-point-p-function #'gfm--table-at-point-p) + (setq-local paragraph-separate + (concat paragraph-separate + "\\|" + ;; GFM alert syntax + "^>\s-*\\[!\\(?:NOTE\\|TIP\\|IMPORTANT\\|WARNING\\|CAUTION\\)\\]")) (add-hook 'post-self-insert-hook #'gfm--electric-pair-fence-code-block 'append t) (markdown-gfm-parse-buffer-for-languages)) diff --git a/.emacs.d/lisp/nginx-mode.el b/.emacs.d/lisp/nginx-mode.el index b01367c..4a29d1e 100644 --- a/.emacs.d/lisp/nginx-mode.el +++ b/.emacs.d/lisp/nginx-mode.el @@ -5,7 +5,7 @@ ;; Author: Andrew J Cosgriff ;; Maintainer: Andrew J Cosgriff ;; Created: 15 Oct 2010 -;; Version: 1.1.9 +;; Version: 1.1.10 ;; Keywords: languages, nginx ;; available from http://github.com/ajc/nginx-mode @@ -33,6 +33,10 @@ ;; Put this file into your load-path and the following into your ~/.emacs: ;; (require 'nginx-mode) +;; +;; Now that nginx-mode is available via NonGNU ELPA, you could also: +;; (use-package nginx-mode +;; :commands nginx-mode) ;;; Code: @@ -76,24 +80,8 @@ "If point is in a block, return the indentation of the first line of that block (the line containing the opening brace). Used to set the indentation of the closing brace of a block." - (save-excursion - (save-match-data - (let ((opoint (point)) - (apoint (search-backward "{" nil t))) - (when apoint - ;; This is a bit of a hack and doesn't allow for strings. We really - ;; want to parse by sexps at some point. - (let ((close-braces (count-matches "}" apoint opoint)) - (open-braces 0)) - (while (and apoint (> close-braces open-braces)) - (setq apoint (search-backward "{" nil t)) - (when apoint - (setq close-braces (count-matches "}" apoint opoint)) - (setq open-braces (1+ open-braces))))) - (if apoint - (current-indentation) - nil)))))) - + (* (syntax-ppss-depth (syntax-ppss)) + nginx-indent-level)) (defun nginx-comment-line-p () "Return non-nil iff this line is a comment." @@ -112,11 +100,11 @@ of the closing brace of a block." (block-indent (nginx-block-indent)) cur-indent) (cond - ((and (looking-at "^\\s-*}\\s-*$") block-indent) + ((and (looking-at "^\\s-*}") block-indent) ;; This line contains a closing brace and we're at the inner ;; block, so we should indent it matching the indentation of ;; the opening brace of the block. - (setq cur-indent block-indent)) + (setq cur-indent (- block-indent nginx-indent-level))) (t ;; Otherwise, we did not start on a block-ending-only line. (save-excursion diff --git a/.emacs.d/lisp/rust-cargo-tests.el b/.emacs.d/lisp/rust-cargo-tests.el new file mode 100644 index 0000000..f49cba0 --- /dev/null +++ b/.emacs.d/lisp/rust-cargo-tests.el @@ -0,0 +1,53 @@ +;;; rust-cargo-tests.el --- ERT tests for rust-cargo.el -*- lexical-binding: t; -*- +(require 'rust-cargo) +(require 'ert) + +(defun rust-test--wait-process-exit () + "Wait for comint process for current buffer to exit." + (let ((proc (get-buffer-process (current-buffer)))) + (while (not (eq (process-status proc) 'exit)) + (sit-for 0.2)))) + +(defun rust-test--send-process-string (string) + "Send STRING to comint process for current buffer." + (let ((proc (get-buffer-process (current-buffer)))) + (comint-send-string proc string))) + +(defmacro rust-test--with-main-file-buffer (expr) + `(let* ((test-dir (expand-file-name "test-project/" default-directory)) + (main-file (expand-file-name "src/main.rs" test-dir))) + (save-current-buffer + (find-file main-file) + ,expr))) + +(defun rust-test--find-string (string) + "Find STRING in current buffer." + (goto-char (point-min)) + (not (null (search-forward string nil t)))) + + +(ert-deftest rust-test-compile () + (skip-unless (executable-find rust-cargo-bin)) + (setq rust-cargo-default-arguments "") + (rust-test--with-main-file-buffer + (with-current-buffer (rust-compile) + (rust-test--wait-process-exit) + (should (rust-test--find-string "Compilation finished"))))) + +(ert-deftest rust-test-run () + (skip-unless (executable-find rust-cargo-bin)) + (setq rust-cargo-default-arguments "") + (rust-test--with-main-file-buffer + (with-current-buffer (rust-run) + (rust-test--wait-process-exit) + (should (rust-test--find-string "***run not interactive"))))) + +(ert-deftest rust-test-run-interactive () + (skip-unless (executable-find rust-cargo-bin)) + (setq rust-cargo-default-arguments "interactive") + (rust-test--with-main-file-buffer + ;; '(4) is default value when called interactively with universal argument + (with-current-buffer (rust-run '(4)) + (rust-test--send-process-string "1234\n") + (rust-test--wait-process-exit) + (should (rust-test--find-string "***run interactive: 1234"))))) diff --git a/.emacs.d/lisp/rust-cargo.el b/.emacs.d/lisp/rust-cargo.el index bda23d8..d9f1be5 100644 --- a/.emacs.d/lisp/rust-cargo.el +++ b/.emacs.d/lisp/rust-cargo.el @@ -19,6 +19,13 @@ :type 'boolean :group 'rust-mode) +(defcustom rust-cargo-locate-default-arguments '("--workspace") + "Arguments for `cargo locate-project`. Remove `--workspace` if you +would prefer to use the local crate Cargo.toml instead of the +worksapce for commands like `cargo check`." + :type '(repeat string) + :group 'rust-mode) + (defcustom rust-cargo-default-arguments "" "Default arguments when running common cargo commands." :type 'string @@ -42,7 +49,13 @@ (setq-local process-environment env) ;; Set PATH so we can find cargo. (setq-local exec-path path) - (let ((ret (process-file rust-cargo-bin nil (list (current-buffer) nil) nil "locate-project" "--workspace"))) + (let ((ret + (let ((args + (append + (list rust-cargo-bin nil (list (current-buffer) nil) nil + "locate-project") + rust-cargo-locate-default-arguments))) + (apply #'process-file args)))) (when (/= ret 0) (error "`cargo locate-project' returned %s status: %s" ret (buffer-string))) (goto-char 0) @@ -67,46 +80,54 @@ ;;; Internal -(defun rust--compile (format-string &rest args) +(defun rust--compile (comint format-string &rest args) (when (null rust-buffer-project) (rust-update-buffer-project)) (let ((default-directory (or (and rust-buffer-project (file-name-directory rust-buffer-project)) - default-directory))) - (compile (apply #'format format-string args)))) + default-directory)) + ;; make sure comint is a boolean value + (comint (not (not comint)))) + (compile (apply #'format format-string args) comint))) ;;; Commands (defun rust-check () "Compile using `cargo check`" (interactive) - (rust--compile "%s check %s" rust-cargo-bin rust-cargo-default-arguments)) + (rust--compile nil "%s check %s" rust-cargo-bin rust-cargo-default-arguments)) (defun rust-compile () "Compile using `cargo build`" (interactive) - (rust--compile "%s build %s" rust-cargo-bin rust-cargo-default-arguments)) + (rust--compile nil "%s build %s" rust-cargo-bin rust-cargo-default-arguments)) (defun rust-compile-release () "Compile using `cargo build --release`" (interactive) - (rust--compile "%s build --release" rust-cargo-bin)) + (rust--compile nil "%s build --release" rust-cargo-bin)) -(defun rust-run () - "Run using `cargo run`" - (interactive) - (rust--compile "%s run %s" rust-cargo-bin rust-cargo-default-arguments)) +(defun rust-run (&optional comint) + "Run using `cargo run` -(defun rust-run-release () - "Run using `cargo run --release`" - (interactive) - (rust--compile "%s run --release" rust-cargo-bin)) +If optional arg COMINT is t or invoked with universal prefix arg, +output buffer will be in comint mode, i.e. interactive." + (interactive "P") + (rust--compile comint "%s run %s" rust-cargo-bin rust-cargo-default-arguments)) + +(defun rust-run-release (&optional comint) + "Run using `cargo run --release` + +If optional arg COMINT is t or invoked with universal prefix arg, +output buffer will be in comint mode, i.e. interactive." + (interactive "P") + (rust--compile comint "%s run --release" rust-cargo-bin)) (defun rust-test () "Test using `cargo test`" (interactive) - (rust--compile "%s test %s" rust-cargo-bin rust-cargo-default-arguments)) + (rust--compile nil "%s test %s" rust-cargo-bin rust-cargo-default-arguments)) (defun rust-run-clippy () "Run `cargo clippy'." @@ -118,7 +139,7 @@ ;; set `compile-command' temporarily so `compile' doesn't ;; clobber the existing value (compile-command (mapconcat #'shell-quote-argument args " "))) - (rust--compile compile-command))) + (rust--compile nil compile-command))) ;;; _ (provide 'rust-cargo) diff --git a/.emacs.d/lisp/rust-mode-treesitter.el b/.emacs.d/lisp/rust-mode-treesitter.el index 89c7cd4..5f84a00 100644 --- a/.emacs.d/lisp/rust-mode-treesitter.el +++ b/.emacs.d/lisp/rust-mode-treesitter.el @@ -5,12 +5,19 @@ ;;; Code: +(require 'rust-mode) + +;; Do not compile or load on Emacs releases that don't support +;; this. See https://github.com/rust-lang/rust-mode/issues/520. (when (version<= "29.1" emacs-version) - ;; We have the when macro because of - ;; https://github.com/rust-lang/rust-mode/issues/520 (require 'treesit) (require 'rust-ts-mode) - (require 'rust-common) + + ;; HACK: `rust-ts-mode' adds itself to the `auto-mode-alist' + ;; after us, so we need to readd `rust-mode' to the front of + ;; the list after loading `rust-ts-mode'. + (setq auto-mode-alist (delete '("\\.rs\\'" . rust-mode) auto-mode-alist)) + (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) (define-derived-mode rust-mode rust-ts-mode "Rust" "Major mode for Rust code. diff --git a/.emacs.d/lisp/rust-mode.el b/.emacs.d/lisp/rust-mode.el index a0f6542..8d38295 100644 --- a/.emacs.d/lisp/rust-mode.el +++ b/.emacs.d/lisp/rust-mode.el @@ -71,10 +71,6 @@ instead of `prog-mode'. This option requires emacs29+." map) "Keymap for Rust major mode.") -(if (and (version<= "29.1" emacs-version) rust-mode-treesitter-derive) - (require 'rust-mode-treesitter) - (require 'rust-prog-mode)) - ;;;###autoload (autoload 'rust-mode "rust-mode" "Major mode for Rust code." t) @@ -82,6 +78,12 @@ instead of `prog-mode'. This option requires emacs29+." (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) (provide 'rust-mode) + +(if (and rust-mode-treesitter-derive + (version<= "29.1" emacs-version)) + (require 'rust-mode-treesitter) + (require 'rust-prog-mode)) + (require 'rust-utils) ;;; rust-mode.el ends here diff --git a/.emacs.d/lisp/rust-prog-mode.el b/.emacs.d/lisp/rust-prog-mode.el index 51e802d..05bc5e0 100644 --- a/.emacs.d/lisp/rust-prog-mode.el +++ b/.emacs.d/lisp/rust-prog-mode.el @@ -4,7 +4,8 @@ ;; rust-mode code deriving from prog-mode instead of rust-ts-mode ;;; Code: -(require 'rust-common) + +(require 'rust-mode) (defvar electric-pair-inhibit-predicate) (defvar electric-pair-skip-self) diff --git a/.emacs.d/lisp/rust-rustfmt.el b/.emacs.d/lisp/rust-rustfmt.el index f609980..cab183c 100644 --- a/.emacs.d/lisp/rust-rustfmt.el +++ b/.emacs.d/lisp/rust-rustfmt.el @@ -87,8 +87,8 @@ (insert-file-contents tmpf) (rust--format-fix-rustfmt-buffer (buffer-name buf)) (error "Rustfmt failed, see %s buffer for details" - rust-rustfmt-buffername)))) - (delete-file tmpf)))))) + rust-rustfmt-buffername))) + (delete-file tmpf))))))) ;; Since we run rustfmt through stdin we get markers in the ;; output. This replaces them with the buffer name instead. diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el index 9706f6b..c748b6c 100644 --- a/.emacs.d/lisp/yaml-mode.el +++ b/.emacs.d/lisp/yaml-mode.el @@ -103,7 +103,7 @@ that key is pressed to begin a block literal." (defface yaml-tab-face '((((class color)) (:background "red" :foreground "red" :bold t)) - (t (:reverse-video t))) + (t (:inverse-video t))) "Face to use for highlighting tabs in YAML files." :group 'faces :group 'yaml) -- cgit v1.3