summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2023-04-11 13:37:25 +0300
committerEli Zaretskii <eliz@gnu.org>2023-04-11 13:37:25 +0300
commit05971c4d9a49d377a17d6ffa4c9fa9616ac12769 (patch)
tree4a225522f5155547594986e51c9080a66c42c494
parent954e2d96a92824ce3c21341913d7a37da6a88d1c (diff)
downloademacs-05971c4d9a49d377a17d6ffa4c9fa9616ac12769.tar.gz
Add menu to 'c-ts-mode' and 'c++-ts-mode'
* lisp/progmodes/c-ts-mode.el (c-ts-mode-menu): New menu.
-rw-r--r--lisp/progmodes/c-ts-mode.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 83e89c3a335..2d54577cb09 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -1033,6 +1033,39 @@ recommended to enable `electric-pair-mode' with this mode."
(setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'cpp))
(treesit-major-mode-setup)))
+(easy-menu-define c-ts-mode-menu (list c-ts-mode-map c++-ts-mode-map)
+ "Menu for `c-ts-mode' and `c++-ts-mode'."
+ '("C/C++"
+ ["Comment Out Region" comment-region
+ :enable mark-active
+ :help "Comment out the region between the mark and point"]
+ ["Uncomment Region" (comment-region (region-beginning)
+ (region-end) '(4))
+ :enable mark-active
+ :help "Uncomment the region between the mark and point"]
+ ["Indent Top-level Expression" c-ts-mode-indent-defun
+ :help "Indent/reindent top-level function, class, etc."]
+ ["Indent Line or Region" indent-for-tab-command
+ :help "Indent current line or region, or insert a tab"]
+ ["Forward Expression" forward-sexp
+ :help "Move forward across one balanced expression"]
+ ["Backward Expression" backward-sexp
+ :help "Move back across one balanced expression"]
+ "--"
+ ("Style..."
+ ["Set Indentation Style..." c-ts-mode-set-style
+ :help "Set C/C++ indentation style for current buffer"]
+ ["Show Current Indentation Style" (message "Indentation Style: %s"
+ c-ts-mode-indent-style)
+ :help "Show the name of the C/C++ indentation style for current buffer"]
+ ["Set Comment Style" c-ts-mode-toggle-comment-style
+ :help "Toglle C/C++ comment style between block and line comments"])
+ "--"
+ ("Toggle..."
+ ["SubWord Mode" subword-mode
+ :style toggle :selected subword-mode
+ :help "Toggle sub-word movement and editing mode"])))
+
;; We could alternatively use parsers, but if this works well, I don't
;; see the need to change. This is copied verbatim from cc-guess.el.
(defconst c-ts-mode--c-or-c++-regexp