Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package.el friendly rust mode #3189

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/etc/emacs/cm-mode.el
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
;; Wrapper for CodeMirror-style emacs modes. Highlighting is done by
;; running a stateful parser (with first-class state object) over the
;; buffer, line by line, using the output to add 'face properties, and
;; storing the parser state at the end of each line. Indentation is
;; done based on the parser state at the start of the line.
;;; cm-mode.el --- Wrapper for CodeMirror-style Emacs modes

;; Version: 0.1.0
;; Url: https://github.com/mozilla/rust

;; Highlighting is done by running a stateful parser (with first-class
;; state object) over the buffer, line by line, using the output to
;; add 'face properties, and storing the parser state at the end of
;; each line. Indentation is done based on the parser state at the
;; start of the line.

(eval-when-compile (require 'cl))

Expand Down Expand Up @@ -163,7 +168,7 @@
(cm-schedule-work 0.05)))))

(defun cm-do-some-work ()
(save-excursion
(save-excursion
(condition-case cnd (cm-do-some-work-inner)
(error (print cnd) (error cnd)))))

Expand All @@ -174,6 +179,7 @@

;; Entry function

;;;###autoload
(defun cm-mode (mode)
(set (make-local-variable 'cm-cur-mode) mode)
(set (make-local-variable 'cm-worklist) (list (copy-marker 1)))
Expand All @@ -184,3 +190,5 @@
(cm-schedule-work 0.05))

(provide 'cm-mode)

;;; cm-mode.el ends here
9 changes: 9 additions & 0 deletions src/etc/emacs/rust-mode.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
;;; rust-mode.el --- A major emacs mode for editing Rust source code

;; Version: 0.1.0
;; Package-Requires: ((cm-mode "0.1.0"))
;; Url: https://github.com/mozilla/rust

(require 'cm-mode)
(require 'cc-mode)

Expand Down Expand Up @@ -277,6 +283,7 @@
((eq (rust-context-align cx) t) (+ (rust-context-column cx) (if closing -1 0)))
(t (+ base (if closing 0 unit)))))))

;;;###autoload
(define-derived-mode rust-mode fundamental-mode "Rust"
"Major mode for editing Rust source files."
(set-syntax-table rust-syntax-table)
Expand All @@ -293,3 +300,5 @@
(define-key rust-mode-map "{" 'rust-electric-brace)

(provide 'rust-mode)

;;; rust-mode.el ends here