[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 67bb849 108/495: use \\_< instead of \\< and do so
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 67bb849 108/495: use \\_< instead of \\< and do so in a way that won't break XEmacs |
Date: |
Sat, 7 Aug 2021 09:04:53 -0400 (EDT) |
branch: elpa/go-mode
commit 67bb8490d22fcbf1ab12cf3f0ea2c2cbc0ecd67c
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
use \\_< instead of \\< and do so in a way that won't break XEmacs
---
go-mode.el | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index a60876f..983bf9b 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -9,12 +9,26 @@
(require 'find-lisp)
(require 'url)
+(defun go--xemacs-p ()
+ (string-match "XEmacs\\|Lucid" emacs-version))
+
+(defun go--regexp-enclose-in-symbol (s)
+ ;; XEmacs does not support \_<, GNU Emacs does. In GNU Emacs we make
+ ;; extensive use of \_< to support unicode in identifiers. Until we
+ ;; come up with a better solution for XEmacs, this solution will
+ ;; break fontification in XEmacs for identifiers such as "typeµ".
+ ;; XEmacs will consider "type" a keyword, GNU Emacs won't.
+
+ (if (go--xemacs-p)
+ (concat "\\<" s "\\>")
+ (concat "\\_<" s "\\_>")))
+
(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]")
(defconst go-identifier-regexp "[[:word:][:multibyte:]_]+")
(defconst go-label-regexp go-identifier-regexp)
(defconst go-type-regexp "[[:word:][:multibyte:]_*]+")
-(defconst go-func-regexp (concat "\\<func\\>\\s *\\(" go-identifier-regexp
"\\)"))
-(defconst go-func-meth-regexp (concat "\\<func\\>\\s *\\(?:(\\s *"
go-identifier-regexp "\\s +" go-type-regexp "\\s *)\\s *\\)?\\("
go-identifier-regexp "\\)("))
+(defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s
*\\(" go-identifier-regexp "\\)"))
+(defconst go-func-meth-regexp (concat (go--regexp-enclose-in-symbol "func")
"\\s *\\(?:(\\s *" go-identifier-regexp "\\s +" go-type-regexp "\\s *)\\s
*\\)?\\(" go-identifier-regexp "\\)("))
(defconst go-builtins
'("append" "cap" "close" "complex" "copy"
"delete" "imag" "len" "make" "new"
@@ -71,9 +85,9 @@
;; we cannot use 'symbols in regexp-opt because emacs <24 doesn't
;; understand that
(append
- `((,(concat "\\_<"(regexp-opt go-mode-keywords) "\\_>") .
font-lock-keyword-face)
- (,(concat "\\_<" (regexp-opt go-builtins) "\\_>") .
font-lock-builtin-face)
- (,(concat "\\_<" (regexp-opt go-constants) "\\_>") .
font-lock-constant-face)
+ `((,(go--regexp-enclose-in-symbol (regexp-opt go-mode-keywords t)) .
font-lock-keyword-face)
+ (,(go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) .
font-lock-builtin-face)
+ (,(go--regexp-enclose-in-symbol (regexp-opt go-constants t)) .
font-lock-constant-face)
(,go-func-regexp 1 font-lock-function-name-face)) ;; function (not
method) name
(if go-fontify-function-calls
@@ -82,22 +96,22 @@
`((,go-func-meth-regexp 1 font-lock-function-name-face))) ;; method name
`(
- ("\\<type\\>[[:space:]]*\\([^[:space:]]+\\)" 1 font-lock-type-face) ;;
types
- (,(concat "\\<type\\>[[:space:]]*" go-identifier-regexp "[[:space:]]*"
go-type-name-regexp) 1 font-lock-type-face) ;; types
+ (,(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
"\\(?:[[:space:]]+\\|\\]\\)\\[\\([[:digit:]]+\\|\\.\\.\\.\\)?\\]"
go-type-name-regexp) 2 font-lock-type-face) ;; Arrays/slices
(,(concat "map\\[[^]]+\\]" go-type-name-regexp) 1 font-lock-type-face) ;;
map value type
(,(concat "\\(" go-identifier-regexp "\\)" "{") 1 font-lock-type-face)
- (,(concat "\\<map\\[" go-type-name-regexp) 1 font-lock-type-face) ;; map
key type
- (,(concat "\\<chan\\>[[:space:]]*\\(?:<-\\)?" go-type-name-regexp) 1
font-lock-type-face) ;; channel type
- (,(concat "\\<\\(?:new\\|make\\)\\>\\(?:[[:space:]]\\|)\\)*("
go-type-name-regexp) 1 font-lock-type-face) ;; new/make type
+ (,(concat (go--regexp-enclose-in-symbol "map") "\\[" go-type-name-regexp)
1 font-lock-type-face) ;; map key type
+ (,(concat (go--regexp-enclose-in-symbol "chan") "[[:space:]]*\\(?:<-\\)?"
go-type-name-regexp) 1 font-lock-type-face) ;; channel type
+ (,(concat (go--regexp-enclose-in-symbol "\\(?:new\\|make\\)")
"\\(?:[[:space:]]\\|)\\)*(" go-type-name-regexp) 1 font-lock-type-face) ;;
new/make type
;; TODO do we actually need this one or isn't it just a function call?
(,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type
conversion
- (,(concat "\\<func\\>[[:space:]]+(" go-identifier-regexp "[[:space:]]+"
go-type-name-regexp ")") 1 font-lock-type-face) ;; Method receiver
+ (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+("
go-identifier-regexp "[[:space:]]+" go-type-name-regexp ")") 1
font-lock-type-face) ;; Method receiver
;; Like the original go-mode this also marks compound literal
;; fields. There, it was marked as to fix, but I grew quite
;; accustomed to it, so it'll stay for now.
(,(concat "^[[:space:]]*\\(" go-label-regexp
"\\)[[:space:]]*:\\(\\S.\\|$\\)") 1 font-lock-constant-face) ;; Labels and
compound literal fields
- (,(concat "\\<\\(goto\\|break\\|continue\\)\\>[[:space:]]*\\("
go-label-regexp "\\)") 2 font-lock-constant-face)))) ;; labels in
goto/break/continue
+ (,(concat (go--regexp-enclose-in-symbol "\\(goto\\|break\\|continue\\)")
"[[:space:]]*\\(" go-label-regexp "\\)") 2 font-lock-constant-face)))) ;;
labels in goto/break/continue
(defvar go-mode-map
(let ((m (make-sparse-keymap)))
- [nongnu] elpa/go-mode d7c48cb 089/495: give in and require cl at runtime, (continued)
- [nongnu] elpa/go-mode d7c48cb 089/495: give in and require cl at runtime, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 23310e5 090/495: be more lenient when finding commented imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2d500b3 091/495: builtins and keywords need to be surrounded by symbols, not word characters, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 71c7f59 101/495: use correct regexps for labels, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3139c0f 107/495: fix regexp-opt usage for emacs <24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8fb900e 062/495: refactor, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 183c028 068/495: use (car (last)) instead of (car (reverse)), ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0f71cee 083/495: add autoload cookie to gofmt-before-save, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f0059f6 098/495: in go-packages, skip over directories that do not contain a /pkg subdirectory, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3d3ba73 103/495: Use completing-read in godoc--read-query, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 67bb849 108/495: use \\_< instead of \\< and do so in a way that won't break XEmacs,
ELPA Syncer <=
- [nongnu] elpa/go-mode 4637dd6 110/495: Mention gofmt rewrite in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d910a0d 112/495: Make _ a word constituent to accomodate inferiority of XEmacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c1074a1 114/495: improve regexps for array, slice and map types, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a88f1d5 115/495: add support for godef, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4935203 117/495: add guidelines for contributions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0e5fd93 119/495: update LEGAL, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 92102a5 120/495: do not rely on find-lisp, xemacs doesn't have that, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bb66ca4 122/495: xemacs comment handling, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8476d21 123/495: provide alternative to syntax-ppss for older versions of xemacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 052a356 125/495: remove unused variables, ELPA Syncer, 2021/08/07