From b4943f9c5420fe510cef87cbfa6708fb698a01e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Denuzi=C3=A8re?= Date: Sat, 28 Oct 2017 09:29:03 +0200 Subject: [PATCH 1/2] Add access control keywords to declaration regexes --- fsharp-mode-font.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fsharp-mode-font.el b/fsharp-mode-font.el index 7d23892..4d11b8f 100644 --- a/fsharp-mode-font.el +++ b/fsharp-mode-font.el @@ -93,6 +93,7 @@ with initial value INITVALUE and optional DOCSTRING." (def-fsharp-compiled-var fsharp-function-def-regexp (concat "\\<\\(?:let\\|and\\|with\\)\\s-+" fsharp-inline-rec-regexp-noncapturing "?" + fsharp-access-control-regexp-noncapturing "*" (format "\\(%s\\)" fsharp-valid-identifier-regexp) "\\(?:\\s-+[A-Za-z_]\\|\\s-*(\\)" ;; matches function arguments or open-paren; unclear why 0-9 not in class )) @@ -100,6 +101,7 @@ with initial value INITVALUE and optional DOCSTRING." (def-fsharp-compiled-var fsharp-pattern-function-regexp (concat "\\<\\(?:let\\|and\\)\\s-+" fsharp-inline-rec-regexp-noncapturing "?" + fsharp-access-control-regexp-noncapturing "*" (format "\\(%s\\)" fsharp-valid-identifier-regexp) "\\s-*=\\s-*function") "Matches an implicit matcher, eg let foo m = function | \"cat\" -> etc.") @@ -107,7 +109,10 @@ with initial value INITVALUE and optional DOCSTRING." ;; Note that this regexp is used for iMenu. To font-lock active patterns, we ;; need to use an anchored match in fsharp-font-lock-keywords. (def-fsharp-compiled-var fsharp-active-pattern-regexp - "\\<\\(?:let\\|and\\)\\s-+\\(?:\\(?:inline\\|rec\\)\\s-+\\)?(\\(|[A-Za-z0-9_'|]+|\\))\\(?:\\s-+[A-Za-z_]\\|\\s-*(\\)") + (concat "\\<\\(?:let\\|and\\)\\s-+" + fsharp-inline-rec-regexp-noncapturing "?" + fsharp-access-control-regexp-noncapturing "*" + "(\\(|[A-Za-z0-9_'|]+|\\))\\(?:\\s-+[A-Za-z_]\\|\\s-*(\\)")) (def-fsharp-compiled-var fsharp-member-access-regexp "\\<\\(?:override\\|member\\|abstract\\)\\s-+" @@ -115,20 +120,23 @@ with initial value INITVALUE and optional DOCSTRING." (def-fsharp-compiled-var fsharp-member-function-regexp (concat fsharp-member-access-regexp - "\\(?:\\(?:inline\\|rec\\)\\s-+\\)?\\(?:" - fsharp-valid-identifier-regexp - "\\.\\)?\\(" - fsharp-valid-identifier-regexp - "\\)") + fsharp-inline-rec-regexp-noncapturing "?" + fsharp-access-control-regexp-noncapturing "*" + "\\(?:" fsharp-valid-identifier-regexp "\\.\\)?" + "\\(" fsharp-valid-identifier-regexp "\\)") "Captures the final identifier in a member function declaration.") (def-fsharp-compiled-var fsharp-overload-operator-regexp (concat fsharp-member-access-regexp - "\\(?:\\(?:inline\\|rec\\)\\s-+\\)?\\(([!%&*+-./<=>?@^|~]+)\\)") + fsharp-inline-rec-regexp-noncapturing "?" + fsharp-access-control-regexp-noncapturing "*" + "\\(([!%&*+-./<=>?@^|~]+)\\)") "Match operators when overloaded by a type/class.") (def-fsharp-compiled-var fsharp-constructor-regexp - "^\\s-*\\<\\(new\\) *(.*)[^=]*=" + (concat "^\\s-*" + fsharp-access-control-regexp-noncapturing "*" + "\\<\\(new\\) *(.*)[^=]*=") "Matches the `new' keyword in a constructor") (def-fsharp-compiled-var fsharp-type-def-regexp From aa07d27250443d86328c62a038d0c204b0475305 Mon Sep 17 00:00:00 2001 From: Loic Denuziere Date: Sat, 28 Oct 2017 09:46:00 +0200 Subject: [PATCH 2/2] Fix font test for let private func --- test/apps/FSharp.Compatibility/Format.fs.faceup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/apps/FSharp.Compatibility/Format.fs.faceup b/test/apps/FSharp.Compatibility/Format.fs.faceup index 1812576..5eac3cc 100644 --- a/test/apps/FSharp.Compatibility/Format.fs.faceup +++ b/test/apps/FSharp.Compatibility/Format.fs.faceup @@ -849,7 +849,7 @@ «m:/// »«x:Re-implementation of OCaml's Pervasives.output, since the one in the »«m:/// »«x:F# compatibility library doesn't have the right type signature. -»«k:let» «k:private» «v:output» «v:oc» («v:buf» : «t:string») («v:pos» : «t:int») («v:len» : «t:int») = +»«k:let» «k:private» «f:output» «v:oc» («v:buf» : «t:string») («v:pos» : «t:int») («v:len» : «t:int») = output_string oc (buf.Substring (pos, len)) «k:let» «f:pp_set_formatter_out_channel» «v:state» «v:os» =