[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 11e3904 176/352: Backporting regexp-opt functio
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 11e3904 176/352: Backporting regexp-opt functionality to Emacs 23. |
Date: |
Sun, 29 Aug 2021 11:22:39 -0400 (EDT) |
branch: elpa/julia-mode
commit 11e3904af277157166ff62552e76ae4aa31c50b2
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Backporting regexp-opt functionality to Emacs 23.
See https://github.com/JuliaLang/julia/issues/8537
---
julia-mode.el | 57 +++++++++++++++++++++++++++++++++++----------------------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index a41aba7..d67b028 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -47,6 +47,19 @@
(when (not (fboundp 'ignore-errors))
(defmacro ignore-errors (body) `(condition-case nil ,body (error nil))))
+(defun julia--regexp-opt (strings &optional paren)
+ "Emacs 23 provides `regexp-opt', but it does not support PAREN taking the
value 'symbols.
+This function provides equivalent functionality, but makes no efforts to
optimise the regexp."
+ (cond
+ ((>= emacs-major-version 24)
+ (regexp-opt strings paren))
+ ((not (eq paren 'symbols))
+ (regexp-opt strings paren))
+ ((null strings)
+ "")
+ ('t
+ (rx-to-string `(seq symbol-start (or ,@strings) symbol-end)))))
+
(defvar julia-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?_ "_" table)
@@ -140,7 +153,7 @@
(rx symbol-start (group "@" (1+ (or word (syntax symbol))))))
(defconst julia-keyword-regex
- (regexp-opt
+ (julia--regexp-opt
'("if" "else" "elseif" "while" "for" "begin" "end" "quote"
"try" "catch" "return" "local" "abstract" "function" "macro" "ccall"
"finally" "typealias" "break" "continue" "type" "global"
@@ -149,13 +162,13 @@
'symbols))
(defconst julia-builtin-regex
- (regexp-opt
+ (julia--regexp-opt
;;'("error" "throw")
'()
'symbols))
(defconst julia-builtin-types-regex
- (regexp-opt
+ (julia--regexp-opt
'("Number" "Real" "BigInt" "Integer"
"Uint" "Uint8" "Uint16" "Uint32" "Uint64" "Uint128"
"Int" "Int8" "Int16" "Int32" "Int64" "Int128"
@@ -171,25 +184,25 @@
(defconst julia-font-lock-keywords
(list
- (cons julia-builtin-types-regex 'font-lock-type-face)
- (cons julia-keyword-regex 'font-lock-keyword-face)
- (cons julia-macro-regex 'font-lock-keyword-face)
- (cons
- (regexp-opt
- '("true" "false" "C_NULL" "Inf" "NaN" "Inf32" "NaN32" "nothing")
- 'symbols)
- 'font-lock-constant-face)
- (list julia-unquote-regex 2 'font-lock-constant-face)
- (list julia-char-regex 2 'font-lock-string-face)
- (list julia-forloop-in-regex 1 'font-lock-keyword-face)
- (list julia-function-regex 1 'font-lock-function-name-face)
- (list julia-function-assignment-regex 1 'font-lock-function-name-face)
- (list julia-type-regex 1 'font-lock-type-face)
- (list julia-type-annotation-regex 1 'font-lock-type-face)
- ;;(list julia-type-parameter-regex 1 'font-lock-type-face)
- (list julia-subtype-regex 1 'font-lock-type-face)
- (list julia-builtin-regex 1 'font-lock-builtin-face)
-))
+ (cons julia-builtin-types-regex 'font-lock-type-face)
+ (cons julia-keyword-regex 'font-lock-keyword-face)
+ (cons julia-macro-regex 'font-lock-keyword-face)
+ (cons
+ (julia--regexp-opt
+ '("true" "false" "C_NULL" "Inf" "NaN" "Inf32" "NaN32" "nothing")
+ 'symbols)
+ 'font-lock-constant-face)
+ (list julia-unquote-regex 2 'font-lock-constant-face)
+ (list julia-char-regex 2 'font-lock-string-face)
+ (list julia-forloop-in-regex 1 'font-lock-keyword-face)
+ (list julia-function-regex 1 'font-lock-function-name-face)
+ (list julia-function-assignment-regex 1 'font-lock-function-name-face)
+ (list julia-type-regex 1 'font-lock-type-face)
+ (list julia-type-annotation-regex 1 'font-lock-type-face)
+ ;;(list julia-type-parameter-regex 1 'font-lock-type-face)
+ (list julia-subtype-regex 1 'font-lock-type-face)
+ (list julia-builtin-regex 1 'font-lock-builtin-face)
+ ))
(defconst julia-block-start-keywords
(list "if" "while" "for" "begin" "try" "function" "type" "let" "macro"
- [nongnu] elpa/julia-mode c2f0ed8 235/352: julia-mode: Fix prompt regexp, (continued)
- [nongnu] elpa/julia-mode c2f0ed8 235/352: julia-mode: Fix prompt regexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode a95b06b 252/352: Merge pull request #20 from tpapp/indent-export, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 847908e 249/352: Add indent for import and export., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7b1d3fb 253/352: Merge pull request #21 from kshramt/python-paren-indent, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f591c6d 275/352: Merge pull request #41 from rfourquet/rf/where-return, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8449c95 295/352: Merge pull request #69 from emmt/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 47d2fb0 282/352: Merge pull request #51 from non-Jedi/arg-list, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e27e6d2 290/352: fix compilation error, silence byte-compiler warnings in emacs>23, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7102542 304/352: fix tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 646f758 156/352: Don't skip over end keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 11e3904 176/352: Backporting regexp-opt functionality to Emacs 23.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 36aa038 181/352: Fix julia-in-brackets so it isn't confused by strings, characters or comments., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d7a7607 184/352: Make julia-last-open-block-pos a pure function that only returns the position., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 3597e9a 186/352: Comment improvements., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6603c79 190/352: rename Uint -> UInt in contrib files for syntax highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f3f2ad1 198/352: Highlight triple quoted strings., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 65cfc0d 201/352: julia-mode.el: add a bunch of builtin types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode fabafad 200/352: julia-mode.el: improve matching of function assignment syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4b41b85 207/352: julia-mode.el: `f(x) == something` does not define a function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode a37d541 214/352: Changed input from TeX mode to use Julia unicode input, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 2e72a0b 213/352: Removed (setq comint-proccess-echoes t) from contrib/julia-mode.el, ELPA Syncer, 2021/08/29