[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/csharp-mode 6988939 448/459: Tweak mode to not require
From: |
ELPA Syncer |
Subject: |
[elpa] externals/csharp-mode 6988939 448/459: Tweak mode to not require tree-sitter packages |
Date: |
Sun, 22 Aug 2021 14:00:19 -0400 (EDT) |
branch: externals/csharp-mode
commit 6988939c724d8109c51e78e5106fd0cd83de6fbe
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Theodor Thornhill <theo@thornhill.no>
Tweak mode to not require tree-sitter packages
---
.gitignore | 4 ++++
csharp-mode.el | 30 ++++++++++--------------------
csharp-tree-sitter.el | 22 +++++++++++++++++-----
3 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/.gitignore b/.gitignore
index f3d8a8a..55c2d12 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,10 @@ tramp
/eshell/history
/eshell/lastdir
+# GNU ELPA generated files
+/csharp-mode-autoloads.el
+/csharp-mode-pkg.el
+
# elpa packages
/elpa/
diff --git a/csharp-mode.el b/csharp-mode.el
index 6329290..f30c16c 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -8,7 +8,7 @@
;; Version : 0.11.0
;; Keywords : c# languages oop mode
;; X-URL : https://github.com/emacs-csharp/csharp-mode
-;; Package-Requires: ((emacs "26.1") (tree-sitter "0.15.1")
(tree-sitter-indent "0.1") (tree-sitter-langs "0.10.0"))
+;; Package-Requires: ((emacs "26.1"))
;; 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
@@ -27,8 +27,6 @@
;;; Code:
-(when (version< emacs-version "25.1")
- (require 'cl))
(require 'cc-mode)
(require 'cc-langs)
@@ -69,11 +67,11 @@
(c-add-language 'csharp-mode 'java-mode))
(c-lang-defconst c-make-mode-syntax-table
- csharp `(lambda ()
- (let ((table (make-syntax-table)))
- (c-populate-syntax-table table)
- (modify-syntax-entry ?@ "_" table)
- table)))
+ csharp (lambda ()
+ (let ((table (make-syntax-table)))
+ (c-populate-syntax-table table)
+ (modify-syntax-entry ?@ "_" table)
+ table)))
(c-lang-defconst c-identifier-syntax-modifications
csharp (append '((?@ . "w"))
@@ -348,8 +346,7 @@ Should be one of the font lock faces, such as
Needs to be set before `csharp-mode' is loaded, because of
compilation and evaluation time conflicts."
- :type 'symbol
- :group 'csharp)
+ :type 'symbol)
(defcustom csharp-font-lock-extra-types
(list csharp--regex-type-name)
@@ -402,7 +399,7 @@ compilation and evaluation time conflicts."
;;; Adding syntax constructs
(advice-add 'c-looking-at-inexpr-block
- :around 'csharp-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)))
@@ -422,7 +419,7 @@ compilation and evaluation time conflicts."
(cons 'inexpr (point))))))
(advice-add 'c-guess-basic-syntax
- :around 'csharp-guess-basic-syntax)
+ :around #'csharp-guess-basic-syntax)
(defun csharp-guess-basic-syntax (orig-fun &rest args)
(cond
@@ -546,12 +543,6 @@ compilation and evaluation time conflicts."
;; Custom variables
;;;###autoload
-(defcustom csharp-mode-hook nil
- "*Hook called by `csharp-mode'."
- :type 'hook
- :group 'csharp)
-
-;;;###autoload
(define-derived-mode csharp-mode prog-mode "C#"
"Major mode for editing Csharp code.
@@ -561,9 +552,8 @@ Key bindings:
(c-initialize-cc-mode t)
(c-init-language-vars csharp-mode)
(c-common-init 'csharp-mode)
- (easy-menu-add csharp-mode-menu)
(setq-local c-doc-comment-style '((csharp-mode . codedoc)))
- (c-run-mode-hooks 'c-mode-common-hook 'csharp-mode-hook))
+ (run-mode-hooks 'c-mode-common-hook))
(provide 'csharp-mode)
diff --git a/csharp-tree-sitter.el b/csharp-tree-sitter.el
index 7fac9c4..3979f09 100644
--- a/csharp-tree-sitter.el
+++ b/csharp-tree-sitter.el
@@ -29,10 +29,22 @@
(require 'cl-extra)
(require 'seq)
-(require 'tree-sitter)
-(require 'tree-sitter-hl)
-(require 'tree-sitter-indent)
-(require 'tree-sitter-langs)
+(when t
+ ;; In order for the package to be usable and installable (and hence
+ ;; compilable) without tree-sitter, wrap the `require's within a dummy `when'
+ ;; so they're only executed when loading this file but not when compiling it.
+ (require 'tree-sitter)
+ (require 'tree-sitter-hl)
+ (require 'tree-sitter-indent)
+ (require 'tree-sitter-langs))
+;; Vars and functions defined by the above packages:
+(defvar tree-sitter-major-mode-language-alist) ;From `tree-sitter-langs'.
+(declare-function tree-sitter-indent-mode "ext:tree-sitter-indent")
+(declare-function tree-sitter-indent-line "ext:tree-sitter-indent")
+(declare-function tree-sitter-hl-mode "ext:tree-sitter-hl")
+(declare-function tsc-node-end-position "ext:tree-sitter")
+(declare-function tsc-node-start-position "ext:tree-sitter")
+(declare-function tree-sitter-node-at-point "ext:tree-sitter")
(require 'csharp-compilation)
@@ -41,7 +53,7 @@
;;; Tree-sitter
-(setq csharp-mode-tree-sitter-patterns
+(defconst csharp-mode-tree-sitter-patterns
[ ;; Various constructs
(comment) @comment
(modifier) @keyword
- [elpa] externals/csharp-mode 57055a7 426/459: Add qualified name to method_declaration, (continued)
- [elpa] externals/csharp-mode 57055a7 426/459: Add qualified name to method_declaration, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 03b8284 428/459: Add type constraints and lambda support, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 6f0bf6b 430/459: Add escape_sequence to strings, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 3f963c2 432/459: Make type_of_expression available in strings, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 61e1305 431/459: Indent constructor initializer, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 0e26b88 433/459: Update readme with :ensure t, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode cb2404f 434/459: Correctly handle implicit types in for_each_statement, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 09b4d57 437/459: Add comment-start-skip, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 254b91b 439/459: Fix parse and sigabort errors on latest tree-sitter, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 76428ef 444/459: Nested type params and using declaration fixes (#233), ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 6988939 448/459: Tweak mode to not require tree-sitter packages,
ELPA Syncer <=
- [elpa] externals/csharp-mode 33e3042 446/459: Change ci setup to purcell/nix-emacs-ci (#236), ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 093f0f2 447/459: Add static as keyword in csharp-tree-sitter, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 96563d1 451/459: Add back in wrongly removed backtick, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 5f127e2 455/459: Add small notice about elpa in readme, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 2595b90 449/459: Revert "Tweak mode to not require tree-sitter packages", ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 166a5fb 340/459: Revert "Handle "nameof" entirely in c-basic-matchers-after.", ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 1e7bf8a 358/459: Update build.yml, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode a685c7f 359/459: Update build.yml, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode e2541a4 362/459: Update README.org, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode c1489db 370/459: First small tree-sitter query, ELPA Syncer, 2021/08/22