[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 6f075d7 224/352: Use syntax-propertize-function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 6f075d7 224/352: Use syntax-propertize-function on Emacs 24. |
Date: |
Sun, 29 Aug 2021 11:22:49 -0400 (EDT) |
branch: elpa/julia-mode
commit 6f075d72acde25d2a7598e022ae52610868c6fa7
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Use syntax-propertize-function on Emacs 24.
Fixes https://github.com/JuliaLang/julia/issues/11591
---
julia-mode.el | 79 +++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 58 insertions(+), 21 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index 368b5ce..7cf2f56 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -111,16 +111,17 @@ This function provides equivalent functionality, but
makes no efforts to optimis
table)
"Syntax table for `julia-mode'.")
-(defconst julia-char-regex
- (rx (or (any "-" ";" "\\" "^" "!" "|" "?" "*" "<" "%" "," "=" ">" "+" "/"
"&" "$" "~" ":")
- (syntax open-parenthesis)
- (syntax whitespace)
- bol)
- (group "'")
- (group
- (or (repeat 0 8 (not (any "'"))) (not (any "\\"))
- "\\\\"))
- (group "'")))
+(eval-when-compile
+ (defconst julia-char-regex
+ (rx (or (any "-" ";" "\\" "^" "!" "|" "?" "*" "<" "%" "," "=" ">" "+" "/"
"&" "$" "~" ":")
+ (syntax open-parenthesis)
+ (syntax whitespace)
+ bol)
+ (group "'")
+ (group
+ (or (repeat 0 8 (not (any "'"))) (not (any "\\"))
+ "\\\\"))
+ (group "'"))))
(defconst julia-triple-quoted-string-regex
;; We deliberately put a group on the first and last delimiter, so
@@ -254,6 +255,38 @@ This function provides equivalent functionality, but makes
no efforts to optimis
(defconst julia-block-end-keywords
(list "end" "else" "elseif" "catch" "finally"))
+(defun julia-stringify-triple-quote ()
+ "Put `syntax-table' property on triple-quoted string delimeters.
+
+Based on `python-syntax-stringify'."
+ (let* ((string-start-pos (- (point) 3))
+ (string-end-pos (point))
+ (ppss (prog2
+ (backward-char 3)
+ (syntax-ppss)
+ (forward-char 3)))
+ (in-comment (nth 4 ppss))
+ (in-string (nth 8 ppss)))
+ (unless in-comment
+ (if in-string
+ ;; We're in a string, so this must be the closing triple-quote.
+ ;; Put | on the last " character.
+ (put-text-property (1- string-end-pos) string-end-pos
+ 'syntax-table (string-to-syntax "|"))
+ ;; We're not in a string, so this is the opening triple-quote.
+ ;; Put | on the first " character.
+ (put-text-property string-start-pos (1+ string-start-pos)
+ 'syntax-table (string-to-syntax "|"))))))
+
+(defconst julia-syntax-propertize-function
+ (syntax-propertize-rules
+ ("\"\"\""
+ (0 (ignore (julia-stringify-triple-quote))))
+ (julia-char-regex
+ (1 "\"") ; Treat ' as a string delimiter.
+ (2 ".") ; Don't highlight anything between.
+ (3 "\"")))) ; Treat the last " in """ as a string delimiter.
+
(defun julia-in-comment ()
"Return non-nil if point is inside a comment.
Handles both single-line and multi-line comments."
@@ -605,17 +638,21 @@ c"))
(set (make-local-variable 'comment-start) "# ")
(set (make-local-variable 'comment-start-skip) "#+\\s-*")
(set (make-local-variable 'font-lock-defaults) '(julia-font-lock-keywords))
- (set (make-local-variable 'font-lock-syntactic-keywords)
- (list
- `(,julia-char-regex
- (1 "\"") ; Treat ' as a string delimiter.
- (2 ".") ; Don't highlight anything between the open and close '.
- (3 "\"")); Treat the close ' as a string delimiter.
- `(,julia-triple-quoted-string-regex
- (1 "\"") ; Treat the first " in """ as a string delimiter.
- (2 ".") ; Don't highlight anything between.
- (3 "\"")) ; Treat the last " in """ as a string delimiter.
- ))
+ (if (< emacs-major-version 24)
+ ;; Emacs 23 doesn't have syntax-propertize-function
+ (set (make-local-variable 'font-lock-syntactic-keywords)
+ (list
+ `(,julia-char-regex
+ (1 "\"") ; Treat ' as a string delimiter.
+ (2 ".") ; Don't highlight anything between the open and close '.
+ (3 "\"")); Treat the close ' as a string delimiter.
+ `(,julia-triple-quoted-string-regex
+ (1 "\"") ; Treat the first " in """ as a string delimiter.
+ (2 ".") ; Don't highlight anything between.
+ (3 "\"")))) ; Treat the last " in """ as a string delimiter.
+ ;; Emacs 24 and later has syntax-propertize-function, so use that instead.
+ (set (make-local-variable 'syntax-propertize-function)
+ julia-syntax-propertize-function))
(set (make-local-variable 'indent-line-function) 'julia-indent-line)
(set (make-local-variable 'julia-basic-offset) 4)
(setq indent-tabs-mode nil)
- [nongnu] elpa/julia-mode ad6a494 301/352: Merge pull request #78 from tpapp/tp/update-latexsubs, (continued)
- [nongnu] elpa/julia-mode ad6a494 301/352: Merge pull request #78 from tpapp/tp/update-latexsubs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 109747e 132/352: eliminate StoredArray (fix #6212, #987); UniformScaling is no longer an AbstractArray (#5810), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 84d9a19 147/352: Fix emacs highlighting of symbols that contain keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode fc04731 153/352: Highlight parameter types and subtypes., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 70d6482 160/352: `throw` and `error` are built-in functions that we should highlight., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ba5ba4c 168/352: Highlight function names when defined with the assignment syntax., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode caab4dc 172/352: Respect the active region when indenting., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e5f8145 191/352: Use a separate face for Julia macro invocations., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 493fb7f 192/352: note #8947 in julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 569d41a 206/352: julia-mode.el: stagedfunction, @[no]inline, indented functions, "=:symbol", ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6f075d7 224/352: Use syntax-propertize-function on Emacs 24.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 96499ff 209/352: Silence Emacs byte-compilation warnings., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c982fd6 216/352: Changed name of Emacs buffer to *Julia*, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7c1603c 226/352: Use more common name for indentation setting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode dd3d682 225/352: Fix Emacs 23 error., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 64d86a4 215/352: Added customization options, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c7e3232 218/352: some tuple redesign follow-ups, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 5ee867e 211/352: Changed inferior-julia function in contrib/julia-mode.el to apply, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 0c6673a 212/352: Changed input method for Julia Emacs buffer to TeX, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6781ef1 220/352: Fix #11673, bad indent after comments ending in =, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 892beb1 231/352: Fix #12528, ELPA Syncer, 2021/08/29