Subject: [PATCH] Add context menu for commenting in prog-mode

From: Billy Lei <[email-masked]>
Date: Sun, 1 Jun 2025 13:23:35 +0800

Though context menu is supported in emacs at present, many modes that 
supports it still lacks some functions (like commenting, toggling bookmark).

This patch is a small update, which add context menu for commenting in 
prog-mode.

From 03db40050787b258f49dd4d508e171e5975ef547 Mon Sep 17 00:00:00 2001
From: Billy Lei <[email-masked]>
Date: Sun, 1 Jun 2025 13:07:14 +0800
Subject: [PATCH] * lisp/progmodes/prog-mode.el (prog-context-menu): Add
 context menu for commenting in prog-mode

---
 lisp/progmodes/prog-mode.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 62d22cb78c0..bb4bda71e26 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -49,6 +49,24 @@
   (define-key-after menu [prog-separator] menu-bar-separator
     'middle-separator)
 
+  (define-key-after menu [comment-line]
+    '(menu-item "Comment Line" comment-line
+                :help "Comment current line"
+                :visible (not (use-region-p)))
+    'prog-separator)
+
+  (define-key-after menu [comment-region]
+    '(menu-item "Comment Region" comment-region
+                :help "Comment each line in the region"
+                :visible (use-region-p))
+    'prog-separator)
+
+  (define-key-after menu [comment-box]
+    '(menu-item "Comment Region (Box)" comment-box
+                :help "Comment region and put it inside a box"
+                :visible (use-region-p))
+    'prog-separator)
+
   (unless (xref-forward-history-empty-p)
     (define-key-after menu [xref-forward]
       '(menu-item "Go Forward" xref-go-forward
-- 
2.49.0.windows.1