From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.bugs Subject: bug#72814: 31.0.50; Add a variable controlling doxygen support in C/C++/Java? Date: Mon, 09 Sep 2024 11:50:59 +0200 Message-ID: <2150926.9o76ZdvQCi@fedora> References: <0708616B-CCE4-4AA5-81FA-FF41F2789018@gmail.com> <86seuqi29z.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2712115.vuYhMxLoTh" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19646"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, vincenzo.pupillo@unimi.it To: casouri@gmail.com, 72814@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 09 11:52:29 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1snb4O-0004rZ-CN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Sep 2024 11:52:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snb42-0006Av-SQ; Mon, 09 Sep 2024 05:52:06 -0400 Original-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 1snb41-0006Ag-Iq for bug-gnu-emacs@gnu.org; Mon, 09 Sep 2024 05:52:05 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1snb3u-0006uM-TT for bug-gnu-emacs@gnu.org; Mon, 09 Sep 2024 05:52:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=qDnhSvclYV9RPPKPaohyM7poq31Vb02zKis+26Dc0eA=; b=BtzqhmiB8z0K1qokN2S3ZRBfBIvHe4ZU77MJ0mJb86icTbeZ9dgUPiUMcFCcWwAhSA6YRwemRaLX7nhmuBZeOifmtxU8MWlRIF1hyRtya2K0n0MZnaaF1BivGf3TfR9kDkqZBoi45iDnF+sztoFDHOXXfHEY4AekwsyD0Bsi4du4Oi0aR8WMTWHwP6oq6s32O++VoOzBngiEwERxTq0iB9MlwhwNsRbSxaLwCy4BNMp0eIW9gMZgs4FFITqS8nlksjRhs1XoACViPxRLr7jiakm2qbQAnIeIcqo9ZzT1n3eUXBiwSCk1Lu4Na6K52dqj3eoHhZRQ0+n+Pi9Jt2LKBQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1snb3y-0002Xf-7c for bug-gnu-emacs@gnu.org; Mon, 09 Sep 2024 05:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Sep 2024 09:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72814 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Yuan Fu , bug-gnu-emacs@gnu.org X-Debbugs-Original-Cc: 72814@debbugs.gnu.org, Eli Zaretskii , vincenzo.pupillo@unimi.it Original-Received: via spool by submit@debbugs.gnu.org id=B.17258754749705 (code B ref -1); Mon, 09 Sep 2024 09:52:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Sep 2024 09:51:14 +0000 Original-Received: from localhost ([127.0.0.1]:60658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snb3B-0002WT-9r for submit@debbugs.gnu.org; Mon, 09 Sep 2024 05:51:13 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:33242) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1snb38-0002WH-D5 for submit@debbugs.gnu.org; Mon, 09 Sep 2024 05:51:11 -0400 Original-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 1snb33-00064W-PC for bug-gnu-emacs@gnu.org; Mon, 09 Sep 2024 05:51:06 -0400 Original-Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1snb31-0006rU-MG; Mon, 09 Sep 2024 05:51:05 -0400 Original-Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso6578166b.1; Mon, 09 Sep 2024 02:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725875462; x=1726480262; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qDnhSvclYV9RPPKPaohyM7poq31Vb02zKis+26Dc0eA=; b=Qf1MK62Wtkd7qAAT6q/lL9ODc7C6ovc0wrcnKz6GP4GoKd8OsBQSCmwJB221k6PDVp HRZTIG2TGs8YBj0k/1Mw8ey+3cTU9enD9tpmhLICyuHD4sIPkfBWIewplpJkocsU9p/n g5znl0eGx7ArTu3lCFiH8i8iu0ViBHW6lJ0/Tcbcprdu++gq6N/rW5drcnbO9UogzxW0 nOGZ66Pv+0fes8y+0T2YaIrp5Qh9YeqlgjwgjwdEeE2JDNBPXf3DFHqncbkGNLloh6hC MU/3rk1FwYRuU7x5OK5M/IdVr48E2M4QkrKW+9zdyvOP2P+8Klq/Y0J/Y9XjvAlAWv+c A6LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725875462; x=1726480262; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qDnhSvclYV9RPPKPaohyM7poq31Vb02zKis+26Dc0eA=; b=vcrdYDAJpiwCoqBmP7QlEeXAjPlmJKUJL8JZM/qyMfUjA/ArWPF96mhYxlbmX7Yyx/ SHGYv5yKXgNpURaVQqpFDkRQ1PakwjvtRopAIY9iNMY1vtjjrs5OS4sl8RKy5OwJMZre p6Z7FOQRqHsOf903h2SRzX/1i2VDd1dJQb1rwHtFZi50OwuI0ZRc6boGybXBwL5O6yIo 9VAu8cnQmO2CdrjBJ+fjvrIQp/0aza+JErGeMN7bunPgOIv7HKX/2PRc5I5Nl8te8h3n uSPD/dU76MuTxyb0NtlyR+/4l4iBmW0Myp9BUJgmS23ESgSI7Dpa3KiMkTaEYXbzqlc2 gf6w== X-Forwarded-Encrypted: i=1; AJvYcCVg+/hd8kr9EGhRClMzRqwnfrVfKh4zpb7o56OYl2j1pmfBUBhllh4wRuWY+CLXoDakL6/8CQ==@gnu.org, AJvYcCXH9e4DP6MLv9nO00leUOgNpeLGWRhaSKxKAcoKDuBWdRBSrzrB09fN/MJVwtkp2o2eXOgc0o253X4eipHO@gnu.org X-Gm-Message-State: AOJu0YyJFkb4m5k7TVtsACcCLNjZLafzSKslmJbYVU1AAMoyuqbjRPef wk0Ym9gzRcFp6WvFL1V+t1YhuCZuxQlWXTJBg2XsZGYJAfcoxdN/ X-Google-Smtp-Source: AGHT+IFtQqjOfYRAdHQcs0svn43TvlzowGwZE+KbSWQWTlUmn3lCX95k4w1HbMIkHydcUi0TmVmatA== X-Received: by 2002:a17:907:6d0e:b0:a8d:4e69:4030 with SMTP id a640c23a62f3a-a8d4e69420bmr393837466b.19.1725875461323; Mon, 09 Sep 2024 02:51:01 -0700 (PDT) Original-Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25ce9ed6sm312967666b.165.2024.09.09.02.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 02:51:00 -0700 (PDT) In-Reply-To: <86seuqi29z.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=v.pupillo@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291494 Archived-At: This is a multi-part message in MIME format. --nextPart2712115.vuYhMxLoTh Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In data marted=C3=AC 27 agosto 2024 14:22:16 CEST, Eli Zaretskii ha scritto: > > From: Yuan Fu > > Date: Mon, 26 Aug 2024 20:13:52 -0700 > > Cc: eliz@gnu.org, > >=20 > > vincenzo.pupillo@unimi.it > >=20 > > Yuan Fu writes: > > > X-Debbugs-CC: eliz@gnu.org , > > > vincenzo.pupillo@unimi.it > > >=20 > > > Should we add a custom option that controls whether to enable doxygen > > > support in c-ts-mode/c++-ts-mode/java-ts-mode? > > >=20 > > > Technically this isn=E2=80=99t a problem, since the doxygen support i= s only > > > enabled if there=E2=80=99s doxygen grammar on the system. But many pe= ople > > > (me) might install a grammar bundle that includes dozens of > > > grammars for convenience. Then the doxygen support would turn on when > > > the user doesn=E2=80=99t really intend to use it. > > >=20 > > > I propose we add custom options like c-ts-mode-enable-doxygen and set= it > > > to t by default, so the default behavior is still to enable doxygen > > > support when the grammar for it exists, but people who don=E2=80=99t = want to pay > > > for it can turn it off by setting the option to nil. > > >=20 > > > Yuan > >=20 > > Eli, WDYT? >=20 > I'm okay with such an option, but it should be careful to check > whether the corresponding grammar library is available, and offer a > user-friendly diagnostic if not. Try to take a look at this patch. Is it okay? Vincenzo --nextPart2712115.vuYhMxLoTh Content-Disposition: attachment; filename="0001-Add-a-user-option-to-disable-Doxygen-syntax-highligh.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Add-a-user-option-to-disable-Doxygen-syntax-highligh.patch" >From 0a6d90f25dfddc1da88b5e47a97bc09fe50a6d34 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 9 Sep 2024 09:20:42 +0200 Subject: [PATCH] Add a user option to disable Doxygen syntax highlighting (bug#72814). Both 'c-ts-mode' and 'java-ts-mode' have a new user option, 'c-ts-mode-enable-doxygen' and 'java-ts-mode-enable-doxygen' (defaults to t) which allow to disable syntax highlighting of comment blocks based on the Doxygen grammar. * lisp/progmodes/c-ts-mode.el: Add the 'c-ts-mode-enable-doxygen' user option variable to disable doxygen grammar. (bug#72814) * lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode): Use the new 'c-ts-mode-enable-dodygen' option. * lisp/progmodes/java-ts-mode.el: Add the 'java-ts-mode-enable-doxygen' user option variable to disable doxygen grammar. (bug#72814) * lisp/progmodes/java-ts-mode.el (java-ts-mode): Use the new 'java-ts-mode-enable-dodygen' option. * etc/NEWS: Document the change. --- etc/NEWS | 16 ++++++++ lisp/progmodes/c-ts-mode.el | 71 ++++++++++++++++++++-------------- lisp/progmodes/java-ts-mode.el | 35 +++++++++++------ 3 files changed, 83 insertions(+), 39 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index c6f8b0062e4..5762bc22c54 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -224,6 +224,22 @@ package of the current buffer. It is bound to 'C-c C-t p' in 'go-ts-mode'. The 'go-ts-mode-build-tags' user option is available to set a list of build tags for the test commands. +** C-ts mode + ++++ +*** New user option 'c-ts-mode-enable-doxygen'. +By default, 'c-ts-mode-enable-doxygen' is t, and doxygen comment blocks +are syntax-highlighted if the doxygen grammar is available. If Non-nil, +the comment blocks are highlighted like other comments. + +** Java-ts mode + ++++ +*** New user option 'java-ts-mode-enable-doxygen'. +By default, 'java-ts-mode-enable-doxygen' is t, and doxygen comment blocks +are syntax-highlighted if the doxygen grammar is available. If Non-nil, +the comment blocks are highlighted like other comments. + ** Emacs Lisp mode --- diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 7f23b30a88a..3adf5673e67 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -216,6 +216,17 @@ c-ts-mode-emacs-sources-support :safe 'booleanp :group 'c) +(defcustom c-ts-mode-enable-doxygen t + "Enable doxygen syntax highlighting. +If nil, disable doxygen based font lock for comment. +This needs to be set before enabling `c-ts-mode'; if you change +the value after enabling `c-ts-mode', toggle the mode off and on +again." + :version "31.1" + :type 'boolean + :safe 'booleanp + :group 'c) + ;;; Syntax table (defvar c-ts-mode--syntax-table @@ -1354,20 +1365,22 @@ c-ts-mode (treesit-font-lock-recompute-features '(emacs-devel))) ;; Inject doxygen parser for comment. - (when (treesit-ready-p 'doxygen t) - (setq-local treesit-primary-parser primary-parser) - (setq-local treesit-font-lock-settings - (append - treesit-font-lock-settings - c-ts-mode-doxygen-comment-font-lock-settings)) - (setq-local treesit-range-settings - (treesit-range-rules - :embed 'doxygen - :host 'c - :local t - `(((comment) @cap - (:match - ,c-ts-mode--doxygen-comment-regex @cap))))))))) + (when c-ts-mode-enable-doxygen + (if (not (treesit-ready-p 'doxygen t)) + (warn "Doxygen language grammar is unavailable, please install it.") + (setq-local treesit-primary-parser primary-parser) + (setq-local treesit-font-lock-settings + (append + treesit-font-lock-settings + c-ts-mode-doxygen-comment-font-lock-settings)) + (setq-local treesit-range-settings + (treesit-range-rules + :embed 'doxygen + :host 'c + :local t + `(((comment) @cap + (:match + ,c-ts-mode--doxygen-comment-regex @cap)))))))))) (derived-mode-add-parents 'c-ts-mode '(c-mode)) @@ -1415,20 +1428,22 @@ c++-ts-mode #'c-ts-mode--emacs-current-defun-name)) ;; Inject doxygen parser for comment. - (when (treesit-ready-p 'doxygen t) - (setq-local treesit-primary-parser primary-parser) - (setq-local treesit-font-lock-settings - (append - treesit-font-lock-settings - c-ts-mode-doxygen-comment-font-lock-settings)) - (setq-local treesit-range-settings - (treesit-range-rules - :embed 'doxygen - :host 'cpp - :local t - `(((comment) @cap - (:match - ,c-ts-mode--doxygen-comment-regex @cap))))))))) + (when c-ts-mode-enable-doxygen + (if (not (treesit-ready-p 'doxygen t)) + (warn "Doxygen language grammar is unavailable, please install it.") + (setq-local treesit-primary-parser primary-parser) + (setq-local treesit-font-lock-settings + (append + treesit-font-lock-settings + c-ts-mode-doxygen-comment-font-lock-settings)) + (setq-local treesit-range-settings + (treesit-range-rules + :embed 'doxygen + :host 'cpp + :local t + `(((comment) @cap + (:match + ,c-ts-mode--doxygen-comment-regex @cap)))))))))) (derived-mode-add-parents 'c++-ts-mode '(c++-mode)) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index ac104534734..f12c7ec81ef 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -48,6 +48,17 @@ java-ts-mode-indent-offset :safe 'integerp :group 'java) +(defcustom java-ts-mode-enable-doxygen t + "Enable doxygen syntax highlighting. +If nil, disable doxygen based font lock for comment. +This needs to be set before enabling `java-ts-mode'; if you change +the value after enabling `java-ts-mode', toggle the mode off and on +again." + :version "31.1" + :type 'boolean + :safe 'booleanp + :group 'java) + (defvar java-ts-mode--syntax-table (let ((table (make-syntax-table))) ;; Taken from the cc-langs version @@ -401,17 +412,19 @@ java-ts-mode java-ts-mode--font-lock-settings) ;; Inject doxygen parser for comment. - (when (treesit-ready-p 'doxygen t) - (setq-local treesit-primary-parser primary-parser) - (setq-local treesit-font-lock-settings - (append treesit-font-lock-settings - c-ts-mode-doxygen-comment-font-lock-settings)) - (setq-local treesit-range-settings - (treesit-range-rules - :embed 'doxygen - :host 'java - :local t - `(((block_comment) @cap (:match "/\\*\\*" @cap))))))) + (when java-ts-mode-enable-doxygen + (if (not (treesit-ready-p 'doxygen t)) + (warn "Doxygen language grammar is unavailable, please install it.") + (setq-local treesit-primary-parser primary-parser) + (setq-local treesit-font-lock-settings + (append treesit-font-lock-settings + c-ts-mode-doxygen-comment-font-lock-settings)) + (setq-local treesit-range-settings + (treesit-range-rules + :embed 'doxygen + :host 'java + :local t + `(((block_comment) @cap (:match "/\\*\\*" @cap)))))))) (setq-local treesit-font-lock-feature-list java-ts-mode--feature-list) -- 2.46.0 --nextPart2712115.vuYhMxLoTh--