diff options
| author | Yuan Fu | 2023-01-08 09:40:49 -0800 |
|---|---|---|
| committer | Yuan Fu | 2023-01-08 09:43:42 -0800 |
| commit | d46f7f4edcce14e6cbd8e2d7091dbabbe08defc1 (patch) | |
| tree | 38246d70d8b69d3a2613a8edb3219ddcb0288ab3 | |
| parent | 1469aac20d8ebcd3c5cca898b814c305278d4c27 (diff) | |
| download | emacs-d46f7f4edcce14e6cbd8e2d7091dbabbe08defc1.tar.gz emacs-d46f7f4edcce14e6cbd8e2d7091dbabbe08defc1.zip | |
Revert "Add c-or-c++-ts-mode (bug#59613)"
This reverts commit 1df2826639c912396fac0af108301533dac71406.
I forgot about the feature freeze, sorry :-)
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 44 |
2 files changed, 0 insertions, 49 deletions
| @@ -3211,11 +3211,6 @@ An optional major mode based on the tree-sitter library for editing | |||
| 3211 | programs in the C++ language. | 3211 | programs in the C++ language. |
| 3212 | 3212 | ||
| 3213 | +++ | 3213 | +++ |
| 3214 | *** New command 'c-or-c++-ts-mode'. | ||
| 3215 | A command that automatically guesses the language of a header file, | ||
| 3216 | and enables either 'c-ts-mode' or 'c++-ts-mode' accordingly. | ||
| 3217 | |||
| 3218 | +++ | ||
| 3219 | *** New major mode 'java-ts-mode'. | 3214 | *** New major mode 'java-ts-mode'. |
| 3220 | An optional major mode based on the tree-sitter library for editing | 3215 | An optional major mode based on the tree-sitter library for editing |
| 3221 | programs in the Java language. | 3216 | programs in the Java language. |
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 66f179f2f7f..e1b45b06e1a 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -858,50 +858,6 @@ This mode is independent from the classic cc-mode.el based | |||
| 858 | (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'cpp)) | 858 | (setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'cpp)) |
| 859 | (treesit-major-mode-setup))) | 859 | (treesit-major-mode-setup))) |
| 860 | 860 | ||
| 861 | ;; We could alternatively use parsers, but if this works well, I don't | ||
| 862 | ;; see the need to change. This is copied verbatim from cc-guess.el. | ||
| 863 | (defconst c-ts-mode--c-or-c++-regexp | ||
| 864 | (eval-when-compile | ||
| 865 | (let ((id "[a-zA-Z_][a-zA-Z0-9_]*") (ws "[ \t]+") (ws-maybe "[ \t]*") | ||
| 866 | (headers '("string" "string_view" "iostream" "map" "unordered_map" | ||
| 867 | "set" "unordered_set" "vector" "tuple"))) | ||
| 868 | (concat "^" ws-maybe "\\(?:" | ||
| 869 | "using" ws "\\(?:namespace" ws | ||
| 870 | "\\|" id "::" | ||
| 871 | "\\|" id ws-maybe "=\\)" | ||
| 872 | "\\|" "\\(?:inline" ws "\\)?namespace" | ||
| 873 | "\\(:?" ws "\\(?:" id "::\\)*" id "\\)?" ws-maybe "{" | ||
| 874 | "\\|" "class" ws id | ||
| 875 | "\\(?:" ws "final" "\\)?" ws-maybe "[:{;\n]" | ||
| 876 | "\\|" "struct" ws id "\\(?:" ws "final" ws-maybe "[:{\n]" | ||
| 877 | "\\|" ws-maybe ":\\)" | ||
| 878 | "\\|" "template" ws-maybe "<.*?>" | ||
| 879 | "\\|" "#include" ws-maybe "<" (regexp-opt headers) ">" | ||
| 880 | "\\)"))) | ||
| 881 | "A regexp applied to C header files to check if they are really C++.") | ||
| 882 | |||
| 883 | ;;;###autoload | ||
| 884 | (defun c-or-c++-ts-mode () | ||
| 885 | "Analyze buffer and enable either C or C++ mode. | ||
| 886 | |||
| 887 | Some people and projects use .h extension for C++ header files | ||
| 888 | which is also the one used for C header files. This makes | ||
| 889 | matching on file name insufficient for detecting major mode that | ||
| 890 | should be used. | ||
| 891 | |||
| 892 | This function attempts to use file contents to determine whether | ||
| 893 | the code is C or C++ and based on that chooses whether to enable | ||
| 894 | `c-ts-mode' or `c++-ts-mode'." | ||
| 895 | (interactive) | ||
| 896 | (if (save-excursion | ||
| 897 | (save-restriction | ||
| 898 | (save-match-data ; Why `save-match-data'? | ||
| 899 | (widen) | ||
| 900 | (goto-char (point-min)) | ||
| 901 | (re-search-forward c-ts-mode--c-or-c++-regexp nil t)))) | ||
| 902 | (c++-ts-mode) | ||
| 903 | (c-ts-mode))) | ||
| 904 | |||
| 905 | (provide 'c-ts-mode) | 861 | (provide 'c-ts-mode) |
| 906 | 862 | ||
| 907 | ;;; c-ts-mode.el ends here | 863 | ;;; c-ts-mode.el ends here |