@@ -1944,29 +1944,33 @@ See `sp-get-buffer-char-syntax'."
19441944 (setq p (or p (point)))
19451945 (sp-get-buffer-char-syntax (1- p)))
19461946
1947- (defun sp-syntax-after-is-prefix (&optional p)
1947+ (defun sp-syntax-after-is-prefix (check-prefix-flag &optional p)
19481948 "Check that the character after P has prefix syntax.
19491949
19501950Prefix syntax can either come from the global major-mode syntax
19511951table, from the text property syntax-table or from the syntax
1952- flag (20)."
1952+ flag (20). The flag must be ignored once inside a symbol, this
1953+ is done by passing CHECK-PREFIX-FLAG as nil."
19531954 (setq p (or p (point)))
19541955 (let ((parse-sexp-lookup-properties t))
19551956 (when-let ((syntax (syntax-after p)))
19561957 (or (= (syntax-class syntax) 6)
1957- (/= 0 (logand (lsh 1 20) (car syntax)))))))
1958+ (and check-prefix-flag
1959+ (/= 0 (logand (lsh 1 20) (car syntax))))))))
19581960
1959- (defun sp-syntax-before-is-prefix (&optional p)
1961+ (defun sp-syntax-before-is-prefix (check-prefix-flag &optional p)
19601962 "Check that the character before P has prefix syntax.
19611963
19621964Prefix syntax can either come from the global major-mode syntax
19631965table, from the text property syntax-table or from the syntax
1964- flag (20)."
1966+ flag (20). The flag must be ignored once inside a symbol, this
1967+ is done by passing CHECK-PREFIX-FLAG as nil."
19651968 (setq p (or p (point)))
19661969 (let ((parse-sexp-lookup-properties t))
19671970 (when-let ((syntax (syntax-after (1- p))))
19681971 (or (= (syntax-class syntax) 6)
1969- (/= 0 (logand (lsh 1 20) (car syntax)))))))
1972+ (and check-prefix-flag
1973+ (/= 0 (logand (lsh 1 20) (car syntax))))))))
19701974
19711975(defun sp-syntax-after-is-word-or-symbol (&optional p)
19721976 "Check that the character after P has word or symbol syntax.
@@ -1977,9 +1981,9 @@ regularly the character would be (for example according to the
19771981syntax table)."
19781982 (setq p (or p (point)))
19791983 (and (memq (sp-syntax-after p) '(?w ?_))
1980- (not (sp-syntax-after-is-prefix p))))
1984+ (not (sp-syntax-after-is-prefix (not (sp-syntax-before-is-word-or-symbol t)) p))))
19811985
1982- (defun sp-syntax-before-is-word-or-symbol (&optional p)
1986+ (defun sp-syntax-before-is-word-or-symbol (check-prefix-flag &optional p)
19831987 "Check that the character before P has word or symbol syntax.
19841988
19851989In case the character has a special syntax flag 'p', meaning a
@@ -1988,7 +1992,7 @@ regularly the character would be (for example according to the
19881992syntax table)."
19891993 (setq p (or p (point)))
19901994 (and (memq (sp-syntax-before p) '(?w ?_))
1991- (not (sp-syntax-before-is-prefix p))))
1995+ (not (sp-syntax-before-is-prefix check-prefix-flag p))))
19921996
19931997(defun sp-point-in-string (&optional p)
19941998 "Return non-nil if point is inside string or documentation string.
@@ -7812,8 +7816,10 @@ Examples:
78127816 ,(if forward '(sp-syntax-after) '(sp-syntax-before))
78137817 '(?< ?> ?! ?| ?\ ?\\ ?\" ?' ?.))
78147818 ,(if forward
7815- '(sp-syntax-after-is-prefix (point))
7816- '(sp-syntax-before-is-prefix (point)))
7819+ ;; ignore prefix syntax not in a prefix position
7820+ '(and (not (sp-syntax-before-is-word-or-symbol t))
7821+ (sp-syntax-after-is-prefix t))
7822+ '(sp-syntax-before-is-prefix t))
78177823 (unless in-comment (sp-point-in-comment))
78187824 ;; This is the case where we are starting at
78197825 ;; pair (looking at it) and there is some
@@ -7985,7 +7991,7 @@ Examples:
79857991 (while (> n 0)
79867992 (while (cond
79877993 ((bobp) nil)
7988- ((not (sp-syntax-before-is-word-or-symbol))
7994+ ((not (sp-syntax-before-is-word-or-symbol t ))
79897995 (backward-char)
79907996 t)
79917997 ((sp--valid-initial-delimiter-p (sp--looking-back open))
@@ -7995,7 +8001,7 @@ Examples:
79958001 (while (and (not (bobp))
79968002 (not (or (sp--valid-initial-delimiter-p (sp--looking-back open))
79978003 (sp--valid-initial-delimiter-p (sp--looking-back close))))
7998- (or (sp-syntax-before-is-word-or-symbol)
8004+ (or (sp-syntax-before-is-word-or-symbol nil) ;; now inside symbol so ignore prefix flag
79998005 ;; Specifically for lisp, we consider
80008006 ;; sequences of ?\<ANYTHING> a symbol
80018007 ;; sequence
0 commit comments