[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 73ff68c 198/495: handle backslash in raw string in
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 73ff68c 198/495: handle backslash in raw string in Emacs 23 |
Date: |
Sat, 7 Aug 2021 09:05:12 -0400 (EDT) |
branch: elpa/go-mode
commit 73ff68c6f425595ac247b8cd8362081f366e28c0
Author: Rui Ueyama <ruiu@google.com>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
handle backslash in raw string in Emacs 23
Go-mode in Emacs 23 does not recognize a backslash followed
by a backquote as end of raw string literal, as it does not
support syntax-propertize-function which Go-mode uses to
remove special meaning from backslashes in ``.
This patch provides a fallback mechanism to do the same thing
using font-lock-syntactic-keywords, which is supported by
Emacs 23.
---
go-mode.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/go-mode.el b/go-mode.el
index 4704e41..fbae855 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -281,6 +281,7 @@ For mode=set, all covered lines will have this weight."
`((,go-func-meth-regexp 2 font-lock-function-name-face))) ;; method name
`(
+ ("\\(`[^`]*`\\)" 1 font-lock-multiline) ;; raw string literal, needed for
font-lock-syntactic-keywords
(,(concat (go--regexp-enclose-in-symbol "type")
"[[:space:]]+\\([^[:space:]]+\\)") 1 font-lock-type-face) ;; types
(,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+"
go-identifier-regexp "[[:space:]]*" go-type-name-regexp) 1 font-lock-type-face)
;; types
(,(concat "[^[:word:][:multibyte:]]\\[\\([[:digit:]]+\\|\\.\\.\\.\\)?\\]"
go-type-name-regexp) 2 font-lock-type-face) ;; Arrays/slices
@@ -299,6 +300,14 @@ For mode=set, all covered lines will have this weight."
(,(concat "^[[:space:]]*\\(" go-label-regexp
"\\)[[:space:]]*:\\(\\S.\\|$\\)") 1 font-lock-constant-face) ;; Labels and
compound literal fields
(,(concat (go--regexp-enclose-in-symbol "\\(goto\\|break\\|continue\\)")
"[[:space:]]*\\(" go-label-regexp "\\)") 2 font-lock-constant-face)))) ;;
labels in goto/break/continue
+(defconst go--font-lock-syntactic-keywords
+ ;; Override syntax property of raw string literal contents, so that
+ ;; backslashes have no special meaning in ``. Used in Emacs 23 or older.
+ '(("\\(`\\)\\([^`]*\\)\\(`\\)"
+ (1 (7 . ?`))
+ (2 (15 . nil)) ;; 15 = "generic string"
+ (3 (7 . ?`)))))
+
(defvar go-mode-map
(let ((m (make-sparse-keymap)))
(define-key m "}" #'go-mode-insert-and-indent)
@@ -573,7 +582,10 @@ recommended that you look at goflymake
(set (make-local-variable 'parse-sexp-lookup-properties) t)
(if (boundp 'syntax-propertize-function)
- (set (make-local-variable 'syntax-propertize-function)
#'go-propertize-syntax))
+ (set (make-local-variable 'syntax-propertize-function)
#'go-propertize-syntax)
+ (set (make-local-variable 'font-lock-syntactic-keywords)
+ go--font-lock-syntactic-keywords)
+ (set (make-local-variable 'font-lock-multiline) t))
(set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql))
(add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache
(make-hash-table :test 'eql))) t t)
- [nongnu] elpa/go-mode ff30ae1 190/495: use (function) for function symbols, (continued)
- [nongnu] elpa/go-mode ff30ae1 190/495: use (function) for function symbols, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 50fb3b2 192/495: allow users to customize the gofmt command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 49c885d 188/495: (foo)(bar) is not a function call when there's a letter directly preceding it, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 83c4e32 185/495: fix typo, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b4cbae5 193/495: minor cleanups, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4a96be2 186/495: handle empty "import ()" in go-goto-imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4055561 191/495: Don't break on emacsen that don't have declare-function macro, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ad5e273 203/495: suggest flycheck as well as flymake and fix URL markup, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 26ca1fd 199/495: do not highlight built-in function if not followed by '(', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 192c9e2 195/495: Use "point" argument instead of return value of point function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 73ff68c 198/495: handle backslash in raw string in Emacs 23,
ELPA Syncer <=
- [nongnu] elpa/go-mode 1071ac6 209/495: simplify godef--successful-p, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c597843 214/495: import Go's license, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c2bf889 217/495: remove all references to upstream misc/emacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3fb128a 219/495: Highlight type names in function parameter list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3300479 225/495: fix beginning-of-defun when point is near the start of a function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 948dbeb 226/495: Issue 61., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode be58a4a 227/495: add go-mode-autoloads.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0bcbcf1 228/495: refine install instructions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3fdac08 233/495: use quit-window to hide the gofmt error window, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 50e7182 234/495: fix several `checkdoc' errors., ELPA Syncer, 2021/08/07