diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2020-02-18 18:44:59 +0100 |
|---|---|---|
| committer | Nathan Moreau <nathan.moreau@m4x.org> | 2020-07-09 09:13:29 +0200 |
| commit | 7afad7b043364ef21e36bc40eb454aea81505eb2 (patch) | |
| tree | bf5fd1a58a6459d84b0b47da9825f3593ab60960 /rust-mode.el | |
| parent | c23453df6d89c2b3151f8dd912398e563f232ffd (diff) | |
| download | rust-mode-7afad7b043364ef21e36bc40eb454aea81505eb2.tar.gz | |
rearrange II: Regexp variables and functions
Diffstat (limited to 'rust-mode.el')
| -rw-r--r-- | rust-mode.el | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/rust-mode.el b/rust-mode.el index d7a03ba..8571a9c 100644 --- a/rust-mode.el +++ b/rust-mode.el @@ -144,18 +144,6 @@ to the function arguments. When nil, `->' will be indented one level." (defconst rust-re-ident "[[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*") (defconst rust-re-lc-ident "[[:lower:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*") (defconst rust-re-uc-ident "[[:upper:]][[:word:][:multibyte:]_[:digit:]]*") -(defconst rust-re-unsafe "unsafe") -(defconst rust-re-extern "extern") -(defconst rust-re-async-or-const "async\\|const") -(defconst rust-re-generic - (concat "<[[:space:]]*'" rust-re-ident "[[:space:]]*>")) -(defconst rust-re-union - (rx-to-string - `(seq - (or space line-start) - (group symbol-start "union" symbol-end) - (+ space) (regexp ,rust-re-ident)))) - (defvar rust-re-vis ;; pub | pub ( crate ) | pub ( self ) | pub ( super ) | pub ( in SimplePath ) (concat @@ -174,8 +162,23 @@ to the function arguments. When nil, `->' will be indented one level." (rust-re-shy (concat "::" rust-re-ident)) "*")))) "[[:space:]]*)")) "?")) +(defconst rust-re-unsafe "unsafe") +(defconst rust-re-extern "extern") +(defconst rust-re-async-or-const "async\\|const") +(defconst rust-re-generic + (concat "<[[:space:]]*'" rust-re-ident "[[:space:]]*>")) +(defconst rust-re-union + (rx-to-string + `(seq + (or space line-start) + (group symbol-start "union" symbol-end) + (+ space) (regexp ,rust-re-ident)))) + +(defun rust-re-item-def (itype) + (concat (rust-re-word itype) + (rust-re-shy rust-re-generic) "?" + "[[:space:]]+" (rust-re-grab rust-re-ident))) -;;; Start of a Rust item (defvar rust-top-item-beg-re (concat "\\s-*" ;; TODO some of this does only make sense for `fn' (unsafe, extern...) @@ -189,6 +192,18 @@ to the function arguments. When nil, `->' will be indented one level." "\\_>") "Start of a Rust item.") +;; TODO some of this does only make sense for `fn' (unsafe, extern...) +;; and not other items +(defun rust-re-item-def-imenu (itype) + (concat "^[[:space:]]*" + (rust-re-shy (concat rust-re-vis "[[:space:]]+")) "?" + (rust-re-shy (concat (rust-re-word "default") "[[:space:]]+")) "?" + (rust-re-shy (concat (rust-re-shy rust-re-async-or-const) "[[:space:]]+")) "?" + (rust-re-shy (concat (rust-re-word rust-re-unsafe) "[[:space:]]+")) "?" + (rust-re-shy (concat (rust-re-word rust-re-extern) "[[:space:]]+" + (rust-re-shy "\"[^\"]+\"[[:space:]]+") "?")) "?" + (rust-re-item-def itype))) + (defun rust-looking-back-str (str) "Return non-nil if there's a match on the text before point and STR. Like `looking-back' but for fixed strings rather than regexps (so @@ -713,22 +728,6 @@ buffer." symbol-end)) (defconst rust-re-pre-expression-operators "[-=!%&*/:<>[{(|.^;}]") -(defun rust-re-item-def (itype) - (concat (rust-re-word itype) - (rust-re-shy rust-re-generic) "?" - "[[:space:]]+" (rust-re-grab rust-re-ident))) - -;; TODO some of this does only make sense for `fn' (unsafe, extern...) -;; and not other items -(defun rust-re-item-def-imenu (itype) - (concat "^[[:space:]]*" - (rust-re-shy (concat rust-re-vis "[[:space:]]+")) "?" - (rust-re-shy (concat (rust-re-word "default") "[[:space:]]+")) "?" - (rust-re-shy (concat (rust-re-shy rust-re-async-or-const) "[[:space:]]+")) "?" - (rust-re-shy (concat (rust-re-word rust-re-unsafe) "[[:space:]]+")) "?" - (rust-re-shy (concat (rust-re-word rust-re-extern) "[[:space:]]+" - (rust-re-shy "\"[^\"]+\"[[:space:]]+") "?")) "?" - (rust-re-item-def itype))) (defconst rust-re-special-types (regexp-opt rust-special-types 'symbols)) |
