From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Cassou Newsgroups: gmane.emacs.bugs Subject: bug#71760: [PATCH] js-ts-mode: Fix filling of jsdoc blocks Date: Wed, 31 Jul 2024 10:25:51 +0200 Message-ID: <87sevqx90w.fsf@cassou.me> References: <875xsoousd.fsf@cassou.me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5316"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu To: 71760@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 31 10:27:14 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 1sZ4fx-00018w-2u for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 31 Jul 2024 10:27:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ4fZ-0004rX-JA; Wed, 31 Jul 2024 04:26:49 -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 1sZ4fX-0004rN-PM for bug-gnu-emacs@gnu.org; Wed, 31 Jul 2024 04:26:47 -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 1sZ4fX-0000Wb-G2 for bug-gnu-emacs@gnu.org; Wed, 31 Jul 2024 04:26:47 -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:Date:References:In-Reply-To:From:To:Subject; bh=SIw/XQ5k+CpLJTBQE7g1c4Xe3AePloLOSExT0iZPLf4=; b=aDp41himgTSRafo8Pfxo7XXhiMkLMUI+Y186m7H8H+EtiFOumDWKfyyPvbJJ3gS+fSLN3K5WV8SEuhD0uk6ORQ4pGrQ0pc9Tb0BCDPZsO6LxdZv7fCAtV2nmBJNiY48N1WrJqYkNPEF+YU1HIWU1ulaIzH3XWDeg7Qmo6bAbko6Xc3wm96zl1RW4RpfI2FILZ3HQ76sRVq5SeKID3tCsGJPTUwZ/PyUzzEw+z/8hbOjQ/LSWtoJ29LCCXSAjDoOM/EY3H1RQVerp0GnPw10iSzLXB49f0vXaTHl8bJPV6OOD+BPJqJzvB9cpO3Usk3leHyywZhK3z4HLTrkEiBukHg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sZ4fl-0000pi-MF for bug-gnu-emacs@gnu.org; Wed, 31 Jul 2024 04:27:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Damien Cassou Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Jul 2024 08:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71760 X-GNU-PR-Package: emacs Original-Received: via spool by 71760-submit@debbugs.gnu.org id=B71760.17224143763147 (code B ref 71760); Wed, 31 Jul 2024 08:27:01 +0000 Original-Received: (at 71760) by debbugs.gnu.org; 31 Jul 2024 08:26:16 +0000 Original-Received: from localhost ([127.0.0.1]:49072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sZ4f1-0000og-KQ for submit@debbugs.gnu.org; Wed, 31 Jul 2024 04:26:16 -0400 Original-Received: from mail.reprendre.net ([193.23.30.35]:36196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sZ4ey-0000oU-1v for 71760@debbugs.gnu.org; Wed, 31 Jul 2024 04:26:14 -0400 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7D3EE2C0B4D; Wed, 31 Jul 2024 10:25:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cassou.me; s=dkim; t=1722414355; h=from:subject:date:message-id:to:cc:mime-version:content-type: in-reply-to:references; bh=SIw/XQ5k+CpLJTBQE7g1c4Xe3AePloLOSExT0iZPLf4=; b=hOwLjk+79fN5SiNp14jXhKm/AZj9BIeHgT9oSvU0oPpUXXOl5SKbbtVHfHnWIfEpVGg+Ym hl3eYg122wUT99Ti3pWJaayb+RxbinTe7TIJpvn48XPa9V3Cctni2UHdRYA97MVH2IfaMi 4NnIbZQhkCF4GPRBjPW6N3AAlGHlxNaUK6CZOUKQ19dA0SZR7j0Wy0TRhdTsSXdYgSpkU2 qw7QiZYY9pcVjeOPeTbnzoN/siwjEUwLG3CBmBNyNihh0gF1upmbgWSdh/Ns1FcEIsTZ+A 8FomREnISMZUV7ScjpV7xGmYGTNuJa1s9n6s2ALL//d89djkGHHYSg9xAfTWAw== In-Reply-To: <875xsoousd.fsf@cassou.me> X-Last-TLS-Session-Version: TLSv1.3 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:289577 Archived-At: Hi, after today's fix on c-ts-mode by Yuan Fu, the only patch still necessary to apply for js-ts-mode to properly fill jsdoc descriptions is 0001-js-ts-mode-Make-jsdoc-s-description-block-a-comment.patch. Damien Cassou writes: > Tags: patch > > Hi, > > the attached patches > > 1. add "description" (the kind of treesit node used for texts by the > jsdoc parser) to `c-ts-common--comment-regexp' in js-ts-mode; > > 2. make `c-ts-common--fill-block-comment' only remove a mask if it has > added it in the first place. > > Best > > -- > Damien Cassou > > "Success is the ability to go from one failure to another without > losing enthusiasm." --Winston Churchill > From e444692026cae97dfaecebf5972507ae95f5e488 Mon Sep 17 00:00:00 2001 > From: Damien Cassou > Date: Sun, 21 Jul 2024 21:32:34 +0200 > Subject: [PATCH 1/2] js-ts-mode: Make jsdoc's "description" block a comment > > * lisp/progmodes/js.el (js-ts-mode): Add "description" to > `c-ts-common--comment-regexp'. > --- > lisp/progmodes/js.el | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > index f8140c14a49..75c8111035c 100644 > --- a/lisp/progmodes/js.el > +++ b/lisp/progmodes/js.el > @@ -3946,7 +3946,9 @@ js-ts-mode > :embed 'jsdoc > :host 'javascript > :local t > - `(((comment) @capture (:match ,js--treesit-jsdoc-beginning-regexp @capture)))))) > + `(((comment) @capture (:match ,js--treesit-jsdoc-beginning-regexp @capture))))) > + > + (setq c-ts-common--comment-regexp (rx (or "comment" "line_comment" "block_comment" "description")))) > > ;; Imenu > (setq-local treesit-simple-imenu-settings > -- > 2.45.2 > > From cf14e3b25245dac98adcf90723e4a0c601f65528 Mon Sep 17 00:00:00 2001 > From: Damien Cassou > Date: Sun, 21 Jul 2024 21:33:59 +0200 > Subject: [PATCH 2/2] c-ts-common: Don't insert wrong characters during filling > > * lisp/progmodes/c-ts-common.el (c-ts-common--fill-block-comment): If > masking hasn't been done, don't unmask. > --- > lisp/progmodes/c-ts-common.el | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el > index 3882a697c48..14dd29e07e2 100644 > --- a/lisp/progmodes/c-ts-common.el > +++ b/lisp/progmodes/c-ts-common.el > @@ -151,7 +151,9 @@ c-ts-common--fill-block-comment > (orig-point (point-marker)) > (start-marker (point-marker)) > (end-marker nil) > - (end-len 0)) > + (end-len 0) > + (start-mask-done nil) > + (end-mask-done nil)) > (move-marker start-marker start) > ;; We mask "/*" and the space before "*/" like > ;; `c-fill-paragraph' does. > @@ -162,6 +164,7 @@ c-ts-common--fill-block-comment > (group "/") "*")) > (goto-char (match-beginning 1)) > (move-marker start-marker (point)) > + (setq start-mask-done t) > (replace-match " " nil nil nil 1)) > > ;; Include whitespaces before /*. > @@ -179,6 +182,7 @@ c-ts-common--fill-block-comment > (goto-char (match-beginning 1)) > (setq end-marker (point-marker)) > (setq end-len (- (match-end 1) (match-beginning 1))) > + (setq end-mask-done t) > (replace-match (make-string end-len ?x) > nil nil nil 1)) > > @@ -206,11 +210,11 @@ c-ts-common--fill-block-comment > (fill-region (max start-marker para-start) (min end para-end) arg)) > > ;; Unmask. > - (when start-marker > + (when (and start-mask-done start-marker) > (goto-char start-marker) > (delete-char 1) > (insert "/")) > - (when end-marker > + (when (and end-mask-done start-marker) > (goto-char end-marker) > (delete-region (point) (+ end-len (point))) > (insert (make-string end-len ?\s))) > -- > 2.45.2 > -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill