From unknown Tue Jun 24 15:44:07 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#59490 <59490@debbugs.gnu.org> To: bug#59490 <59490@debbugs.gnu.org> Subject: Status: 29.0.50; Add C# support Reply-To: bug#59490 <59490@debbugs.gnu.org> Date: Tue, 24 Jun 2025 22:44:07 +0000 retitle 59490 29.0.50; Add C# support reassign 59490 emacs submitter 59490 Theodor Thornhill severity 59490 normal tag 59490 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 22 15:52:42 2022 Received: (at submit) by debbugs.gnu.org; 22 Nov 2022 20:52:42 +0000 Received: from localhost ([127.0.0.1]:52666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxaG0-0004PX-SL for submit@debbugs.gnu.org; Tue, 22 Nov 2022 15:52:42 -0500 Received: from lists.gnu.org ([209.51.188.17]:48862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxaFx-0004PO-8j for submit@debbugs.gnu.org; Tue, 22 Nov 2022 15:52:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxaFi-0002j7-GX for bug-gnu-emacs@gnu.org; Tue, 22 Nov 2022 15:52:35 -0500 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxaFc-0000hY-0X for bug-gnu-emacs@gnu.org; Tue, 22 Nov 2022 15:52:21 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669150332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=Y4uif3VytpA3/SkUG4bqGvG/iM+IrFo5yfFZokRkLeM=; b=Ums+IqjD+IrusgB4F5Kjr1h3Ka+R+lwcjD2SaxGIoCzEfKkUZUJW5AWWPb+t+qklnEAibH OwgN31ShFpSzTu35BsH8CE2YYLVzxWi8eCbEcsrtXA7OidFAcDqYbJoYrnnc+DDN1f0Fbt jwmDkKk9RYz1EkCYkY8dFpO8bNrdTHf0W3RFozh4rI53by4MJVOozAjPHTb7PFbEiaQlqd FhG4h+9yHndyGpulq94P+jE/Ur91Q5VbBigDsWw3Oqfdt6tGtUpRUC8i/+Ik4Hwlm4pKHn DmCHSfHK4Oqqsl+wTxT8I9zzgYqVVVEtx6sUlPWM0my7xRy2uN7a2y+dW1Dbbw== From: Theodor Thornhill To: bug-gnu-emacs@gnu.org Subject: 29.0.50; Add C# support X-Debbugs-CC: casouri@gmail.com, josteink@gmail.com Date: Tue, 22 Nov 2022 21:52:05 +0100 Message-ID: <87edtuogp6.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Hi Yuan, Jostein and others. Added is support for C# in Emacs. This is the original C# mode as found on ELPA [0], as well as support for the new tree sitter mechanisms. I made two new modes, 'csharp-cc-mode' and 'csharp-ts-mode'. The cc-mode variant has that name as to not conflict with the ELPA package. Please shoot comments at me, and I'll fix them. Hope you like it, Theodor [0]: https://github.com/emacs-csharp/csharp-mode --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-csharp-cc-ts-mode.patch Content-Transfer-Encoding: quoted-printable >From 3e8f7a649c70e4222eb1123008623707afdd66b6 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Tue, 22 Nov 2022 21:22:31 +0100 Subject: [PATCH] Add csharp-{cc|ts}-mode * etc/NEWS: Mention new modes. * lisp/progmodes/csharp-mode.el (csharp-cc-mode, csharp-ts-mode): New major modes. --- etc/NEWS | 8 + lisp/progmodes/csharp-mode.el | 898 ++++++++++++++++++++++++++++++++++ 2 files changed, 906 insertions(+) create mode 100644 lisp/progmodes/csharp-mode.el diff --git a/etc/NEWS b/etc/NEWS index 5a65896d69..30e2b3780c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2990,6 +2990,14 @@ A major mode based on the tree-sitter library for ed= iting programs in the JSON language. It includes support for font-locking, indentation, Imenu, which-func, and navigation. =20 +** New mode 'csharp-ts-mode'. +A major mode based on the tree-sitter library for editing programs +in the C# language. It includes support for font-locking, +indentation, Imenu, which-func, and navigation. + +** New mode 'csharp-cc-mode'. +A major mode based on CC Mode for editing programs in the C# language. + * Incompatible Lisp Changes in Emacs 29.1 =20 diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el new file mode 100644 index 0000000000..0dcd69f8dd --- /dev/null +++ b/lisp/progmodes/csharp-mode.el @@ -0,0 +1,898 @@ +;;; csharp-mode.el --- Support for editing C# -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. + +;; Author : Theodor Thornhill +;; Maintainer : Theodor Thornhill +;; Created : September 2022 +;; Keywords : c# languages oop + +;; This file is part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Code: + + +(require 'cc-mode) +(require 'cc-langs) +(eval-when-compile + (require 'cc-fonts)) + +(require 'compile) + +(defgroup csharp nil + "Major mode for editing C# code." + :group 'prog-mode) + +(eval-and-compile + (defconst csharp-cc-mode--regex-identifier + "[A-Za-z][A-Za-z0-9_]*" + "Regex describing an dentifier in C#.") + + (defconst csharp-cc-mode--regex-identifier-matcher + (concat "\\(" csharp-cc-mode--regex-identifier "\\)") + "Regex matching an identifier in C#.") + + (defconst csharp-cc-mode--regex-type-name + "[A-Z][A-Za-z0-9_]*" + "Regex describing a type identifier in C#.") + + (defconst csharp-cc-mode--regex-type-name-matcher + (concat "\\(" csharp-cc-mode--regex-type-name "\\)") + "Regex matching a type identifier in C#.") + + (defconst csharp-cc-mode--regex-using-or-namespace + (concat "^using" "\\|" "namespace" + "\\s *" + csharp-cc-mode--regex-type-name-matcher) + "Regex matching identifiers after a using or namespace + declaration.")) + +(eval-and-compile + (c-add-language 'csharp-cc-mode 'java-mode) + + (defun csharp-cc-mode--make-mode-syntax-table () + (let ((table (make-syntax-table))) + (c-populate-syntax-table table) + (modify-syntax-entry ?@ "_" table) + table)) + + (defvar csharp-cc-mode--make-mode-syntax-table #'csharp-cc-mode--make-mo= de-syntax-table + "Workaround for Emacs bug#57065.")) + +(c-lang-defconst c-make-mode-syntax-table + csharp #'csharp-cc-mode--make-mode-syntax-table) + +(c-lang-defconst c-identifier-syntax-modifications + csharp (append '((?@ . "w")) + (c-lang-const c-identifier-syntax-modifications))) + +(c-lang-defconst c-symbol-start + csharp (concat "[" c-alpha "_@]")) + +(c-lang-defconst c-opt-type-suffix-key + csharp (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\?\\)")) + +(c-lang-defconst c-identifier-ops + csharp '((left-assoc "."))) + +(c-lang-defconst c-overloadable-operators + csharp '("+" "-" "*" "/" "%" "&" "|" "^" "<<" ">>" "=3D=3D" + "!=3D" ">" "<" ">=3D" "<=3D")) + +(c-lang-defconst c-multiline-string-start-char + csharp ?@) + +(c-lang-defconst c-ml-string-opener-re + ;; "\\(\\(?:@\\$?\\)\\(\"\\)\\)" + csharp + (rx + (group + (or "@" "@$") + (group "\"")))) + +(c-lang-defconst c-ml-string-max-opener-len + csharp 3) + +(c-lang-defconst c-ml-string-max-closer-len + csharp 2) + +(c-lang-defconst c-ml-string-any-closer-re + ;; "\\(?:\"\"\\)*\\(\\(\"\\)\\)\\(?:[^\"]\\|\\'\\)" + csharp + (rx + (seq + (zero-or-more "\"\"") + (group + (group "\"")) + (or (not (any "\"")) eos)))) + +(c-lang-defconst c-ml-string-back-closer-re + ;; "\\(?:\\`\\|[^\"]\\)\"*" + csharp + (rx + (seq + (or bos + (not (any "\""))) + (zero-or-more "\"")))) + +(c-lang-defconst c-type-prefix-kwds + csharp '("class" "interface" "struct")) + +(c-lang-defconst c-class-decl-kwds + csharp '("class" "interface" "struct")) + +;;; Keyword lists + +(c-lang-defconst c-primitive-type-kwds + csharp '("bool" "byte" "sbyte" "char" "decimal" "double" "float" "int" "= uint" + "long" "ulong" "short" "ushort" "void" "object" "string" "var")) + +(c-lang-defconst c-other-decl-kwds + csharp nil) + +(c-lang-defconst c-type-list-kwds + csharp nil) + +(c-lang-defconst c-other-block-decl-kwds + csharp nil) + +(c-lang-defconst c-return-kwds + csharp '("return")) + +(c-lang-defconst c-typedef-kwds + csharp nil) + +(c-lang-defconst c-typeof-kwds + csharp '("typeof" "is" "as")) + +(c-lang-defconst c-type-modifier-prefix-kwds + csharp '("volatile")) + +(c-lang-defconst c-type-modifier-kwds + csharp '("readonly" "new")) + +(c-lang-defconst c-brace-list-decl-kwds + csharp '("enum" "new")) + +(c-lang-defconst c-recognize-post-brace-list-type-p + csharp t) + +(c-lang-defconst c-ref-list-kwds + csharp nil) + +(c-lang-defconst c-using-kwds + csharp '("using")) + +(c-lang-defconst c-equals-type-clause-kwds + csharp '("using")) + +(defun csharp-cc-mode-at-vsemi-p (&optional pos) + (if pos (goto-char pos)) + (save-excursion + (beginning-of-line) + (c-forward-syntactic-ws) + (looking-at "using\\s *("))) + +(c-lang-defconst c-at-vsemi-p-fn + csharp 'csharp-cc-mode-at-vsemi-p) + +(defun csharp-cc-mode-vsemi-status-unknown () t) + +(c-lang-defconst c-vsemi-status-unknown-p-fn + csharp 'csharp-cc-mode-vsemi-status-unknown-p) + + +(c-lang-defconst c-modifier-kwds + csharp '("abstract" "default" "final" "native" "private" "protected" + "public" "partial" "internal" "readonly" "static" "event" "tran= sient" + "volatile" "sealed" "ref" "out" "virtual" "implicit" "explicit" + "fixed" "override" "params" "async" "await" "extern" "unsafe" + "get" "set" "this" "const" "delegate")) + +(c-lang-defconst c-other-kwds + csharp '("select" "from" "where" "join" "in" "on" "equals" "into" + "orderby" "ascending" "descending" "group" "when" + "let" "by" "namespace")) + +(c-lang-defconst c-colon-type-list-kwds + csharp '("class" "struct" "interface")) + +(c-lang-defconst c-block-stmt-1-kwds + csharp '("do" "else" "finally" "try")) + +(c-lang-defconst c-block-stmt-1-2-kwds + csharp '("try")) + +(c-lang-defconst c-block-stmt-2-kwds + csharp '("for" "if" "switch" "while" "catch" "foreach" "fixed" "checked" + "unchecked" "using" "lock")) + +(c-lang-defconst c-simple-stmt-kwds + csharp '("break" "continue" "goto" "throw" "return" "yield")) + +(c-lang-defconst c-constant-kwds + csharp '("true" "false" "null" "value")) + +(c-lang-defconst c-primary-expr-kwds + csharp '("this" "base" "operator")) + +(c-lang-defconst c-inexpr-class-kwds + csharp nil) + +(c-lang-defconst c-class-decl-kwds + csharp '("class" "struct" "interface")) + +(c-lang-defconst c-std-abbrev-keywords + csharp (append (c-lang-const c-std-abbrev-keywords) '("catch" "finally")= )) + +(c-lang-defconst c-decl-prefix-re + csharp "\\([{}(;,<]+\\)") + +(c-lang-defconst c-recognize-typeless-decls + csharp t) + +(c-lang-defconst c-recognize-<>-arglists + csharp t) + +(c-lang-defconst c-opt-cpp-prefix + csharp "\\s *#\\s *") + +(c-lang-defconst c-opt-cpp-macro-define + csharp (if (c-lang-const c-opt-cpp-prefix) + "define")) + +(c-lang-defconst c-cpp-message-directives + csharp '("error" "warning" "region")) + +(c-lang-defconst c-cpp-expr-directives + csharp '("if" "elif")) + +(c-lang-defconst c-other-op-syntax-tokens + csharp (append '("#") + (c-lang-const c-other-op-syntax-tokens))) + +(c-lang-defconst c-line-comment-starter + csharp "//") + +(c-lang-defconst c-doc-comment-start-regexp + csharp "///") + +(c-add-style "csharp" + '("java" + (c-basic-offset . 4) + (c-comment-only-line-offset . (0 . 0)) + (c-offsets-alist . ((inline-open . 0) + (arglist-intro . +) + (arglist-close . 0) + (inexpr-class . 0) + (case-label . +) + (cpp-macro . c-lineup-dont-= change) + (substatement-open . 0))))) + +(eval-and-compile + (unless (or (stringp c-default-style) + (assoc 'csharp-cc-mode-mode c-default-style)) + (setq c-default-style + (cons '(csharp-cc-mode . "csharp") + c-default-style)))) + +(defun csharp-cc-mode--color-forwards (font-lock-face) + (let (id-beginning) + (goto-char (match-beginning 0)) + (forward-word) + (while (and (not (or (eq (char-after) ?\;) + (eq (char-after) ?\{))) + (progn + (forward-char) + (c-forward-syntactic-ws) + (setq id-beginning (point)) + (> (skip-chars-forward + (c-lang-const c-symbol-chars)) + 0)) + (not (get-text-property (point) 'face))) + (c-put-font-lock-face id-beginning (point) font-lock-face) + (c-forward-syntactic-ws)))) + +(c-lang-defconst c-basic-matchers-before + csharp `( + ;; Warning face on unclosed strings + ,@(if (version< emacs-version "27.0") + ;; Taken from 26.1 branch + `(,(c-make-font-lock-search-function + (concat ".\\(" c-string-limit-regexp "\\)") + '((c-font-lock-invalid-string)))) + `(("\\s|" 0 font-lock-warning-face t nil))) + + ;; Invalid single quotes + c-font-lock-invalid-single-quotes + + ;; Keyword constants + ,@(when (c-lang-const c-constant-kwds) + (let ((re (c-make-keywords-re nil (c-lang-const c-constant-= kwds)))) + `((eval . (list ,(concat "\\<\\(" re "\\)\\>") + 1 c-constant-face-name))))) + + ;; Keywords except the primitive types. + ,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp)) + 1 font-lock-keyword-face) + + ;; Chained identifiers in using/namespace statements + ,`(,(c-make-font-lock-search-function + csharp-cc-mode--regex-using-or-namespace + `((csharp-cc-mode--color-forwards font-lock-variable-name-= face) + nil + (goto-char (match-end 0))))) + + + ;; Negation character + (eval . (list "\\(!\\)[^=3D]" 1 c-negation-char-face-name)) + + ;; Types after 'new' + (eval . (list (concat "\\ *" csharp-cc-mode--regex-type-= name-matcher) + 1 font-lock-type-face)) + + ;; Single identifier in attribute + (eval . (list (concat "\\[" csharp-cc-mode--regex-type-name-mat= cher "\\][^;]") + 1 font-lock-variable-name-face t)) + + ;; Function names + (eval . (list "\\([A-Za-z0-9_]+\\)\\(<[a-zA-Z0-9, ]+>\\)?(" + 1 font-lock-function-name-face)) + + ;; Nameof + (eval . (list (concat "\\(\\\\) *(") + 1 font-lock-function-name-face)) + + (eval . (list (concat "\\ *( *" + csharp-cc-mode--regex-identifier-matcher + " *) *") + 1 font-lock-variable-name-face)) + + ;; Catch statements with type only + (eval . (list (concat "\\ *( *" + csharp-cc-mode--regex-type-name-matcher + " *) *") + 1 font-lock-type-face)) + )) + +(c-lang-defconst c-basic-matchers-after + csharp (append + ;; Merge with cc-mode defaults - enables us to add more later + (c-lang-const c-basic-matchers-after))) + +(defcustom csharp-cc-mode-codedoc-tag-face 'c-doc-markup-face-name + "Face to be used on the codedoc docstring tags. + +Should be one of the font lock faces, such as +`font-lock-variable-name-face' and friends. + +Needs to be set before `csharp-cc-mode' is loaded, because of +compilation and evaluation time conflicts." + :type 'symbol) + +(defcustom csharp-cc-mode-font-lock-extra-types + (list csharp-cc-mode--regex-type-name) + (c-make-font-lock-extra-types-blurb "C#" "csharp-cc-mode" (concat)) + :type 'c-extra-types-widget + :group 'c) + +(defconst csharp-cc-mode-font-lock-keywords-1 (c-lang-const c-matchers-1 c= sharp) + "Minimal font locking for C# mode.") + +(defconst csharp-cc-mode-font-lock-keywords-2 (c-lang-const c-matchers-2 c= sharp) + "Fast normal font locking for C# mode.") + +(defconst csharp-cc-mode-font-lock-keywords-3 (c-lang-const c-matchers-3 c= sharp) + "Accurate normal font locking for C# mode.") + +(defvar csharp-cc-mode-font-lock-keywords csharp-cc-mode-font-lock-keyword= s-3 + "Default expressions to highlight in C# mode.") + +(defun csharp-cc-mode-font-lock-keywords-2 () + (c-compose-keywords-list csharp-cc-mode-font-lock-keywords-2)) +(defun csharp-cc-mode-font-lock-keywords-3 () + (c-compose-keywords-list csharp-cc-mode-font-lock-keywords-3)) +(defun csharp-cc-mode-font-lock-keywords () + (c-compose-keywords-list csharp-cc-mode-font-lock-keywords)) + +;;; Doc comments + +(defconst codedoc-font-lock-doc-comments + ;; Most of this is taken from the javadoc example, however, we don't use= the + ;; '@foo' syntax, so I removed that. Supports the XML tags only + `((,(concat "") + 0 ,csharp-cc-mode-codedoc-tag-face prepend nil) + ("&\\(\\sw\\|[.:]\\)+;" ; XML entities. + 0 ,csharp-cc-mode-codedoc-tag-face prepend nil))) + +(defconst codedoc-font-lock-keywords + `((,(lambda (limit) + (c-font-lock-doc-comments "///" limit + codedoc-font-lock-doc-comments))))) + +;;; End of doc comments + +;;; Adding syntax constructs + +(advice-add 'c-looking-at-inexpr-block + :around #'csharp-cc-mode-looking-at-inexpr-block) + +(defun csharp-cc-mode-looking-at-inexpr-block (orig-fun &rest args) + (let ((res (csharp-cc-mode-at-lambda-header))) + (if res + res + (apply orig-fun args)))) + +(defun csharp-cc-mode-at-lambda-header () + (save-excursion + (c-backward-syntactic-ws) + (unless (bobp) + (backward-char) + (c-safe (goto-char (scan-sexps (point) -1))) + (when (or (looking-at "([[:alnum:][:space:]_,]*)[ \t\n]*=3D>[ \t\n]*= {") + (looking-at "[[:alnum:]_]+[ \t\n]*=3D>[ \t\n]*{")) + ;; If we are at a C# lambda header + (cons 'inexpr (point)))))) + +(advice-add 'c-guess-basic-syntax + :around #'csharp-cc-mode-guess-basic-syntax) + +(defun csharp-cc-mode-guess-basic-syntax (orig-fun &rest args) + (cond + (;; Attributes + (save-excursion + (goto-char (c-point 'iopl)) + (and + (eq (char-after) ?\[) + (save-excursion + (c-go-list-forward) + (and (eq (char-before) ?\]) + (not (eq (char-after) ?\;)))))) + `((annotation-top-cont ,(c-point 'iopl)))) + + ((and + ;; Heuristics to find object initializers + (save-excursion + ;; Next non-whitespace character should be '{' + (goto-char (c-point 'boi)) + (eq (char-after) ?{)) + (save-excursion + ;; 'new' should be part of the line + (goto-char (c-point 'iopl)) + (looking-at ".*\\s *new\\s *.*")) + ;; Line should not already be terminated + (save-excursion + (goto-char (c-point 'eopl)) + (or (not (eq (char-before) ?\;)) + (not (eq (char-before) ?\{))))) + (if (save-excursion + ;; if we have a hanging brace on line before + (goto-char (c-point 'eopl)) + (eq (char-before) ?\{)) + `((brace-list-intro ,(c-point 'iopl))) + `((block-open) (statement ,(c-point 'iopl))))) + (t + (apply orig-fun args)))) + +;;; End of new syntax constructs + +;;; Compilation support + +;; When invoked by MSBuild, csc=E2=80=99s errors look like this: +;; subfolder\file.cs(6,18): error CS1006: Name of constructor must +;; match name of class [c:\Users\user\project.csproj] + +(defun csharp-cc-mode--compilation-error-file-resolve () + "Resolve an msbuild error to a (filename . dirname) cons cell." + ;; http://stackoverflow.com/a/18049590/429091 + (cons (match-string 1) (file-name-directory (match-string 4)))) + +(defconst csharp-cc-mode-compilation-re-msbuild-error + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): " + "error [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$") + "Regexp to match compilation error from msbuild.") + +(defconst csharp-cc-mode-compilation-re-msbuild-warning + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): " + "warning [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$") + "Regexp to match compilation warning from msbuild.") + +;; Notes on xbuild and devenv commonalities +;; +;; These regexes were tailored for xbuild, but apart from the concurrent +;; build-marker ("1>") they share exactly the same match-markers. +;; +;; If we don't exclude the match-markers explicitly, these regexes +;; will also be used to match for devenv as well, including the build-mark= er +;; in the file-name, causing the lookup to fail. +;; +;; So if we don't want devenv to fail, we actually need to handle it in our +;; xbuild-regexes, but then we automatically get devenv-support for free. + +(defconst csharp-cc-mode-compilation-re-xbuild-error + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?" + ;; handle weird devenv output format with 4 numbers, not 2 by having op= tional + ;; extra capture-groups. + "\\(?:,\\([0-9]+\\)\\)*): " + "error [[:alnum:]]+: .+$") + "Regexp to match compilation error from xbuild.") + +(defconst csharp-cc-mode-compilation-re-xbuild-warning + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?" + ;; handle weird devenv output format with 4 numbers, not 2 by having op= tional + ;; extra capture-groups. + "\\(?:,\\([0-9]+\\)\\)?*): " + "warning [[:alnum:]]+: .+$") + "Regexp to match compilation warning from xbuild.") + +(defconst csharp-cc-mode-compilation-re-dotnet-error + "\\([^\r\n]+\\) : error [A-Z]+[0-9]+:") + +(defconst csharp-cc-mode-compilation-re-dotnet-warning + "\\([^\r\n]+\\) : warning [A-Z]+[0-9]+:") + +(defconst csharp-cc-mode-compilation-re-dotnet-testfail + (concat + "[[:blank:]]+Stack Trace:\n" + "[[:blank:]]+at [^\n]+ in \\([^\n]+\\):line \\([0-9]+\\)")) + +(eval-after-load 'compile + (lambda () + (dolist + (regexp + `((dotnet-testfail + ,csharp-cc-mode-compilation-re-dotnet-testfail + 1 2) + (xbuild-error + ,csharp-cc-mode-compilation-re-xbuild-error + 1 2 3 2) + (xbuild-warning + ,csharp-cc-mode-compilation-re-xbuild-warning + 1 2 3 1) + (msbuild-error + ,csharp-cc-mode-compilation-re-msbuild-error + csharp-cc-mode--compilation-error-file-resolve + 2 + 3 + 2 + nil + (1 compilation-error-face) + (4 compilation-error-face)) + (msbuild-warning + ,csharp-cc-mode-compilation-re-msbuild-warning + csharp-cc-mode--compilation-error-file-resolve + 2 + 3 + 1 + nil + (1 compilation-warning-face) + (4 compilation-warning-face)) + (dotnet-error + ,csharp-cc-mode-compilation-re-dotnet-error + 1) + (dotnet-warning + ,csharp-cc-mode-compilation-re-dotnet-warning + 1 nil nil 1))) + (add-to-list 'compilation-error-regexp-alist-alist regexp) + (add-to-list 'compilation-error-regexp-alist (car regexp))))) + +(defvar csharp-cc-mode-mode-syntax-table + (funcall (c-lang-const c-make-mode-syntax-table csharp)) + "Syntax table used in `csharp-cc-mode' buffers.") + +(defvar csharp-cc-mode-map + (let ((map (c-make-inherited-keymap))) + map) + "Keymap used in `csharp-cc-mode' buffers.") + +(easy-menu-define csharp-cc-mode-menu csharp-cc-mode-map "C# Mode Commands= ." + (cons "C#" (c-lang-const c-mode-menu csharp))) + +;;; Tree-sitter support + +(defcustom csharp-ts-mode-indent-offset 4 + "Number of spaces for each indentation step in `csharp-ts-mode'." + :type 'integer + :safe 'integerp + :group 'csharp) + +(defvar csharp-ts-mode--indent-rules + `((c-sharp + ((parent-is "compilation_unit") parent-bol 0) + ((node-is "}") parent-bol 0) + ((node-is ")") parent-bol 0) + ((node-is "]") parent-bol 0) + ((parent-is "namespace_declaration") parent-bol 0) + ((parent-is "class_declaration") parent-bol 0) + ((parent-is "constructor_declaration") parent-bol 0) + ((parent-is "method_declaration") parent-bol 0) + ((parent-is "enum_declaration") parent-bol 0) + ((parent-is "operator_declaration") parent-bol 0) + ((parent-is "field_declaration") parent-bol 0) + ((parent-is "struct_declaration") parent-bol 0) + ((parent-is "declaration_list") parent-bol csharp-ts-mode-indent-offs= et) + ((parent-is "argument_list") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "interpolation") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "binary_expression") parent 0) + ((parent-is "block") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "local_function_statement") parent-bol 0) + ((parent-is "if_statement") parent-bol 0) + ((parent-is "for_statement") parent-bol 0) + ((parent-is "for_each_statement") parent-bol 0) + ((parent-is "while_statement") parent-bol 0) + ((match "{" "switch_expression") parent-bol 0) + ((parent-is "switch_statement") parent-bol 0) + ((parent-is "switch_body") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "switch_section") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "switch_expression") parent-bol csharp-ts-mode-indent-off= set) + ((parent-is "case_statement") parent-bol 0) + ((parent-is "do_statement") parent-bol 0) + ((parent-is "equals_value_clause") parent-bol csharp-ts-mode-indent-o= ffset) + ((parent-is "ternary_expression") parent-bol csharp-ts-mode-indent-of= fset) + ((parent-is "conditional_expression") parent-bol csharp-ts-mode-inden= t-offset) + ((parent-is "statement_block") parent-bol csharp-ts-mode-indent-offse= t) + ((parent-is "type_arguments") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "variable_declarator") parent-bol csharp-ts-mode-indent-o= ffset) + ((parent-is "arguments") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "array") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "formal_parameters") parent-bol csharp-ts-mode-indent-off= set) + ((parent-is "template_substitution") parent-bol csharp-ts-mode-indent= -offset) + ((parent-is "object_pattern") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "object") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "object_type") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "enum_body") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "arrow_function") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "parenthesized_expression") parent-bol csharp-ts-mode-ind= ent-offset)))) + +(defvar csharp-ts-mode--keywords + '("using" "namespace" "class" "if" "else" "throw" "new" "for" + "return" "await" "struct" "enum" "switch" "case" + "default" "typeof" "try" "catch" "finally" "break" + "foreach" "in" "yield" "get" "set" "when" "as" "out" + "is" "while" "continue" "this" "ref" "goto" "interface" + "from" "where" "select" "lock" "base" "record" "init" + "with" "let" "static" "var" "do" "public" "private" + "readonly" "unmanaged") + "C# keywords for tree-sitter font-locking.") + +(defvar csharp-ts-mode--font-lock-settings + (treesit-font-lock-rules + :language 'c-sharp + :override t + :feature 'comment + '((comment) @font-lock-comment-face) + :language 'c-sharp + :override t + :feature 'keyword + `([,@csharp-ts-mode--keywords] @font-lock-keyword-face + (modifier) @font-lock-keyword-face + (this_expression) @font-lock-keyword-face) + :language 'c-sharp + :override t + :feature 'attribute + `((attribute (identifier) @font-lock-property-face (attribute_argument_= list)) + (attribute (identifier) @font-lock-property-face)) + :language 'c-sharp + :override t + :feature 'escape-sequence + '((escape_sequence) @font-lock-escape-face) + :language 'c-sharp + :override t + :feature 'literal + `((integer_literal) @font-lock-constant-face + (real_literal) @font-lock-constant-face + (null_literal) @font-lock-constant-face + (boolean_literal) @font-lock-constant-face) + :language 'c-sharp + :override t + :feature 'string + `([(string_literal) + (verbatim_string_literal) + (interpolated_string_text) + (interpolated_verbatim_string_text) + (character_literal) + "\"" + "$\"" + "@$\"" + "$@\""] @font-lock-string-face) + :language 'c-sharp + :override t + :feature 'type + '((predefined_type) @font-lock-type-face + (implicit_type) @font-lock-type-face + (nullable_type) @font-lock-type-face + (type_parameter + (identifier) @font-lock-type-face) + (type_argument_list + (identifier) @font-lock-type-face) + (generic_name + (identifier) @font-lock-type-face) + (array_type + (identifier) @font-lock-type-face) + (cast_expression (identifier) @font-lock-type-face) + ["operator"] @font-lock-type-face + (type_parameter_constraints_clause + target: (identifier) @font-lock-type-face)) + :language 'c-sharp + :feature 'definition + :override t + '((qualified_name (identifier) @font-lock-variable-name-face) + (using_directive (identifier) @font-lock-type-face) + + (enum_declaration (identifier) @font-lock-type-face) + (enum_member_declaration (identifier) @font-lock-variable-name-face) + + (interface_declaration (identifier) @font-lock-type-face) + + (struct_declaration (identifier) @font-lock-type-face) + + (record_declaration (identifier) @font-lock-type-face) + (namespace_declaration (identifier) @font-lock-type-face) + (base_list (identifier) @font-lock-type-face) + (property_declaration (generic_name)) + (property_declaration + type: (nullable_type) @font-lock-type-face + name: (identifier) @font-lock-variable-name-face) + (property_declaration + type: (predefined_type) @font-lock-type-face + name: (identifier) @font-lock-variable-name-face) + (property_declaration + type: (identifier) @font-lock-type-face + name: (identifier) @font-lock-variable-name-face) + (class_declaration (identifier) @font-lock-type-face) + + (constructor_declaration name: (_) @font-lock-type-face) + + (method_declaration type: (_) @font-lock-type-face) + (method_declaration name: (_) @font-lock-function-name-face) + + (variable_declaration (identifier) @font-lock-type-face) + (variable_declarator (identifier) @font-lock-variable-name-face) + + (parameter type: (identifier) @font-lock-type-face) + (parameter name: (identifier) @font-lock-variable-name-face)) + :language 'c-sharp + :feature 'expression + '((conditional_expression (identifier) @font-lock-variable-name-face) + (postfix_unary_expression (identifier)* @font-lock-variable-name-face) + (assignment_expression (identifier) @font-lock-variable-name-face)) + :language 'c-sharp + :feature 'bracket + '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) + + :language 'c-sharp + :feature 'delimiter + '((["," ":" ";"]) @font-lock-delimiter-face))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-cc-mode)) + +(defun csharp-ts-mode--imenu-1 (node) + "Helper for `csharp-ts-mode--imenu'. +Find string representation for NODE and set marker, then recurse +the subtrees." + (let* ((ts-node (car node)) + (subtrees (mapcan #'csharp-ts-mode--imenu-1 (cdr node))) + (name (when ts-node + (or (treesit-node-text + (or (treesit-node-child-by-field-name + ts-node "name")) + t) + "Unnamed node"))) + (marker (when ts-node + (set-marker (make-marker) + (treesit-node-start ts-node))))) + (cond + ((null ts-node) subtrees) + (subtrees + `((,name ,(cons name marker) ,@subtrees))) + (t + `((,name . ,marker)))))) + +(defun csharp-ts-mode--imenu () + "Return Imenu alist for the current buffer." + (let* ((node (treesit-buffer-root-node)) + (class-tree (treesit-induce-sparse-tree + node "^class_declaration$" nil 1000)) + (interface-tree (treesit-induce-sparse-tree + node "^interface_declaration$" nil 1000)) + (enum-tree (treesit-induce-sparse-tree + node "^enum_declaration$" nil 1000)) + (struct-tree (treesit-induce-sparse-tree + node "^struct_declaration$" nil 1000)) + (record-tree (treesit-induce-sparse-tree + node "^record_declaration$" nil 1000)) + (method-tree (treesit-induce-sparse-tree + node "^method_declaration$" nil 1000)) + (class-index (csharp-ts-mode--imenu-1 class-tree)) + (interface-index (csharp-ts-mode--imenu-1 interface-tree)) + (enum-index (csharp-ts-mode--imenu-1 enum-tree)) + (record-index (csharp-ts-mode--imenu-1 record-tree)) + (struct-index (csharp-ts-mode--imenu-1 struct-tree)) + (method-index (csharp-ts-mode--imenu-1 method-tree))) + (append + (when class-index `(("Class" . ,class-index))) + (when interface-index `(("Interface" . ,interface-index))) + (when enum-index `(("Enum" . ,enum-index))) + (when record-index `(("Record" . ,record-index))) + (when struct-index `(("Struct" . ,struct-index))) + (when method-index `(("Method" . ,method-index)))))) + +;;;###autoload +(define-derived-mode csharp-cc-mode prog-mode "C#" + "Major mode for editing Csharp code. +Key bindings: +\\{csharp-mode-map}" + :after-hook (c-update-modeline) + (c-initialize-cc-mode t) + (c-init-language-vars csharp-mode) + (c-common-init 'csharp-mode) + (setq-local c-doc-comment-style '((csharp-mode . codedoc))) + (run-mode-hooks 'c-mode-common-hook)) + +;;;###autoload +(define-derived-mode csharp-ts-mode prog-mode "C#" + "Major mode for editing C# code." + + (unless (treesit-ready-p 'c-sharp) + (error "Tree-sitter for C# isn't available")) + + ;; Tree-sitter. + (treesit-parser-create 'c-sharp) + + ;; Comments. + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") + + ;; Indent. + (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + + ;; Navigation. + (setq-local treesit-defun-type-regexp "declaration") + + ;; Font-lock. + (setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-setting= s) + (setq-local treesit-font-lock-feature-list + '((comment keyword constant string) + (type definition expression literal attribute) + (bracket delimiter))) + + ;; Imenu. + (setq-local imenu-create-index-function #'csharp-ts-mode--imenu) + (setq-local which-func-functions nil) ;; Piggyback on imenu + (treesit-major-mode-setup)) + +(provide 'csharp-mode) + +;;; csharp-mode.el ends here --=20 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 22 16:26:17 2022 Received: (at 59490) by debbugs.gnu.org; 22 Nov 2022 21:26:17 +0000 Received: from localhost ([127.0.0.1]:52718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxamX-0005Ec-2Z for submit@debbugs.gnu.org; Tue, 22 Nov 2022 16:26:17 -0500 Received: from out2.migadu.com ([188.165.223.204]:43070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxamU-0005ET-T0 for 59490@debbugs.gnu.org; Tue, 22 Nov 2022 16:26:16 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669152373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=iLCszVIZEqYBvxJg5nfJXUMBpUZ30mRsNVbmBosU18I=; b=bVQ8ZQ4lgiGjYihS0w8aLHsKiFQijLMzxdesObP+uCfAiQVcQTQ4J83rg/ZvGMlmO7u16f ZVUrZgLi3gIWbD1nYWIn/TyY621x29WAf2ujlswVMDbz+gIqlQY2xsMnBf24iOcqodjYwB AZuHx1mJum0BvlBLfRO3owG3uA7jSIYvlJk76SGT674SACf3k/hVTxctoF8j6tTnvfBiJm TJpxmSF+F+89IaW4dc53aaz7K39IfuJUM1GJAXAlGyfYK7EW3u9G15Bo58bxnjJGC+xvM/ W6dF+XjmEHvZy7ZOVGezh9I8kN88ttigsOJnIikktGJ2SxuNGgSdh0iBv1CX/A== From: Theodor Thornhill To: 59490@debbugs.gnu.org Subject: 29.0.50; Add C# support Date: Tue, 22 Nov 2022 22:25:56 +0100 Message-ID: <87a64iptp7.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59490 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hmm, It seems I've made a mistake in the C# CC mode variant. Just wait a little, and let me find the problem :-) Theo From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 22 16:47:27 2022 Received: (at 59490) by debbugs.gnu.org; 22 Nov 2022 21:47:27 +0000 Received: from localhost ([127.0.0.1]:52745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxb6z-0005jw-Qm for submit@debbugs.gnu.org; Tue, 22 Nov 2022 16:47:27 -0500 Received: from out2.migadu.com ([188.165.223.204]:11194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxb6v-0005jk-0i for 59490@debbugs.gnu.org; Tue, 22 Nov 2022 16:47:23 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669153639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eZJ6gxeUnUhUt9Z0IAoPKwCTGeOyE7SfKd9QLaP88UE=; b=wdwINaByCFA7BM3fArltg84AuIDq0PbXuKp6KN69trP0fKRBemENeDRe91u+BZcGiUlBko SZvnpkKr4GGG5RueRSuNTfosTrx/U/ASn39A+NCj/ucqMOTQy/4EmwMnVpgiOM3quW7EOD jjEbiTrlY3dZ4FqPETVIhjcW97PPwwNY2HLKZlF40/Iy6sfSIqPv6MtrL2Il0G2M3fXnsq nPnb8LZdkT+Eyj6nMJUiy6YnfSQOsMRP/05XKmPVidYGKtg2MjvDKqHdp7RrysOic1szoH MiBm4t/ySMOrm80ssd0PzZ7pdt4spzhPCwhJWOKLJQCG+RR6IVEYL9+FVfHZfQ== From: Theodor Thornhill To: 59490@debbugs.gnu.org Subject: 29.0.50; Add C# support In-Reply-To: References: <87edtuogp6.fsf@thornhill.no> Date: Tue, 22 Nov 2022 22:47:12 +0100 Message-ID: <87wn7macgv.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59490 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Ok so this works. Sorry for the mess. What do you think? Theo --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-csharp-mode-and-csharp-ts-mode.patch Content-Transfer-Encoding: quoted-printable >From 07ff9e24d55cafad735eb4aa7cba0c772b295c25 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Tue, 22 Nov 2022 21:48:21 +0100 Subject: [PATCH] Add csharp-mode and csharp-ts-mode * etc/NEWS: Mention new modes. * lisp/progmodes/csharp-mode.el (csharp-mode, csharp-ts-mode): New major modes. --- etc/NEWS | 8 + lisp/progmodes/csharp-mode.el | 964 ++++++++++++++++++++++++++++++++++ 2 files changed, 972 insertions(+) create mode 100644 lisp/progmodes/csharp-mode.el diff --git a/etc/NEWS b/etc/NEWS index 5a65896d69..4024c5cac3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2990,6 +2990,14 @@ A major mode based on the tree-sitter library for ed= iting programs in the JSON language. It includes support for font-locking, indentation, Imenu, which-func, and navigation. =20 +** New mode 'csharp-ts-mode'. +A major mode based on the tree-sitter library for editing programs +in the C# language. It includes support for font-locking, +indentation, Imenu, which-func, and navigation. + +** New mode 'csharp-mode'. +A major mode based on CC Mode for editing programs in the C# language. + * Incompatible Lisp Changes in Emacs 29.1 =20 diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el new file mode 100644 index 0000000000..f8fe5bed20 --- /dev/null +++ b/lisp/progmodes/csharp-mode.el @@ -0,0 +1,964 @@ +;;; csharp-mode.el --- Support for editing C# -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. + +;; Author : Theodor Thornhill +;; Maintainer : Theodor Thornhill +;; Created : September 2022 +;; Keywords : c# languages oop + +;; This file is part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Code: + +(require 'compile) +(require 'cc-mode) +(require 'cc-langs) + +(eval-when-compile + (require 'cc-fonts)) + +(defgroup csharp nil + "Major mode for editing C# code." + :group 'prog-mode) + +(eval-and-compile + (defconst csharp--regex-identifier + "[A-Za-z][A-Za-z0-9_]*" + "Regex describing an dentifier in C#.") + + (defconst csharp--regex-identifier-matcher + (concat "\\(" csharp--regex-identifier "\\)") + "Regex matching an identifier in C#.") + + (defconst csharp--regex-type-name + "[A-Z][A-Za-z0-9_]*" + "Regex describing a type identifier in C#.") + + (defconst csharp--regex-type-name-matcher + (concat "\\(" csharp--regex-type-name "\\)") + "Regex matching a type identifier in C#.") + + (defconst csharp--regex-using-or-namespace + (concat "^using" "\\|" "namespace" + "\\s *" + csharp--regex-type-name-matcher) + "Regex matching identifiers after a using or namespace + declaration.")) + +(eval-and-compile + (c-add-language 'csharp-mode 'java-mode) + + (defun csharp--make-mode-syntax-table () + (let ((table (make-syntax-table))) + (c-populate-syntax-table table) + (modify-syntax-entry ?@ "_" table) + table)) + (defvar csharp--make-mode-syntax-table #'csharp--make-mode-syntax-table + "Workaround for Emacs bug#57065.")) + +(c-lang-defconst c-make-mode-syntax-table + csharp #'csharp--make-mode-syntax-table) + +(c-lang-defconst c-identifier-syntax-modifications + csharp (append '((?@ . "w")) + (c-lang-const c-identifier-syntax-modifications))) + +(c-lang-defconst c-symbol-start + csharp (concat "[" c-alpha "_@]")) + +(c-lang-defconst c-opt-type-suffix-key + csharp (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\?\\)")) + +(c-lang-defconst c-identifier-ops + csharp '((left-assoc "."))) + +(c-lang-defconst c-overloadable-operators + csharp '("+" "-" "*" "/" "%" "&" "|" "^" "<<" ">>" "=3D=3D" + "!=3D" ">" "<" ">=3D" "<=3D")) + +(c-lang-defconst c-multiline-string-start-char + csharp ?@) + +(c-lang-defconst c-ml-string-opener-re + ;; "\\(\\(?:@\\$?\\)\\(\"\\)\\)" + csharp + (rx + (group + (or "@" "@$") + (group "\"")))) + +(c-lang-defconst c-ml-string-max-opener-len + csharp 3) + +(c-lang-defconst c-ml-string-max-closer-len + csharp 2) + +(c-lang-defconst c-ml-string-any-closer-re + ;; "\\(?:\"\"\\)*\\(\\(\"\\)\\)\\(?:[^\"]\\|\\'\\)" + csharp + (rx + (seq + (zero-or-more "\"\"") + (group + (group "\"")) + (or (not (any "\"")) eos)))) + +(c-lang-defconst c-ml-string-back-closer-re + ;; "\\(?:\\`\\|[^\"]\\)\"*" + csharp + (rx + (seq + (or bos + (not (any "\""))) + (zero-or-more "\"")))) + +(c-lang-defconst c-type-prefix-kwds + csharp '("class" "interface" "struct")) + +(c-lang-defconst c-class-decl-kwds + csharp '("class" "interface" "struct")) + +;;; Keyword lists + +(c-lang-defconst c-primitive-type-kwds + csharp '("bool" "byte" "sbyte" "char" "decimal" "double" "float" "int" "= uint" + "long" "ulong" "short" "ushort" "void" "object" "string" "var")) + +(c-lang-defconst c-other-decl-kwds + csharp nil) + +(c-lang-defconst c-type-list-kwds + csharp nil) + +(c-lang-defconst c-other-block-decl-kwds + csharp nil) + +(c-lang-defconst c-return-kwds + csharp '("return")) + +(c-lang-defconst c-typedef-kwds + csharp nil) + +(c-lang-defconst c-typeof-kwds + csharp '("typeof" "is" "as")) + +(c-lang-defconst c-type-modifier-prefix-kwds + csharp '("volatile")) + +(c-lang-defconst c-type-modifier-kwds + csharp '("readonly" "new")) + +(c-lang-defconst c-brace-list-decl-kwds + csharp '("enum" "new")) + +(c-lang-defconst c-recognize-post-brace-list-type-p + csharp t) + +(c-lang-defconst c-ref-list-kwds + csharp nil) + +(c-lang-defconst c-using-kwds + csharp '("using")) + +(c-lang-defconst c-equals-type-clause-kwds + csharp '("using")) + +(defun csharp-at-vsemi-p (&optional pos) + (if pos (goto-char pos)) + (save-excursion + (beginning-of-line) + (c-forward-syntactic-ws) + (looking-at "using\\s *("))) + +(c-lang-defconst c-at-vsemi-p-fn + csharp 'csharp-at-vsemi-p) + +(defun csharp-vsemi-status-unknown () t) + +(c-lang-defconst c-vsemi-status-unknown-p-fn + csharp 'csharp-vsemi-status-unknown-p) + + +(c-lang-defconst c-modifier-kwds + csharp '("abstract" "default" "final" "native" "private" "protected" + "public" "partial" "internal" "readonly" "static" "event" "tran= sient" + "volatile" "sealed" "ref" "out" "virtual" "implicit" "explicit" + "fixed" "override" "params" "async" "await" "extern" "unsafe" + "get" "set" "this" "const" "delegate")) + +(c-lang-defconst c-other-kwds + csharp '("select" "from" "where" "join" "in" "on" "equals" "into" + "orderby" "ascending" "descending" "group" "when" + "let" "by" "namespace")) + +(c-lang-defconst c-colon-type-list-kwds + csharp '("class" "struct" "interface")) + +(c-lang-defconst c-block-stmt-1-kwds + csharp '("do" "else" "finally" "try")) + +(c-lang-defconst c-block-stmt-1-2-kwds + csharp '("try")) + +(c-lang-defconst c-block-stmt-2-kwds + csharp '("for" "if" "switch" "while" "catch" "foreach" "fixed" "checked" + "unchecked" "using" "lock")) + +(c-lang-defconst c-simple-stmt-kwds + csharp '("break" "continue" "goto" "throw" "return" "yield")) + +(c-lang-defconst c-constant-kwds + csharp '("true" "false" "null" "value")) + +(c-lang-defconst c-primary-expr-kwds + csharp '("this" "base" "operator")) + +(c-lang-defconst c-inexpr-class-kwds + csharp nil) + +(c-lang-defconst c-class-decl-kwds + csharp '("class" "struct" "interface")) + +(c-lang-defconst c-std-abbrev-keywords + csharp (append (c-lang-const c-std-abbrev-keywords) '("catch" "finally")= )) + +(c-lang-defconst c-decl-prefix-re + csharp "\\([{}(;,<]+\\)") + +(c-lang-defconst c-recognize-typeless-decls + csharp t) + +(c-lang-defconst c-recognize-<>-arglists + csharp t) + +(c-lang-defconst c-opt-cpp-prefix + csharp "\\s *#\\s *") + +(c-lang-defconst c-opt-cpp-macro-define + csharp (if (c-lang-const c-opt-cpp-prefix) + "define")) + +(c-lang-defconst c-cpp-message-directives + csharp '("error" "warning" "region")) + +(c-lang-defconst c-cpp-expr-directives + csharp '("if" "elif")) + +(c-lang-defconst c-other-op-syntax-tokens + csharp (append '("#") + (c-lang-const c-other-op-syntax-tokens))) + +(c-lang-defconst c-line-comment-starter + csharp "//") + +(c-lang-defconst c-doc-comment-start-regexp + csharp "///") + +(c-add-style "csharp" + '("java" + (c-basic-offset . 4) + (c-comment-only-line-offset . (0 . 0)) + (c-offsets-alist . ((inline-open . 0) + (arglist-intro . +) + (arglist-close . 0) + (inexpr-class . 0) + (case-label . +) + (cpp-macro . c-lineup-dont-= change) + (substatement-open . 0))))) + +(eval-and-compile + (unless (or (stringp c-default-style) + (assoc 'csharp-mode c-default-style)) + (setq c-default-style + (cons '(csharp-mode . "csharp") + c-default-style)))) + +(defun csharp--color-forwards (font-lock-face) + (let (id-beginning) + (goto-char (match-beginning 0)) + (forward-word) + (while (and (not (or (eq (char-after) ?\;) + (eq (char-after) ?\{))) + (progn + (forward-char) + (c-forward-syntactic-ws) + (setq id-beginning (point)) + (> (skip-chars-forward + (c-lang-const c-symbol-chars)) + 0)) + (not (get-text-property (point) 'face))) + (c-put-font-lock-face id-beginning (point) font-lock-face) + (c-forward-syntactic-ws)))) + +(c-lang-defconst c-basic-matchers-before + csharp `( + ;; Warning face on unclosed strings + ,@(if (version< emacs-version "27.0") + ;; Taken from 26.1 branch + `(,(c-make-font-lock-search-function + (concat ".\\(" c-string-limit-regexp "\\)") + '((c-font-lock-invalid-string)))) + `(("\\s|" 0 font-lock-warning-face t nil))) + + ;; Invalid single quotes + c-font-lock-invalid-single-quotes + + ;; Keyword constants + ,@(when (c-lang-const c-constant-kwds) + (let ((re (c-make-keywords-re nil (c-lang-const c-constant-= kwds)))) + `((eval . (list ,(concat "\\<\\(" re "\\)\\>") + 1 c-constant-face-name))))) + + ;; Keywords except the primitive types. + ,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp)) + 1 font-lock-keyword-face) + + ;; Chained identifiers in using/namespace statements + ,`(,(c-make-font-lock-search-function + csharp--regex-using-or-namespace + `((csharp--color-forwards font-lock-variable-name-face) + nil + (goto-char (match-end 0))))) + + + ;; Negation character + (eval . (list "\\(!\\)[^=3D]" 1 c-negation-char-face-name)) + + ;; Types after 'new' + (eval . (list (concat "\\ *" csharp--regex-type-name-mat= cher) + 1 font-lock-type-face)) + + ;; Single identifier in attribute + (eval . (list (concat "\\[" csharp--regex-type-name-matcher "\\= ][^;]") + 1 font-lock-variable-name-face t)) + + ;; Function names + (eval . (list "\\([A-Za-z0-9_]+\\)\\(<[a-zA-Z0-9, ]+>\\)?(" + 1 font-lock-function-name-face)) + + ;; Nameof + (eval . (list (concat "\\(\\\\) *(") + 1 font-lock-function-name-face)) + + (eval . (list (concat "\\ *( *" + csharp--regex-identifier-matcher + " *) *") + 1 font-lock-variable-name-face)) + + ;; Catch statements with type only + (eval . (list (concat "\\ *( *" + csharp--regex-type-name-matcher + " *) *") + 1 font-lock-type-face)) + )) + +(c-lang-defconst c-basic-matchers-after + csharp (append + ;; Merge with cc-mode defaults - enables us to add more later + (c-lang-const c-basic-matchers-after))) + +(defcustom csharp-codedoc-tag-face 'c-doc-markup-face-name + "Face to be used on the codedoc docstring tags. + +Should be one of the font lock faces, such as +`font-lock-variable-name-face' and friends. + +Needs to be set before `csharp-mode' is loaded, because of +compilation and evaluation time conflicts." + :type 'symbol) + +(defcustom csharp-font-lock-extra-types + (list csharp--regex-type-name) + (c-make-font-lock-extra-types-blurb "C#" "csharp-mode" (concat)) + :type 'c-extra-types-widget + :group 'c) + +(defconst csharp-font-lock-keywords-1 (c-lang-const c-matchers-1 csharp) + "Minimal font locking for C# mode.") + +(defconst csharp-font-lock-keywords-2 (c-lang-const c-matchers-2 csharp) + "Fast normal font locking for C# mode.") + +(defconst csharp-font-lock-keywords-3 (c-lang-const c-matchers-3 csharp) + "Accurate normal font locking for C# mode.") + +(defvar csharp-font-lock-keywords csharp-font-lock-keywords-3 + "Default expressions to highlight in C# mode.") + +(defun csharp-font-lock-keywords-2 () + (c-compose-keywords-list csharp-font-lock-keywords-2)) +(defun csharp-font-lock-keywords-3 () + (c-compose-keywords-list csharp-font-lock-keywords-3)) +(defun csharp-font-lock-keywords () + (c-compose-keywords-list csharp-font-lock-keywords)) + +;;; Doc comments + +(defconst codedoc-font-lock-doc-comments + ;; Most of this is taken from the javadoc example, however, we don't use= the + ;; '@foo' syntax, so I removed that. Supports the XML tags only + `((,(concat "") + 0 ,csharp-codedoc-tag-face prepend nil) + ;; ("\\([a-zA-Z0-9_]+\\)=3D" 0 font-lock-variable-name-face prepend ni= l) + ;; ("\".*\"" 0 font-lock-string-face prepend nil) + ("&\\(\\sw\\|[.:]\\)+;" ; XML entities. + 0 ,csharp-codedoc-tag-face prepend nil))) + +(defconst codedoc-font-lock-keywords + `((,(lambda (limit) + (c-font-lock-doc-comments "///" limit + codedoc-font-lock-doc-comments))))) + +;;; End of doc comments + +;;; Adding syntax constructs + +(advice-add 'c-looking-at-inexpr-block + :around #'csharp-looking-at-inexpr-block) + +(defun csharp-looking-at-inexpr-block (orig-fun &rest args) + (let ((res (csharp-at-lambda-header))) + (if res + res + (apply orig-fun args)))) + +(defun csharp-at-lambda-header () + (save-excursion + (c-backward-syntactic-ws) + (unless (bobp) + (backward-char) + (c-safe (goto-char (scan-sexps (point) -1))) + (when (or (looking-at "([[:alnum:][:space:]_,]*)[ \t\n]*=3D>[ \t\n]*= {") + (looking-at "[[:alnum:]_]+[ \t\n]*=3D>[ \t\n]*{")) + ;; If we are at a C# lambda header + (cons 'inexpr (point)))))) + +(advice-add 'c-guess-basic-syntax + :around #'csharp-guess-basic-syntax) + +(defun csharp-guess-basic-syntax (orig-fun &rest args) + (cond + (;; Attributes + (save-excursion + (goto-char (c-point 'iopl)) + (and + (eq (char-after) ?\[) + (save-excursion + (c-go-list-forward) + (and (eq (char-before) ?\]) + (not (eq (char-after) ?\;)))))) + `((annotation-top-cont ,(c-point 'iopl)))) + + ((and + ;; Heuristics to find object initializers + (save-excursion + ;; Next non-whitespace character should be '{' + (goto-char (c-point 'boi)) + (eq (char-after) ?{)) + (save-excursion + ;; 'new' should be part of the line + (goto-char (c-point 'iopl)) + (looking-at ".*\\s *new\\s *.*")) + ;; Line should not already be terminated + (save-excursion + (goto-char (c-point 'eopl)) + (or (not (eq (char-before) ?\;)) + (not (eq (char-before) ?\{))))) + (if (save-excursion + ;; if we have a hanging brace on line before + (goto-char (c-point 'eopl)) + (eq (char-before) ?\{)) + `((brace-list-intro ,(c-point 'iopl))) + `((block-open) (statement ,(c-point 'iopl))))) + (t + (apply orig-fun args)))) + +;;; End of new syntax constructs + + + +;;; Fix for strings on version 27.1 + +(when (version=3D emacs-version "27.1") + ;; See: + ;; https://github.com/emacs-csharp/csharp-mode/issues/175 + ;; https://github.com/emacs-csharp/csharp-mode/issues/151 + ;; for the full story. + (defun c-pps-to-string-delim (end) + (let* ((start (point)) + (no-st-s `(0 nil nil ?\" nil nil 0 nil ,start nil nil)) + (st-s `(0 nil nil t nil nil 0 nil ,start nil nil)) + no-st-pos st-pos + ) + (parse-partial-sexp start end nil nil no-st-s 'syntax-table) + (setq no-st-pos (point)) + (goto-char start) + (while (progn + (parse-partial-sexp (point) end nil nil st-s 'syntax-table) + (unless (bobp) + (c-clear-syn-tab (1- (point)))) + (setq st-pos (point)) + (and (< (point) end) + (not (eq (char-before) ?\"))))) + (goto-char (min no-st-pos st-pos)) + nil)) + + (defun c-multiline-string-check-final-quote () + (let (pos-ll pos-lt) + (save-excursion + (goto-char (point-max)) + (skip-chars-backward "^\"") + (while + (and + (not (bobp)) + (cond + ((progn + (setq pos-ll (c-literal-limits) + pos-lt (c-literal-type pos-ll)) + (memq pos-lt '(c c++))) + ;; In a comment. + (goto-char (car pos-ll))) + ((save-excursion + (backward-char) ; over " + (c-is-escaped (point))) + ;; At an escaped string. + (backward-char) + t) + (t + ;; At a significant " + (c-clear-syn-tab (1- (point))) + (setq pos-ll (c-literal-limits) + pos-lt (c-literal-type pos-ll)) + nil))) + (skip-chars-backward "^\"")) + (cond + ((bobp)) + ((eq pos-lt 'string) + (c-put-syn-tab (1- (point)) '(15))) + (t nil)))))) + +;;; End of fix for strings on version 27.1 + +;; When invoked by MSBuild, csc=E2=80=99s errors look like this: +;; subfolder\file.cs(6,18): error CS1006: Name of constructor must +;; match name of class [c:\Users\user\project.csproj] + +(defun csharp--compilation-error-file-resolve () + "Resolve an msbuild error to a (filename . dirname) cons cell." + ;; http://stackoverflow.com/a/18049590/429091 + (cons (match-string 1) (file-name-directory (match-string 4)))) + +(defconst csharp-compilation-re-msbuild-error + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): " + "error [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$") + "Regexp to match compilation error from msbuild.") + +(defconst csharp-compilation-re-msbuild-warning + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): " + "warning [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$") + "Regexp to match compilation warning from msbuild.") + +;; Notes on xbuild and devenv commonalities +;; +;; These regexes were tailored for xbuild, but apart from the concurrent +;; build-marker ("1>") they share exactly the same match-markers. +;; +;; If we don't exclude the match-markers explicitly, these regexes +;; will also be used to match for devenv as well, including the build-mark= er +;; in the file-name, causing the lookup to fail. +;; +;; So if we don't want devenv to fail, we actually need to handle it in our +;; xbuild-regexes, but then we automatically get devenv-support for free. + +(defconst csharp-compilation-re-xbuild-error + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?" + ;; handle weird devenv output format with 4 numbers, not 2 by having op= tional + ;; extra capture-groups. + "\\(?:,\\([0-9]+\\)\\)*): " + "error [[:alnum:]]+: .+$") + "Regexp to match compilation error from xbuild.") + +(defconst csharp-compilation-re-xbuild-warning + (concat + "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?" + "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?" + ;; handle weird devenv output format with 4 numbers, not 2 by having op= tional + ;; extra capture-groups. + "\\(?:,\\([0-9]+\\)\\)?*): " + "warning [[:alnum:]]+: .+$") + "Regexp to match compilation warning from xbuild.") + +(defconst csharp-compilation-re-dotnet-error + "\\([^\r\n]+\\) : error [A-Z]+[0-9]+:") + +(defconst csharp-compilation-re-dotnet-warning + "\\([^\r\n]+\\) : warning [A-Z]+[0-9]+:") + +(defconst csharp-compilation-re-dotnet-testfail + (concat + "[[:blank:]]+Stack Trace:\n" + "[[:blank:]]+at [^\n]+ in \\([^\n]+\\):line \\([0-9]+\\)")) + + +(eval-after-load 'compile + (lambda () + (dolist + (regexp + `((dotnet-testfail + ,csharp-compilation-re-dotnet-testfail + 1 2) + (xbuild-error + ,csharp-compilation-re-xbuild-error + 1 2 3 2) + (xbuild-warning + ,csharp-compilation-re-xbuild-warning + 1 2 3 1) + (msbuild-error + ,csharp-compilation-re-msbuild-error + csharp--compilation-error-file-resolve + 2 + 3 + 2 + nil + (1 compilation-error-face) + (4 compilation-error-face)) + (msbuild-warning + ,csharp-compilation-re-msbuild-warning + csharp--compilation-error-file-resolve + 2 + 3 + 1 + nil + (1 compilation-warning-face) + (4 compilation-warning-face)) + (dotnet-error + ,csharp-compilation-re-dotnet-error + 1) + (dotnet-warning + ,csharp-compilation-re-dotnet-warning + 1 nil nil 1))) + (add-to-list 'compilation-error-regexp-alist-alist regexp) + (add-to-list 'compilation-error-regexp-alist (car regexp))))) + +(defvar csharp-mode-syntax-table + (funcall (c-lang-const c-make-mode-syntax-table csharp)) + "Syntax table used in `csharp-mode' buffers.") + +(defvar csharp-mode-map + (let ((map (c-make-inherited-keymap))) + map) + "Keymap used in `csharp-mode' buffers.") + +(easy-menu-define csharp-mode-menu csharp-mode-map "C# Mode Commands." + (cons "C#" (c-lang-const c-mode-menu csharp))) + +;;; Tree-sitter support + +(defcustom csharp-ts-mode-indent-offset 4 + "Number of spaces for each indentation step in `csharp-ts-mode'." + :type 'integer + :safe 'integerp + :group 'csharp) + +(defvar csharp-ts-mode--indent-rules + `((c-sharp + ((parent-is "compilation_unit") parent-bol 0) + ((node-is "}") parent-bol 0) + ((node-is ")") parent-bol 0) + ((node-is "]") parent-bol 0) + ((parent-is "namespace_declaration") parent-bol 0) + ((parent-is "class_declaration") parent-bol 0) + ((parent-is "constructor_declaration") parent-bol 0) + ((parent-is "method_declaration") parent-bol 0) + ((parent-is "enum_declaration") parent-bol 0) + ((parent-is "operator_declaration") parent-bol 0) + ((parent-is "field_declaration") parent-bol 0) + ((parent-is "struct_declaration") parent-bol 0) + ((parent-is "declaration_list") parent-bol csharp-ts-mode-indent-offs= et) + ((parent-is "argument_list") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "interpolation") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "binary_expression") parent 0) + ((parent-is "block") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "local_function_statement") parent-bol 0) + ((parent-is "if_statement") parent-bol 0) + ((parent-is "for_statement") parent-bol 0) + ((parent-is "for_each_statement") parent-bol 0) + ((parent-is "while_statement") parent-bol 0) + ((match "{" "switch_expression") parent-bol 0) + ((parent-is "switch_statement") parent-bol 0) + ((parent-is "switch_body") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "switch_section") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "switch_expression") parent-bol csharp-ts-mode-indent-off= set) + ((parent-is "case_statement") parent-bol 0) + ((parent-is "do_statement") parent-bol 0) + ((parent-is "equals_value_clause") parent-bol csharp-ts-mode-indent-o= ffset) + ((parent-is "ternary_expression") parent-bol csharp-ts-mode-indent-of= fset) + ((parent-is "conditional_expression") parent-bol csharp-ts-mode-inden= t-offset) + ((parent-is "statement_block") parent-bol csharp-ts-mode-indent-offse= t) + ((parent-is "type_arguments") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "variable_declarator") parent-bol csharp-ts-mode-indent-o= ffset) + ((parent-is "arguments") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "array") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "formal_parameters") parent-bol csharp-ts-mode-indent-off= set) + ((parent-is "template_substitution") parent-bol csharp-ts-mode-indent= -offset) + ((parent-is "object_pattern") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "object") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "object_type") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "enum_body") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "arrow_function") parent-bol csharp-ts-mode-indent-offset) + ((parent-is "parenthesized_expression") parent-bol csharp-ts-mode-ind= ent-offset)))) + +(defvar csharp-ts-mode--keywords + '("using" "namespace" "class" "if" "else" "throw" "new" "for" + "return" "await" "struct" "enum" "switch" "case" + "default" "typeof" "try" "catch" "finally" "break" + "foreach" "in" "yield" "get" "set" "when" "as" "out" + "is" "while" "continue" "this" "ref" "goto" "interface" + "from" "where" "select" "lock" "base" "record" "init" + "with" "let" "static" "var" "do" "public" "private" + "readonly" "unmanaged") + "C# keywords for tree-sitter font-locking.") + +(defvar csharp-ts-mode--font-lock-settings + (treesit-font-lock-rules + :language 'c-sharp + :override t + :feature 'comment + '((comment) @font-lock-comment-face) + :language 'c-sharp + :override t + :feature 'keyword + `([,@csharp-ts-mode--keywords] @font-lock-keyword-face + (modifier) @font-lock-keyword-face + (this_expression) @font-lock-keyword-face) + :language 'c-sharp + :override t + :feature 'attribute + `((attribute (identifier) @font-lock-property-face (attribute_argument_= list)) + (attribute (identifier) @font-lock-property-face)) + :language 'c-sharp + :override t + :feature 'escape-sequence + '((escape_sequence) @font-lock-escape-face) + :language 'c-sharp + :override t + :feature 'literal + `((integer_literal) @font-lock-constant-face + (real_literal) @font-lock-constant-face + (null_literal) @font-lock-constant-face + (boolean_literal) @font-lock-constant-face) + :language 'c-sharp + :override t + :feature 'string + `([(string_literal) + (verbatim_string_literal) + (interpolated_string_text) + (interpolated_verbatim_string_text) + (character_literal) + "\"" + "$\"" + "@$\"" + "$@\""] @font-lock-string-face) + :language 'c-sharp + :override t + :feature 'type + '((predefined_type) @font-lock-type-face + (implicit_type) @font-lock-type-face + (nullable_type) @font-lock-type-face + (type_parameter + (identifier) @font-lock-type-face) + (type_argument_list + (identifier) @font-lock-type-face) + (generic_name + (identifier) @font-lock-type-face) + (array_type + (identifier) @font-lock-type-face) + (cast_expression (identifier) @font-lock-type-face) + ["operator"] @font-lock-type-face + (type_parameter_constraints_clause + target: (identifier) @font-lock-type-face)) + :language 'c-sharp + :feature 'definition + :override t + '((qualified_name (identifier) @font-lock-variable-name-face) + (using_directive (identifier) @font-lock-type-face) + + (enum_declaration (identifier) @font-lock-type-face) + (enum_member_declaration (identifier) @font-lock-variable-name-face) + + (interface_declaration (identifier) @font-lock-type-face) + + (struct_declaration (identifier) @font-lock-type-face) + + (record_declaration (identifier) @font-lock-type-face) + (namespace_declaration (identifier) @font-lock-type-face) + (base_list (identifier) @font-lock-type-face) + (property_declaration (generic_name)) + (property_declaration + type: (nullable_type) @font-lock-type-face + name: (identifier) @font-lock-variable-name-face) + (property_declaration + type: (predefined_type) @font-lock-type-face + name: (identifier) @font-lock-variable-name-face) + (property_declaration + type: (identifier) @font-lock-type-face + name: (identifier) @font-lock-variable-name-face) + (class_declaration (identifier) @font-lock-type-face) + + (constructor_declaration name: (_) @font-lock-type-face) + + (method_declaration type: (_) @font-lock-type-face) + (method_declaration name: (_) @font-lock-function-name-face) + + (variable_declaration (identifier) @font-lock-type-face) + (variable_declarator (identifier) @font-lock-variable-name-face) + + (parameter type: (identifier) @font-lock-type-face) + (parameter name: (identifier) @font-lock-variable-name-face)) + :language 'c-sharp + :feature 'expression + '((conditional_expression (identifier) @font-lock-variable-name-face) + (postfix_unary_expression (identifier)* @font-lock-variable-name-face) + (assignment_expression (identifier) @font-lock-variable-name-face)) + :language 'c-sharp + :feature 'bracket + '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) + + :language 'c-sharp + :feature 'delimiter + '((["," ":" ";"]) @font-lock-delimiter-face))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-cc-mode)) + +(defun csharp-ts-mode--imenu-1 (node) + "Helper for `csharp-ts-mode--imenu'. +Find string representation for NODE and set marker, then recurse +the subtrees." + (let* ((ts-node (car node)) + (subtrees (mapcan #'csharp-ts-mode--imenu-1 (cdr node))) + (name (when ts-node + (or (treesit-node-text + (or (treesit-node-child-by-field-name + ts-node "name")) + t) + "Unnamed node"))) + (marker (when ts-node + (set-marker (make-marker) + (treesit-node-start ts-node))))) + (cond + ((null ts-node) subtrees) + (subtrees + `((,name ,(cons name marker) ,@subtrees))) + (t + `((,name . ,marker)))))) + +(defun csharp-ts-mode--imenu () + "Return Imenu alist for the current buffer." + (let* ((node (treesit-buffer-root-node)) + (class-tree (treesit-induce-sparse-tree + node "^class_declaration$" nil 1000)) + (interface-tree (treesit-induce-sparse-tree + node "^interface_declaration$" nil 1000)) + (enum-tree (treesit-induce-sparse-tree + node "^enum_declaration$" nil 1000)) + (struct-tree (treesit-induce-sparse-tree + node "^struct_declaration$" nil 1000)) + (record-tree (treesit-induce-sparse-tree + node "^record_declaration$" nil 1000)) + (method-tree (treesit-induce-sparse-tree + node "^method_declaration$" nil 1000)) + (class-index (csharp-ts-mode--imenu-1 class-tree)) + (interface-index (csharp-ts-mode--imenu-1 interface-tree)) + (enum-index (csharp-ts-mode--imenu-1 enum-tree)) + (record-index (csharp-ts-mode--imenu-1 record-tree)) + (struct-index (csharp-ts-mode--imenu-1 struct-tree)) + (method-index (csharp-ts-mode--imenu-1 method-tree))) + (append + (when class-index `(("Class" . ,class-index))) + (when interface-index `(("Interface" . ,interface-index))) + (when enum-index `(("Enum" . ,enum-index))) + (when record-index `(("Record" . ,record-index))) + (when struct-index `(("Struct" . ,struct-index))) + (when method-index `(("Method" . ,method-index)))))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode)) + +;;;###autoload +(define-derived-mode csharp-mode prog-mode "C#" + "Major mode for editing Csharp code. + +Key bindings: +\\{csharp-mode-map}" + :after-hook (c-update-modeline) + (c-initialize-cc-mode t) + (c-init-language-vars csharp-mode) + (c-common-init 'csharp-mode) + (setq-local c-doc-comment-style '((csharp-mode . codedoc))) + (run-mode-hooks 'c-mode-common-hook)) + +;;;###autoload +(define-derived-mode csharp-ts-mode prog-mode "C#" + "Major mode for editing C# code." + + (unless (treesit-ready-p 'c-sharp) + (error "Tree-sitter for C# isn't available")) + + ;; Tree-sitter. + (treesit-parser-create 'c-sharp) + + ;; Comments. + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") + + ;; Indent. + (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) + + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + + ;; Navigation. + (setq-local treesit-defun-type-regexp "declaration") + + ;; Font-lock. + (setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-setting= s) + (setq-local treesit-font-lock-feature-list + '((comment keyword constant string) + (type definition expression literal attribute) + (bracket delimiter))) + + ;; Imenu. + (setq-local imenu-create-index-function #'csharp-ts-mode--imenu) + (setq-local which-func-functions nil) ;; Piggyback on imenu + (treesit-major-mode-setup)) + +(provide 'csharp-mode) + +;;; csharp-mode.el ends here --=20 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 07:15:57 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 12:15:57 +0000 Received: from localhost ([127.0.0.1]:54034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxofV-0001Fx-8q for submit@debbugs.gnu.org; Wed, 23 Nov 2022 07:15:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxofS-0001Fi-Pz for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 07:15:55 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxofM-0007op-Vj; Wed, 23 Nov 2022 07:15:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=TUgjSwdSfY24vn7YtvwC5xtM1I/UpTKKvXu+XQ35q8E=; b=WiS+MPv7TXeT UKgBlQ7jmDE4el9dzZzUiRBNqWMfX9vmCyxThJyJjAscsrcUp4jYwiiTSJ71aXvXvrfwUDUeog0eu 6BUXWlOCVWGF+CISQCNwNgzTZ8aYyPw6hsuLswOcUeLURo6d+DMtmM/zcxeETZppSQw2B5+zmQttu hJiOQp5zuPjArH0WqEUCCEmxGnscbD+mn6DTcgvqpBC8ApYYxIVHTMMzBJbW5DOYUdgJswsxxvsoO pqJM2GlcgPBdxd5btCyE9Tnq+xQAQVtrI0GWz99NWZXqamWKiopNI4imlePmyaNFRsoaDnN7sRErA qYoiORlM0TMFaKJPefuoPA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxofM-0000J4-Dz; Wed, 23 Nov 2022 07:15:48 -0500 Date: Wed, 23 Nov 2022 14:16:05 +0200 Message-Id: <83r0xtzx16.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87wn7macgv.fsf@thornhill.no> (bug-gnu-emacs@gnu.org) Subject: Re: bug#59490: 29.0.50; Add C# support References: <87edtuogp6.fsf@thornhill.no> <87wn7macgv.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59490 Cc: 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Tue, 22 Nov 2022 22:47:12 +0100 > From: Theodor Thornhill via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Ok so this works. > > Sorry for the mess. > > What do you think? LGTM, thanks. I'll let Yuan review and install. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 13:30:09 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 18:30:09 +0000 Received: from localhost ([127.0.0.1]:56166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxuVd-0001kq-Au for submit@debbugs.gnu.org; Wed, 23 Nov 2022 13:30:09 -0500 Received: from mail-pl1-f178.google.com ([209.85.214.178]:36803) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxuVZ-0001io-4D for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 13:30:07 -0500 Received: by mail-pl1-f178.google.com with SMTP id y10so16208344plp.3 for <59490@debbugs.gnu.org>; Wed, 23 Nov 2022 10:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=upAsuJCeeS74Zmh526qIe5THiRUEcPC0+EvGwiOhBEg=; b=prMCCRHpIc2/+8A4yjTVYwNrAdmO0wCPdPfQOBu0duU5Tp/ATkkasfvcuy8n8+60at Sr11IVnRezW9nuta3Sul1AASfMqov2ccO8jsZ+myr9faDMaOtXOM5zgmrUcepNdylqk9 Y654QibNPqh/IZ/geyW23gIzSjyod1/EWvFMRuqc07HW2Xi+RZmcCZbeyb8HEYsa7y94 CHSqFr8bpnOXIABGlkkrMP0nhqrtd/Mf62vHFh6EX94CqdYgingnPZznNmKHm38T6Vkw d+JEMVHwC6oFyGm9mfr5fsa4sqdX+2bkmzYqDrH0LN/F/STKfe30goUHpmsFIIzi7sM8 3+/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=upAsuJCeeS74Zmh526qIe5THiRUEcPC0+EvGwiOhBEg=; b=NXQekqjBx/kQS94L8fHhSbTpQbD2RGfNLfBdeOpPyM+eWP2qyQSBiLLvzbIo0AUlpR UKhBRjLjoPrHXsfYXKZvEX+k7BLiBQY32dx0Mo5KW1yxExWK1CUGICGxk4jl67UD+zBv W+vsaXNu3a1xfpSae3LU9djcSV05mmK9Ul0an1tiZr4h0hQNGfsWJJrpASyOh7Gha0Id 9wiFBg+BxmiBgwc6NqJ+0IOdbp3r27rRdh25Il5cFkhWAFVtGfO6ZrW/NME1qaEMIg38 j4EJj4qlFvF23wQU/wCdRspkRIWcEXYoYGDJDrxpxSUfnmr1UOIYHBB3JWrzkiUZm4FO hw8A== X-Gm-Message-State: ANoB5pnjPRTzUzvZwBeNLJWGhKc26cAJmd3UOfdk+rF+uQX3alClflKE PfGZZaSHRhQKMHvAdkzraO0= X-Google-Smtp-Source: AA0mqf7YFrHv5baagG4yf+60aaXldYXE4IR36IEw8W0CvkkpNB3ZsF18xpooHDq5eHrPlL7tLDOjpg== X-Received: by 2002:a17:90b:3e8b:b0:1fb:825c:af8a with SMTP id rj11-20020a17090b3e8b00b001fb825caf8amr36966671pjb.104.1669228198940; Wed, 23 Nov 2022 10:29:58 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id k7-20020a170902c40700b001894198d0ebsm2067450plk.24.2022.11.23.10.29.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2022 10:29:58 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59490: 29.0.50; Add C# support Message-Id: <55FA74B7-9048-40E5-A2EB-687EBDE85D7E@gmail.com> Date: Wed, 23 Nov 2022 10:29:57 -0800 To: Eli Zaretskii X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59490 Cc: theo@thornhill.no, 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Date: Tue, 22 Nov 2022 22:47:12 +0100 >> From: Theodor Thornhill via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >>=20 >> Ok so this works. >>=20 >> Sorry for the mess. >>=20 >> What do you think? > > LGTM, thanks. I'll let Yuan review and install. Thanks Theo! I=E2=80=99ve merged it. One general comment is that we = should have a "standard" list of features consistent across major modes. I think by now we=E2=80=99ve worked on font-lock enough to know what those features = should be. I=E2=80=99ll start a discussion on the ML. Yuan From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 13:44:41 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 18:44:41 +0000 Received: from localhost ([127.0.0.1]:56221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxujg-00029T-Si for submit@debbugs.gnu.org; Wed, 23 Nov 2022 13:44:41 -0500 Received: from out0.migadu.com ([94.23.1.103]:20706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxuje-00029K-Ht for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 13:44:39 -0500 Date: Wed, 23 Nov 2022 19:44:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669229077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2j8GAiIqkQkj4WvnucUEtrr380zi6zm4ZXfPke/fYT0=; b=aQ/ejmZNBW4wKL7N198Hyj/8gxcuulWjEnJzqbMZ5hsx6mF7rS86KLbKRLoRE0v1e8MyS8 Dn4ZHyiPhlClmEWOf2gzM8lzsdJg1HxY7CPGJ1RR7Op1eHogka0D8RTH/R6swqQ4DzyS9N bCi9MNM2dgb3parKSVHKVQf288vhgdSyV6IuiiHEFPoHG65mGRjLb671wunyQKdK6IgkAU xBtjdn0Ssj+75A3LYAv7hPuH5YGM1z+d5Sv75FfITZejjmWLRcamivOnGfVi+u++bGK1SI wt20l8GNm2MueXN/ewZihaoah7r8my9PUEsm72jK/KO4lVRig6tKSfMU7h0JPQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Yuan Fu , Eli Zaretskii Subject: Re: bug#59490: 29.0.50; Add C# support In-Reply-To: <55FA74B7-9048-40E5-A2EB-687EBDE85D7E@gmail.com> References: <55FA74B7-9048-40E5-A2EB-687EBDE85D7E@gmail.com> Message-ID: <92C05465-1347-405A-B04D-B619EE822F45@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59490 Cc: 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 23 November 2022 19:29:57 CET, Yuan Fu wrote: > >Eli Zaretskii writes: > >>> Date: Tue, 22 Nov 2022 22:47:12 +0100 >>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" >>>=20 >>> Ok so this works=2E >>>=20 >>> Sorry for the mess=2E >>>=20 >>> What do you think? >> >> LGTM, thanks=2E I'll let Yuan review and install=2E > >Thanks Theo! I=E2=80=99ve merged it=2E One general comment is that we sho= uld have >a "standard" list of features consistent across major modes=2E I think by >now we=E2=80=99ve worked on font-lock enough to know what those features = should >be=2E I=E2=80=99ll start a discussion on the ML=2E > >Yuan I agree! From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 15:38:32 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 20:38:32 +0000 Received: from localhost ([127.0.0.1]:56377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxwVr-0007Mn-TS for submit@debbugs.gnu.org; Wed, 23 Nov 2022 15:38:32 -0500 Received: from mail-pf1-f172.google.com ([209.85.210.172]:34438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxwVn-0007MW-0b for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 15:38:30 -0500 Received: by mail-pf1-f172.google.com with SMTP id z26so18406770pff.1 for <59490@debbugs.gnu.org>; Wed, 23 Nov 2022 12:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=MrD0eQoqDILTTw8kDCKzCP++8pbK+xAgsUhrSxBNhI8=; b=Zreer/4O1Zdh1WIl2ZA92jd4YV9QOAbzwqGFZB7jezbVpzWL4fW6KeUGTyBFJ8Xa2a BMQ1BFAgCwtf9bFKtsOwFq92BgS8RT5KrBlEhyZGyWBT/I3PcCL9z7SmZgPDymK7y5HR YVXChzsZzL/JeAtZEq8I7jGMTM1TNOO6HBYkFMNBVrGadqgWYD+iIYHRV2xboIZntcFA hd6LnPU1cVygaL2reyOyrewbURTIWmAH9hobsTqFcY8qyBoO+vNYjA+ZaGhnFzIgJut0 WXGyoViCeHnUK+cUhv4qbPfz4qyNgz23RqZ02SdD7+bxotWpfPEfvx90HTCudW1o0Wma 9B/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MrD0eQoqDILTTw8kDCKzCP++8pbK+xAgsUhrSxBNhI8=; b=rF8OtZmP3DboRyawVYskrSky1bj6bAXMzeoMZW3eCxAezHsBciQYvcZh9wQ/S4SF5a DJLjIUrx83MNIW5LTmkIu+PJw/4nst5Rm/QaEqwr8hNPgT+9+EThGVn+lzFLeVPFxvEW L47ok6MLWy/r6rZBa0v2GDaSEiDte98wiR5SbC001tZoB10MMcQFOLH6mLL1K7gATM9k bC6rf1kiTeFDBBqUCNqsFG1Oo6q9+ZfcK9Ctq4cx3qflwQ8jeDDIu4tkaTTfZebhkQQ2 OOZIfs/hL553Oq8UPIndKxsb8vHraTim0V5j7GPb11JPAT3obeNhIZEUwXUdx7GwSugO cxSw== X-Gm-Message-State: ANoB5pkZxLVcK+XeCN6+GD+0XuOmk70c/9rURu8LeIogQH+DYWdI2RqI jWJq6d2IWSFVbOztze7HioY= X-Google-Smtp-Source: AA0mqf6YL9p+tfYHZF35uP1n2AlWQ5Hbl8JhxpK4NHGrYtslzAVRjGAVMz8sUWc16ZDE31MOVzC1jA== X-Received: by 2002:a63:e84f:0:b0:477:7dc8:57a7 with SMTP id a15-20020a63e84f000000b004777dc857a7mr8956989pgk.498.1669235900906; Wed, 23 Nov 2022 12:38:20 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id i8-20020a170902c94800b00172fad607b3sm14845716pla.207.2022.11.23.12.38.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2022 12:38:20 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59490: 29.0.50; Add C# support Message-Id: Date: Wed, 23 Nov 2022 12:38:19 -0800 To: Eli Zaretskii X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59490 Cc: theo@thornhill.no, 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Yuan Fu writes: > Eli Zaretskii writes: > >>> Date: Tue, 22 Nov 2022 22:47:12 +0100 >>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" >>>=20 >>> Ok so this works. >>>=20 >>> Sorry for the mess. >>>=20 >>> What do you think? >> >> LGTM, thanks. I'll let Yuan review and install. > > Thanks Theo! I=E2=80=99ve merged it. One general comment is that we = should have > a "standard" list of features consistent across major modes. I think = by > now we=E2=80=99ve worked on font-lock enough to know what those = features should > be. I=E2=80=99ll start a discussion on the ML. Actually, another thing: it seems the mode defined is still named csharp-mode rather than csharp-cc-mode. Yuan From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 15:44:13 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 20:44:13 +0000 Received: from localhost ([127.0.0.1]:56382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxwbL-0007VM-Sw for submit@debbugs.gnu.org; Wed, 23 Nov 2022 15:44:12 -0500 Received: from out2.migadu.com ([188.165.223.204]:44631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxwbF-0007V4-Gm for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 15:44:08 -0500 Date: Wed, 23 Nov 2022 21:43:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669236244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C0oTK+4wLLo1dfEuR6XGVd3Zrm9LYv4U5XrUomuGquQ=; b=Z6Pr8QQT2x1RoFlG5D8ySmnqjF/W0FaWAcGGZEy+R2zcNAUnvzY4+ioIod0kLabKtx+fhC RQfmJie9g9TmbJbBpqDFWEowXzUk2Vet0BCiCndltI/yEIwxLYwesSOa7NW/cCAP+1khSN DGW1mFLNGpiNxeaacncQDw1+lfzlkVuS9S18JnBBiFmmJxU4JVnjOJU6/x+fdGuYQVyXO5 0T9abduUCBToKCIT5b2xmSlgin8RvCCT7v5wdKxQZM+TcnU0/an/gootcLWDwDdg0Nuk8P iS/je9TCVaODFt+/jyEQ7iSX6J9DATJADYChWxDJnku81hxahZ8f5fZS/TLhdQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Yuan Fu , Eli Zaretskii Subject: Re: bug#59490: 29.0.50; Add C# support In-Reply-To: References: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59490 Cc: 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 23 November 2022 21:38:19 CET, Yuan Fu wrote: > >Yuan Fu writes: > >> Eli Zaretskii writes: >> >>>> Date: Tue, 22 Nov 2022 22:47:12 +0100 >>>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>>> the Swiss army knife of text editors" >>>>=20 >>>> Ok so this works=2E >>>>=20 >>>> Sorry for the mess=2E >>>>=20 >>>> What do you think? >>> >>> LGTM, thanks=2E I'll let Yuan review and install=2E >> >> Thanks Theo! I=E2=80=99ve merged it=2E One general comment is that we s= hould have >> a "standard" list of features consistent across major modes=2E I think = by >> now we=E2=80=99ve worked on font-lock enough to know what those feature= s should >> be=2E I=E2=80=99ll start a discussion on the ML=2E > >Actually, another thing: it seems the mode defined is still named >csharp-mode rather than csharp-cc-mode=2E > >Yuan Yeah that's right=2E Imo that's ok, because it's unlikely there will be mu= ch new development on the cc mode variant=2E So it will be identical to the= upstream one, and the upstream one will be marked as deprecated very soon= =2E What do you think? From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 16:19:33 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 21:19:33 +0000 Received: from localhost ([127.0.0.1]:56421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxx9Z-0008SF-Ad for submit@debbugs.gnu.org; Wed, 23 Nov 2022 16:19:33 -0500 Received: from mail-pg1-f181.google.com ([209.85.215.181]:45748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxx9V-0008S0-OT for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 16:19:32 -0500 Received: by mail-pg1-f181.google.com with SMTP id r18so17780212pgr.12 for <59490@debbugs.gnu.org>; Wed, 23 Nov 2022 13:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=//S/hwKRy4gMGC8KNhag1YjktdekgJpzHAiA4kQMZ+c=; b=gpZigJk83QfICLW1h7V+uBMiA4cEdRHd3CUtmv/qGBD+DWXqYiw+xCDYouajQqpl6C BO9jdEVSuLDcfKx624DDS4dvSmk2m3oHOmRWVtr7xoGIfW44P3IZhAKqNlWAx1qzkxsW C3vXMMCOTXFvC2Kt72pEtxzZL+IqzAqXwI5pI+ycgOtoxdNaowZt6ZmQj4hlllwDJGHA /tNSnpeG6x50OjgDc6uBDDIL+zUaBI1EBbyuCG4EA8dLhq8M1HzWoCgeTqFq308CfxGj VaV6NFuHdgQ4Ip+p/U4pBKbnLDT7BeUp4mCfn2wIkD0QeV7KZGsY+dpE7f7biocJiUJA JpWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=//S/hwKRy4gMGC8KNhag1YjktdekgJpzHAiA4kQMZ+c=; b=puI8Za+8aWESVvVi1MYnttjIStrnRYaV9AXW/Ne3u5zSHsEv9iJ78WuAAVWR0aWsGV 1tNVsrkdQebwiwFbP/ReiayDWe2hjVYSSwLK0Ce/xdI7xc3vacsKHdyh3YP6fjQa6mD3 qz3/wvQeHbS/baeqEArzFzSjsMk/c6GU0t+tXcEdTLBykF9cPfdZTt/8YLJBR+YvSDIG v9zKiWrynE7OWjBj1AKae9aULmRv+LZZ4qKEksbkHRv13msXKE5HJwFwU/jfKc78nLTD WCaxqymblZ6ACNkP1X70RVg4jBOYhIe5zgMpB71fPBVCYQ2rlbD69hOghuUrsCg+WbS5 yMBA== X-Gm-Message-State: ANoB5plOzRvTPg6KHI5Dn/NrxIS7/YUmKwkbxlMcGgFYuPwFiO0fDVZe XRe+I13AsNUNdnz53u6u7DI= X-Google-Smtp-Source: AA0mqf63G/UIT+tI8IqGTb9JwZwE2EhPd5uE0E/Mbqz2lt2BcMHTgoCJ8BfJ2k1KfCXq2+7g9JF5Hg== X-Received: by 2002:a63:de01:0:b0:476:32a2:253 with SMTP id f1-20020a63de01000000b0047632a20253mr12036271pgg.133.1669238363623; Wed, 23 Nov 2022 13:19:23 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id ik18-20020a170902ab1200b001767f6f04efsm4094595plb.242.2022.11.23.13.19.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2022 13:19:23 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59490: 29.0.50; Add C# support From: Yuan Fu In-Reply-To: Date: Wed, 23 Nov 2022 13:19:21 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59490 Cc: Eli Zaretskii , 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Nov 23, 2022, at 12:43 PM, Theodor Thornhill = wrote: >=20 >=20 >=20 > On 23 November 2022 21:38:19 CET, Yuan Fu wrote: >>=20 >> Yuan Fu writes: >>=20 >>> Eli Zaretskii writes: >>>=20 >>>>> Date: Tue, 22 Nov 2022 22:47:12 +0100 >>>>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>>>> the Swiss army knife of text editors" >>>>>=20 >>>>> Ok so this works. >>>>>=20 >>>>> Sorry for the mess. >>>>>=20 >>>>> What do you think? >>>>=20 >>>> LGTM, thanks. I'll let Yuan review and install. >>>=20 >>> Thanks Theo! I=E2=80=99ve merged it. One general comment is that we = should have >>> a "standard" list of features consistent across major modes. I think = by >>> now we=E2=80=99ve worked on font-lock enough to know what those = features should >>> be. I=E2=80=99ll start a discussion on the ML. >>=20 >> Actually, another thing: it seems the mode defined is still named >> csharp-mode rather than csharp-cc-mode. >>=20 >> Yuan >=20 > Yeah that's right. Imo that's ok, because it's unlikely there will be = much new development on the cc mode variant. So it will be identical to = the upstream one, and the upstream one will be marked as deprecated very = soon. >=20 > What do you think? Yeah I was just confused because you said > I made two new modes, 'csharp-cc-mode' and 'csharp-ts-mode'. The = cc-mode > variant has that name as to not conflict with the ELPA package. And I only see csharp-mode. So the mode we provide in Emacs are csharp-mode and csharp-ts-mode? Then = I assume this line is a typo? ;;;###autoload (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-cc-mode)) Yuan From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 16:25:23 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 21:25:23 +0000 Received: from localhost ([127.0.0.1]:56432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxxFD-0000AX-6b for submit@debbugs.gnu.org; Wed, 23 Nov 2022 16:25:23 -0500 Received: from out0.migadu.com ([94.23.1.103]:17350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxxFB-0000AM-3f for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 16:25:22 -0500 Date: Wed, 23 Nov 2022 22:25:12 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669238719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YXYN1aAAZstog7cCrZC1Ttf6fr2nS2apfor9RWfO9go=; b=H9zNtPJ8dtqpLPsco89CBGwESynAFb4oaJs5UXO2YqSfXH2n2sDzSUr5X/nWuq/Nag3Mj5 jDf+vFVH6wb9S10K3skiHyoEfyih81tQ2YzxDcPQ1qnHqbo5lBNTfkwT3f+uEz/7rSjyus AHGq0RS0ioMzGPaYIJgIk6kVtjF2RqFYZ7C9wRhPBRpy/pvQx9KcyOkKyduKyQ7/O6ADlh PQrNwHzW9OyO+iRSIVuRfPZPrqLq42qDLTFu8ELL63NHV/zk8gdbOyPL4ibLgeavOnkEC/ 7xO1FYfD0S/gsceBPfPSZjsC46oE6yqQoBn6CBuCqli52Ny48u0pgYILu32sfg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Yuan Fu Subject: Re: bug#59490: 29.0.50; Add C# support In-Reply-To: References: Message-ID: <0D2B024A-7486-46A4-999C-453494A251D6@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59490 Cc: Eli Zaretskii , 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 23 November 2022 22:19:21 CET, Yuan Fu wrote: > > >> On Nov 23, 2022, at 12:43 PM, Theodor Thornhill w= rote: >>=20 >>=20 >>=20 >> On 23 November 2022 21:38:19 CET, Yuan Fu wrote: >>>=20 >>> Yuan Fu writes: >>>=20 >>>> Eli Zaretskii writes: >>>>=20 >>>>>> Date: Tue, 22 Nov 2022 22:47:12 +0100 >>>>>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>>>>> the Swiss army knife of text editors" >>>>>>=20 >>>>>> Ok so this works=2E >>>>>>=20 >>>>>> Sorry for the mess=2E >>>>>>=20 >>>>>> What do you think? >>>>>=20 >>>>> LGTM, thanks=2E I'll let Yuan review and install=2E >>>>=20 >>>> Thanks Theo! I=E2=80=99ve merged it=2E One general comment is that we= should have >>>> a "standard" list of features consistent across major modes=2E I thin= k by >>>> now we=E2=80=99ve worked on font-lock enough to know what those featu= res should >>>> be=2E I=E2=80=99ll start a discussion on the ML=2E >>>=20 >>> Actually, another thing: it seems the mode defined is still named >>> csharp-mode rather than csharp-cc-mode=2E >>>=20 >>> Yuan >>=20 >> Yeah that's right=2E Imo that's ok, because it's unlikely there will be= much new development on the cc mode variant=2E So it will be identical to = the upstream one, and the upstream one will be marked as deprecated very so= on=2E >>=20 >> What do you think? > >Yeah I was just confused because you said > >> I made two new modes, 'csharp-cc-mode' and 'csharp-ts-mode'=2E The cc-m= ode >> variant has that name as to not conflict with the ELPA package=2E Yep, that was unclear=2E I decided to skip it in the second patch :) > >And I only see csharp-mode=2E > >So the mode we provide in Emacs are csharp-mode and csharp-ts-mode? Then = I assume this line is a typo? > >;;;###autoload >(add-to-list 'auto-mode-alist '("\\=2Ecs\\'" =2E csharp-cc-mode)) > >Yuan > That's correct=2E That's a typo=2E My bad :) make it csharp-mode=2E You wa= nt a new patch? From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 18:04:03 2022 Received: (at 59490) by debbugs.gnu.org; 23 Nov 2022 23:04:03 +0000 Received: from localhost ([127.0.0.1]:56546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxymh-000517-1g for submit@debbugs.gnu.org; Wed, 23 Nov 2022 18:04:03 -0500 Received: from mail-pg1-f176.google.com ([209.85.215.176]:39453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxyme-00050d-S9 for 59490@debbugs.gnu.org; Wed, 23 Nov 2022 18:04:01 -0500 Received: by mail-pg1-f176.google.com with SMTP id 6so96775pgm.6 for <59490@debbugs.gnu.org>; Wed, 23 Nov 2022 15:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0GLNd0jDdvRXFf2YmXr6MFaTl9WjTLex+V5QvJzAL+I=; b=iBbkSmCDArN18j85jfeFD9v4/3JRzFRnG+XAv/o0YVrjgH5C3M1pF5s1j2JTrcAqNk GU1l4d+Gbvuer8McoFfJ1efWAzwyPkDD7Rt1cHJR0eULo4Q9VFBXLQ26UyEQi38OSc73 smYLtzXdug+UaQzwxEW4ZP+/ok7Ylu1D0P8TY4HisfgA5xPWnJvC+9tzWEJfhLiE39ZM hGfzF24J/j/kaqfHuUpu5eLrEH1qEsd5tZIvZZiTIkLc2/32rTR1+FLHyoSuI5POJii4 s7TtfLd8LJf1+Qi3Kv6aUOP43MnIYb3p74CmEHfWRLaCBuqVEQ9ZdHAVfbdvMl4iRyw0 jQAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0GLNd0jDdvRXFf2YmXr6MFaTl9WjTLex+V5QvJzAL+I=; b=DJa+D1IERPsaZ40DgoOeQcdHYbdG3Ym4IWEePx2pHbzaN9EQh3A7+6K2tMmUPnHCKo Gy/G48FOnZJ93sP/pWWrnYtYeFkc6pvBuDHIdecKTHpeBSxPU/k3fBbbXJQAl37shdXe neziIBQk35FsqmXViw7o39EPOJb5b2mMGAWiMhsLV/TQfwz1uBd5+VBQwAj+zv97QESI hdeXVWbUtcnLZLj6n3BbwPgzVLX2p4R2HJ0B2sEWgsxAS/N0u9CSm73SsUBJkKOzquG8 9dP6NMYbTvfOz/2Td8TEmrL9zS5miyM2ZEvblQ8f021NMA3T2FA0Vw7PXQHbhrSJLrVp MROA== X-Gm-Message-State: ANoB5pkMacFVojA0JYaPToWpdzmDHXNZidOr6RcqvzOD/tyGgTCW3nGT UQdSlxBsp09lAWaIpvbQasTwXmUH05/cIg== X-Google-Smtp-Source: AA0mqf7UYT+f0ynVhFAD7QVsuDQrssl7REKauNy6TRxfik/JPpnS8W9nkWf+7LoTnTP/NhmcrWV6ag== X-Received: by 2002:a63:4b0f:0:b0:464:203c:b964 with SMTP id y15-20020a634b0f000000b00464203cb964mr10138664pga.270.1669244634939; Wed, 23 Nov 2022 15:03:54 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id q2-20020aa79822000000b005743cdde1b8sm2292427pfl.127.2022.11.23.15.03.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2022 15:03:54 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59490: 29.0.50; Add C# support From: Yuan Fu In-Reply-To: <0D2B024A-7486-46A4-999C-453494A251D6@thornhill.no> Date: Wed, 23 Nov 2022 15:03:53 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <7DF363CA-3DE7-4477-B9C5-01558FDAC814@gmail.com> References: <0D2B024A-7486-46A4-999C-453494A251D6@thornhill.no> To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59490 Cc: Eli Zaretskii , 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Nov 23, 2022, at 1:25 PM, Theodor Thornhill = wrote: >=20 >=20 >=20 > On 23 November 2022 22:19:21 CET, Yuan Fu wrote: >>=20 >>=20 >>> On Nov 23, 2022, at 12:43 PM, Theodor Thornhill = wrote: >>>=20 >>>=20 >>>=20 >>> On 23 November 2022 21:38:19 CET, Yuan Fu wrote: >>>>=20 >>>> Yuan Fu writes: >>>>=20 >>>>> Eli Zaretskii writes: >>>>>=20 >>>>>>> Date: Tue, 22 Nov 2022 22:47:12 +0100 >>>>>>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>>>>>> the Swiss army knife of text editors" >>>>>>>=20 >>>>>>> Ok so this works. >>>>>>>=20 >>>>>>> Sorry for the mess. >>>>>>>=20 >>>>>>> What do you think? >>>>>>=20 >>>>>> LGTM, thanks. I'll let Yuan review and install. >>>>>=20 >>>>> Thanks Theo! I=E2=80=99ve merged it. One general comment is that = we should have >>>>> a "standard" list of features consistent across major modes. I = think by >>>>> now we=E2=80=99ve worked on font-lock enough to know what those = features should >>>>> be. I=E2=80=99ll start a discussion on the ML. >>>>=20 >>>> Actually, another thing: it seems the mode defined is still named >>>> csharp-mode rather than csharp-cc-mode. >>>>=20 >>>> Yuan >>>=20 >>> Yeah that's right. Imo that's ok, because it's unlikely there will = be much new development on the cc mode variant. So it will be identical = to the upstream one, and the upstream one will be marked as deprecated = very soon. >>>=20 >>> What do you think? >>=20 >> Yeah I was just confused because you said >>=20 >>> I made two new modes, 'csharp-cc-mode' and 'csharp-ts-mode'. The = cc-mode >>> variant has that name as to not conflict with the ELPA package. >=20 > Yep, that was unclear. I decided to skip it in the second patch :) >=20 >>=20 >> And I only see csharp-mode. >>=20 >> So the mode we provide in Emacs are csharp-mode and csharp-ts-mode? = Then I assume this line is a typo? >>=20 >> ;;;###autoload >> (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-cc-mode)) >>=20 >> Yuan >>=20 >=20 > That's correct. That's a typo. My bad :) make it csharp-mode. You want = a new patch? I applied the patch with that change :-) Yuan From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 24 01:25:39 2022 Received: (at 59490) by debbugs.gnu.org; 24 Nov 2022 06:25:39 +0000 Received: from localhost ([127.0.0.1]:56953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oy5g3-0001n3-Em for submit@debbugs.gnu.org; Thu, 24 Nov 2022 01:25:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oy5g1-0001mr-Qi for 59490@debbugs.gnu.org; Thu, 24 Nov 2022 01:25:38 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oy5fw-0004W3-Ff; Thu, 24 Nov 2022 01:25:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1pNEUR0PS+qX5K89sg5tBREcIhDv09GN9vH1Cbo5FFY=; b=OJ/RvR1CDQqy wYLYYsEZN8hQxMfzxr2xcjKBXxQqirictyFkf6B8POVK3JbVMP7un/w0wPldMDd6uqfMuMzHCBj2+ 7TQwO2Csy5C08zwJ7M1b7JFNjvzjEvrm/vR7z6Zy8PVTfu6YkbxySfOqkvTAYffIGM1Ohir4Fkf57 PDJ0I8dWktRgzJKaS0F3Z1v1W7LCynTcURBBOZPkD4/KaEgC6P47O5QUEplrf+zteZAs3GX4GNkZy 0d31cdWiUY/YxcTbLFVq9IVY9E0MZQqKEVq/EvZayy10NMADHyLGS0AET/zrYd/Gwvoi6UwZ3EFfI /lRyUzyvOcuNcqa0K8a7bg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oy5fv-0002vn-Vx; Thu, 24 Nov 2022 01:25:32 -0500 Date: Thu, 24 Nov 2022 08:25:51 +0200 Message-Id: <83leo0yikw.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: (message from Yuan Fu on Wed, 23 Nov 2022 12:38:19 -0800) Subject: Re: bug#59490: 29.0.50; Add C# support References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59490 Cc: theo@thornhill.no, 59490@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Yuan Fu > Date: Wed, 23 Nov 2022 12:38:19 -0800 > Cc: theo@thornhill.no, > 59490@debbugs.gnu.org > > Actually, another thing: it seems the mode defined is still named > csharp-mode rather than csharp-cc-mode. I think it is better in general to keep the name of the existing mode for which this one is supposed to be a replacement/continuation. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 24 13:27:04 2022 Received: (at control) by debbugs.gnu.org; 24 Nov 2022 18:27:04 +0000 Received: from localhost ([127.0.0.1]:60030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyGwB-0006pg-T5 for submit@debbugs.gnu.org; Thu, 24 Nov 2022 13:27:04 -0500 Received: from mail-oi1-f181.google.com ([209.85.167.181]:36531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyGwA-0006oC-Kp for control@debbugs.gnu.org; Thu, 24 Nov 2022 13:27:02 -0500 Received: by mail-oi1-f181.google.com with SMTP id s206so2309308oie.3 for ; Thu, 24 Nov 2022 10:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=bJYbDkAGcXAnDZ9ExMDt8JNzkWXNYWFMYIIm28OUKho=; b=iAKhUsyUiO5W6HGIa1y70rJqJof1+FvfE/+fFBnahmrjxCMvVchqgMuVossfOiwnS5 sfSOqeSizQnaq/Hsf+3QFmKbTyviyCN7vtOpFtCt7yJEvkUos763GLJ6Pf2P4djF5ulv xEO5r8iMfDOdgBygEJNfaRQ4Sc7UidVd42Nud+53Mf97KU2fV7DWC988t0tIwgdBgkjR Mkt8P5sOZ6l6igyxTDWs9j6dP7UnULHGJ+gucGJ9EPro1/7MwZ31ZPON+YbaNQzp1Itg zOHONMBixBBeUcMsJYpbArkicFQo4Zd0W+CrYolpaRvImsztkQXXrQ+3zlkSsjNkHplJ nFtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bJYbDkAGcXAnDZ9ExMDt8JNzkWXNYWFMYIIm28OUKho=; b=DFtXdYTDi/Zxa494YvAGbzig7UNrN85nvZem7xdj44ft08BwseqpMFOE7HCbIDoYHH Tt22OR/p31l7dh8aGeGoOKZ17uZ/coSiDbP0JBoEXk3IM6DlOOtzcsZagT2+6Fu6V6X+ YjpgcjVGxgqfLM5VlgUhSckPZ7o/QVuuIOzxJIisdxLaZhi9vfLXi0MMk9cA6kpyHpZa h30rM0Xa2nQ3ZIBWeU0mZIhB6iQP/zZP5Z0/ZG60a3TKZWjYQfTrtXqtSbOphAVf5jnF 0pE7LZ02I/eaMJxODK+RfSEMRrl7v1VeNuCBMVwdpGWTgpxnusv8ZJWyzl8wCvTZBUKw 6nig== X-Gm-Message-State: ANoB5pnBmj9f3MSH4Uqp6KsAbN+cD1laUb16ia0sfKM89oDNGGBWlian PFPhtJumxzUOvTpI6BX4QEyqo4FPuz2hSfKWiqcuENe2 X-Google-Smtp-Source: AA0mqf5ZJXs9z46vdN4fxoLEe7NBFmtj8lhNWjS0E25vHZnrKb9qq7JZKWEB/QEhoIEtX4LUeLGCuyClR0NEB5G5x7g= X-Received: by 2002:a05:6808:2229:b0:35b:2b17:af81 with SMTP id bd41-20020a056808222900b0035b2b17af81mr7452325oib.199.1669314417193; Thu, 24 Nov 2022 10:26:57 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 24 Nov 2022 10:26:56 -0800 From: Stefan Kangas X-Hashcash: 1:20:221124:control@debbugs.gnu.org::9Lv78hFPT9T8fBdp:3wB8 MIME-Version: 1.0 Date: Thu, 24 Nov 2022 10:26:56 -0800 Message-ID: Subject: control message for bug #59490 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 59490 + patch quit From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 17:38:59 2022 Received: (at control) by debbugs.gnu.org; 28 Nov 2022 22:38:59 +0000 Received: from localhost ([127.0.0.1]:51368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozmmB-0005dx-Bj for submit@debbugs.gnu.org; Mon, 28 Nov 2022 17:38:59 -0500 Received: from mail-pf1-f180.google.com ([209.85.210.180]:38753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozmm9-0005do-BS for control@debbugs.gnu.org; Mon, 28 Nov 2022 17:38:57 -0500 Received: by mail-pf1-f180.google.com with SMTP id w129so11933161pfb.5 for ; Mon, 28 Nov 2022 14:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=uW2B9/ur6KYh7/l2KLZNBg5wBNtEWEQGnvskKzdvd1s=; b=ieWW/qU+uoYopz9M1t4B2L8ScnCg6KyqPxHlY6w4zSATEbtnfar/yPzBfD3ig4HM7g sMDM3Rs/4+jlk4edpCh9PUKM1xtAxSRa9Fln1i3YQEn7K4xjsYvhEiuLw7PJG/+CmyG/ zM9L4BTVm2CGQmjZpLF4kNIVi9m9Z6pAe37cLTDK6dzTFbepFfBvqHrDUPK5Sv00hz7F ba0VjlPkamsYZfOgAygspoa+54rCa4ChsL+3KcSnPnKjwMd2Cow8LxFksURoM09BxnSf QjzPwe1CgHuqBXk5Mg10jlUYfhs5qZwHsMxjkzu3fy6k1aXED2BQJAyq0VAyx2Rw/2eO 9COQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uW2B9/ur6KYh7/l2KLZNBg5wBNtEWEQGnvskKzdvd1s=; b=JDIcRTqHvAT+0pSWsH+Ws0ZF+BV6p1Ly5MDRVlyPftteZ9S18RmWK2ka++e9paV4zl u9Ef9q3nCYflRhmq7Abs7w9rYV+zcIu2kKtS9Y/63rKCcUi9kBG/0mERJHBaPV1pz1t4 c0X5D8IBfZNOVuuIyqVCDmuZpH4fjaxi8VLNWgQctCJDMfKh2ff7qqnXGCxJ5PYROmvR RQxbRdohK6NfB6D8KQlA9FFNjhD6Dve0D1UAtxRekS+GmX7V3hPlNiQ5Qu9xQjjKmBoz 14Z0kyu2cPdgMU2Sq/lEIK2RjgvwZI0PVMJgggljfTFfSegkwp4SsFD0zI4FlL3NTiew unUA== X-Gm-Message-State: ANoB5pmxINlrr5RO5ZyfgqB8NW/mM3TaFRNLddIT8yPa7GfxIFqxQ0s/ rOs798PZqgkwOa67TxgNy7xB210DU0U= X-Google-Smtp-Source: AA0mqf6ionVfeLjGHXbl0AklORjxJLGPWTHv9oKkzm3FylTES4RRpcD3nn7F0Hp0vzVcQq4OdmG5RA== X-Received: by 2002:a05:6a00:4104:b0:56c:e37d:ec12 with SMTP id bu4-20020a056a00410400b0056ce37dec12mr34037168pfb.80.1669675131443; Mon, 28 Nov 2022 14:38:51 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id d1-20020a170903230100b0017a0668befasm9384436plh.124.2022.11.28.14.38.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2022 14:38:51 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: control message for bug #59490 Message-Id: <0DFB1974-297D-4983-8746-CC24B8D6003E@gmail.com> Date: Mon, 28 Nov 2022 14:38:50 -0800 To: control@debbugs.gnu.org X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 59490 29.1 quit From unknown Tue Jun 24 15:44:07 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 27 Dec 2022 12:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator