emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/go-mode 58640c3 080/495: Do not consider \ an escape chara


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 58640c3 080/495: Do not consider \ an escape character when in raw strings
Date: Sat, 7 Aug 2021 09:04:47 -0400 (EDT)

branch: elpa/go-mode
commit 58640c38b2f4e4f8f3797a265de40b69457d0795
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    Do not consider \ an escape character when in raw strings
    
    This implementation generally considers *all* \ in \` sequences as
    non-escaping and doesn't touch other occurences of \.
    
    This has two implications:
    
    1) \` inside other structures, such as quoted strings and comments is
    also not an escape sequence
    
    2) other escape sequences are still considered escape sequences in raw
    strings
    
    The assumption here is that neither is a problem, because other escape
    sequences in raw strings do not affect syntax parsing or
    fontification, and \` is not a valid escape sequence in other
    structures, so should not affect parsing or fontification, either.
    
    If either of those two assumptions turns out to be false, we'll need
    to refine this implementation.
---
 go-mode.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/go-mode.el b/go-mode.el
index fd1839d..deacd80 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -285,6 +285,10 @@ functions, and some types.  It also provides indentation 
that is
 
   (set (make-local-variable 'beginning-of-defun-function) 
'go-beginning-of-defun)
   (set (make-local-variable 'end-of-defun-function) 'go-end-of-defun)
+
+  (set (make-local-variable 'parse-sexp-lookup-properties) t)
+  (set (make-local-variable 'syntax-propertize-function) 'go-propertize-syntax)
+
   (set (make-local-variable 'go-dangling-cache) #s(hash-table test eql))
   (add-to-list 'before-change-functions (lambda (x y) (setq go-dangling-cache 
#s(hash-table test eql))))
 
@@ -541,6 +545,12 @@ buffer. Tries to look for a URL at point."
         (go-mode)
         (switch-to-buffer buffer)))))
 
+(defun go-propertize-syntax (start end)
+  (save-excursion
+      (goto-char start)
+      (while (search-forward "\\" end t)
+        (put-text-property (1- (point)) (point) 'syntax-table (if (= 
(char-after) ?`) '(1) '(9))))))
+
 ;; ;; Commented until we actually make use of this function
 ;; (defun go--common-prefix (sequences)
 ;;   ;; mismatch and reduce are cl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]