Skip to content

Conversation

@gengar
Copy link

@gengar gengar commented Mar 20, 2024

The "-" case always matches on "[^0-9>]" and never on latter.

The "-" case always matches on "[^0-9>]" and never on latter.
@monnier
Copy link
Contributor

monnier commented Mar 20, 2024 via email

@gengar
Copy link
Author

gengar commented Mar 20, 2024

OK, here is a example:

(let ((operator-char     "[-!$%&*+./:<=>?@^|~]")
      (operator-char-no> "[-!$%&*+./:<=?@^|~]"))
  (let ((reg1 (concat "\\(-\\)\\(?:[^0-9>]\\|\\("
                      operator-char-no> operator-char "*\\)\\)"))
        (reg2 (concat "\\(-\\)\\("
                      operator-char-no>
                      operator-char "*\\|\\(?:[^0-9>]\\)\\)"))
        (str "-$$$"))
    (string-match reg1 str)
    (print (match-string 0 str)) ; => "-$"
    (print (match-string 2 str)) ; => nil

    (string-match reg2 str)
    (print (match-string 0 str)) ; => "-$$$"
    (print (match-string 2 str)) ; => "$$$"
    nil))

I would expect to tuareg-mode highlights the whole symbol like -$$$.

@monnier
Copy link
Contributor

monnier commented Feb 27, 2025

Oh, I see what you mean now. But the patch is still incorrect because when the operator-char-no> operator-char * part does not match, we end up highlighting not just the - but also the subsequent char matched by [^0-9>].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants