Skip to content

Commit

Permalink
Merge pull request #534 from tarsiiformes/fixup
Browse files Browse the repository at this point in the history
Fix ancient defect and dependency complications related to having two rust-mode implementations
  • Loading branch information
psibi committed Mar 29, 2024
2 parents 150b61f + 7c5de03 commit b2b18aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions rust-mode-treesitter.el
Expand Up @@ -5,12 +5,13 @@

;;; 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)

(define-derived-mode rust-mode rust-ts-mode "Rust"
"Major mode for Rust code.
Expand Down
10 changes: 6 additions & 4 deletions rust-mode.el
Expand Up @@ -71,17 +71,19 @@ 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)

;;;###autoload
(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
3 changes: 2 additions & 1 deletion rust-prog-mode.el
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions rust-rustfmt.el
Expand Up @@ -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 <stdin> markers in the
;; output. This replaces them with the buffer name instead.
Expand Down

0 comments on commit b2b18aa

Please sign in to comment.