Skip to content

Conversation

@tmcgilchrist
Copy link
Contributor

Fix for #4222 the regex is not correct.

;; Original regex
;; NOTE 0 is true and nil is false (roughtly speaking)
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\|-project\\)?\\'" "dune")
0
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\|-project\\)?\\'" "dune.inc")
nil
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\|-project\\)?\\'" "dune-project")
nil

;; New regex
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\\|\\-project\\)?\\'" "dune")
0
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\\|\\-project\\)?\\'" "dune.inc")
0
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\\|\\-project\\)?\\'" "dune-project")
0
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\\|\\-project\\)?\\'" "dune-project.inc")
nil
(string-match "\\(?:\\`\\|/\\)dune\\(?:\\.inc\\|\\-project\\)?\\'" "dune-projects")
nil

;; Potentially simplier regex from regexp-opt though I'm not sure if this covers 
;; all possible cases. I have only tested on OSX and Linux.
(regexp-opt '("dune" "dune-project" "dune.inc"))
"\\(?:dune\\(?:-project\\|\\.inc\\)?\\)"

Signed-off-by: Tim McGilchrist <[email protected]>
@rgrinberg rgrinberg merged commit 16cb826 into ocaml:main Jul 15, 2021
@rgrinberg
Copy link
Member

Thanks

@tmcgilchrist tmcgilchrist deleted the emacs-regex-dune branch July 15, 2021 06:22
@tmcgilchrist
Copy link
Contributor Author

Cheers @rgrinberg the new version is up on MELPA.

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