* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. @ 2024-06-25 14:16 Vincenzo Pupillo 2024-06-27 9:47 ` Eli Zaretskii 0 siblings, 1 reply; 8+ messages in thread From: Vincenzo Pupillo @ 2024-06-25 14:16 UTC (permalink / raw To: 71776 [-- Attachment #1: Type: text/plain, Size: 188 bytes --] Hi, The use of font lock faces by jsdoc in js-ts-mode is different from that done in other major-modes such as java-mode or c++-mode. This patch makes them more similar. Thanks. Vincenzo [-- Attachment #2: 0001-Conforming-use-of-font-lock-faces-in-jsdoc.patch --] [-- Type: text/x-patch, Size: 2212 bytes --] From a81051ab74bd8bb29843206beaf481cf8270b4aa Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo <v.pupillo@gmail.com> Date: Tue, 25 Jun 2024 15:54:17 +0200 Subject: [PATCH] Conforming use of font lock faces in jsdoc * lisp/progmodes/js.el (js--treesit-font-lock-settings): Use 'font-lock-doc-face' for 'document' node type, font-lock-constant-face for 'tag_name' and 'font-lock-type' face for 'type'. * lisp/progmodes/js.el (js-ts-mode): Add 'document' to 'treesit-font-lock-feature-list'. --- lisp/progmodes/js.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 529b31669ed..e9962c36a46 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3636,10 +3636,16 @@ js--treesit-font-lock-settings :override t '((escape_sequence) @font-lock-escape-face) + ;; "document" should be first, to avoid overlap. + :language 'jsdoc + :override t + :feature 'document + '((document) @font-lock-doc-face) + :language 'jsdoc :override t :feature 'keyword - '((tag_name) @font-lock-keyword-face) + '((tag_name) @font-lock-constant-face) :language 'jsdoc :override t @@ -3649,17 +3655,12 @@ js--treesit-font-lock-settings :language 'jsdoc :override t :feature 'property - '((type) @font-lock-variable-use-face) + '((type) @font-lock-type-face) :language 'jsdoc :override t :feature 'definition - '((identifier) @font-lock-variable-name-face) - - :language 'jsdoc - :override t - :feature 'comment - '((description) @font-lock-comment-face)) + '((identifier) @font-lock-variable-name-face)) "Tree-sitter font-lock settings.") (defun js--fontify-template-string (node override start end &rest _) @@ -3933,7 +3934,7 @@ js-ts-mode ;; Fontification. (setq-local treesit-font-lock-settings js--treesit-font-lock-settings) (setq-local treesit-font-lock-feature-list - '(( comment definition) + '(( comment document definition) ( keyword string) ( assignment constant escape-sequence jsx number pattern string-interpolation) -- 2.45.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-06-25 14:16 bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc Vincenzo Pupillo @ 2024-06-27 9:47 ` Eli Zaretskii 2024-06-27 10:33 ` Vincenzo Pupillo 2024-06-28 0:50 ` Dmitry Gutov 0 siblings, 2 replies; 8+ messages in thread From: Eli Zaretskii @ 2024-06-27 9:47 UTC (permalink / raw To: Vincenzo Pupillo, Dmitry Gutov; +Cc: 71776 > From: Vincenzo Pupillo <v.pupillo@gmail.com> > Date: Tue, 25 Jun 2024 16:16:21 +0200 > > The use of font lock faces by jsdoc in js-ts-mode is different from that done in > other major-modes such as java-mode or c++-mode. This patch makes them more similar. Thanks. Dmitry, any comments? On which branch should we install this, if you agree with the changes? ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-06-27 9:47 ` Eli Zaretskii @ 2024-06-27 10:33 ` Vincenzo Pupillo 2024-06-27 19:20 ` Vincenzo Pupillo 2024-06-28 0:50 ` Dmitry Gutov 1 sibling, 1 reply; 8+ messages in thread From: Vincenzo Pupillo @ 2024-06-27 10:33 UTC (permalink / raw To: Dmitry Gutov, Eli Zaretskii; +Cc: 71776 In data giovedì 27 giugno 2024 11:47:20 CEST, Eli Zaretskii ha scritto: > > From: Vincenzo Pupillo <v.pupillo@gmail.com> > > Date: Tue, 25 Jun 2024 16:16:21 +0200 > > > > The use of font lock faces by jsdoc in js-ts-mode is different from that > > done in other major-modes such as java-mode or c++-mode. This patch makes > > them more similar. > Thanks. > > Dmitry, any comments? On which branch should we install this, if you > agree with the changes? Please wait. I noticed this morning that there are problems with multiple comment blocks in the same file. Thanks. V. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-06-27 10:33 ` Vincenzo Pupillo @ 2024-06-27 19:20 ` Vincenzo Pupillo 0 siblings, 0 replies; 8+ messages in thread From: Vincenzo Pupillo @ 2024-06-27 19:20 UTC (permalink / raw To: Dmitry Gutov, Eli Zaretskii; +Cc: 71776 [-- Attachment #1: Type: text/plain, Size: 1057 bytes --] In data giovedì 27 giugno 2024 12:33:15 CEST, Vincenzo Pupillo ha scritto: > In data giovedì 27 giugno 2024 11:47:20 CEST, Eli Zaretskii ha scritto: > > > From: Vincenzo Pupillo <v.pupillo@gmail.com> > > > Date: Tue, 25 Jun 2024 16:16:21 +0200 > > > > > > The use of font lock faces by jsdoc in js-ts-mode is different from that > > > done in other major-modes such as java-mode or c++-mode. This patch > > > makes > > > them more similar. > > > > Thanks. > > > > Dmitry, any comments? On which branch should we install this, if you > > agree with the changes? > > Please wait. I noticed this morning that there are problems with multiple > comment blocks in the same file. > > Thanks. > V. Hi, this patch fix the treesit range rule for the jsdoc parser. As you can see from the attached screenshots, with the previous rule the parser throws an error (look at the modeline). With the new one, it doesn't happen anymore, and now the font lock is correct (I applied both patches I sent for this bug). Thanks. Vincenzo [-- Attachment #2: 0001-Fix-treesit-range-rule-for-jsdoc.patch --] [-- Type: text/x-patch, Size: 3341 bytes --] From 0002186ff06659407ec32e76b18b4cf45e6f35f9 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo <v.pupillo@gmail.com> Date: Thu, 27 Jun 2024 16:13:58 +0200 Subject: [PATCH] Fix treesit range rule for jsdoc The parser for jsdoc is local, so it is necessary for the range rule to take this into account. * lisp/progmodes/js.el (js-ts-mode): Add ':local' keyword. * lisp/progmodes/js.el (js-ts-language-at-point): Removed 'js-ts-language-at-point'. --- lisp/progmodes/js.el | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 529b31669ed..31e8f2924ac 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3636,10 +3636,16 @@ js--treesit-font-lock-settings :override t '((escape_sequence) @font-lock-escape-face) + ;; "document" should be first, to avoid overlap. + :language 'jsdoc + :override t + :feature 'document + '((document) @font-lock-doc-face) + :language 'jsdoc :override t :feature 'keyword - '((tag_name) @font-lock-keyword-face) + '((tag_name) @font-lock-constant-face) :language 'jsdoc :override t @@ -3649,17 +3655,12 @@ js--treesit-font-lock-settings :language 'jsdoc :override t :feature 'property - '((type) @font-lock-variable-use-face) + '((type) @font-lock-type-face) :language 'jsdoc :override t :feature 'definition - '((identifier) @font-lock-variable-name-face) - - :language 'jsdoc - :override t - :feature 'comment - '((description) @font-lock-comment-face)) + '((identifier) @font-lock-variable-name-face)) "Tree-sitter font-lock settings.") (defun js--fontify-template-string (node override start end &rest _) @@ -3933,7 +3934,7 @@ js-ts-mode ;; Fontification. (setq-local treesit-font-lock-settings js--treesit-font-lock-settings) (setq-local treesit-font-lock-feature-list - '(( comment definition) + '(( comment document definition) ( keyword string) ( assignment constant escape-sequence jsx number pattern string-interpolation) @@ -3944,10 +3945,9 @@ js-ts-mode (treesit-range-rules :embed 'jsdoc :host 'javascript + :local t `(((comment) @capture (:match ,js--treesit-jsdoc-beginning-regexp @capture)))))) - (setq-local treesit-language-at-point-function #'js-ts-language-at-point) - ;; Imenu (setq-local treesit-simple-imenu-settings `(("Function" "\\`function_declaration\\'" nil nil) @@ -3989,17 +3989,6 @@ js-ts--syntax-propertize (put-text-property ns (1+ ns) 'syntax-table syntax) (put-text-property (1- ne) ne 'syntax-table syntax))))) -(defun js-ts-language-at-point (point) - "Return the language at POINT." - (let ((node (treesit-node-at point 'javascript))) - (if (and (treesit-ready-p 'jsdoc) - (equal (treesit-node-type node) "comment") - (string-match-p - js--treesit-jsdoc-beginning-regexp - (treesit-node-text node))) - 'jsdoc - 'javascript))) - ;;;###autoload (define-derived-mode js-json-mode prog-mode "JSON" :syntax-table js-mode-syntax-table -- 2.45.2 [-- Attachment #3: js-jsdoc-master.png --] [-- Type: image/png, Size: 21650 bytes --] [-- Attachment #4: js_jsdoc_with_patch.png --] [-- Type: image/png, Size: 20734 bytes --] ^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-06-27 9:47 ` Eli Zaretskii 2024-06-27 10:33 ` Vincenzo Pupillo @ 2024-06-28 0:50 ` Dmitry Gutov 2024-07-06 7:54 ` Eli Zaretskii 1 sibling, 1 reply; 8+ messages in thread From: Dmitry Gutov @ 2024-06-28 0:50 UTC (permalink / raw To: Eli Zaretskii, Vincenzo Pupillo; +Cc: Damien Cassou, 71776 Hi! On 27/06/2024 12:47, Eli Zaretskii wrote: >> From: Vincenzo Pupillo<v.pupillo@gmail.com> >> Date: Tue, 25 Jun 2024 16:16:21 +0200 >> >> The use of font lock faces by jsdoc in js-ts-mode is different from that done in >> other major-modes such as java-mode or c++-mode. This patch makes them more similar. > Thanks. > > Dmitry, any comments? On which branch should we install this, if you > agree with the changes? It looks like an improvement (thanks!), and as a change to the feature added just recently, should go to emacs-30 - the second revision of the patch, naturally. Also Cc'ing Damien who did the original work. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-06-28 0:50 ` Dmitry Gutov @ 2024-07-06 7:54 ` Eli Zaretskii 2024-07-06 8:51 ` Damien Cassou 0 siblings, 1 reply; 8+ messages in thread From: Eli Zaretskii @ 2024-07-06 7:54 UTC (permalink / raw To: Dmitry Gutov, damien; +Cc: 71776, v.pupillo Ping! Damien, would you please chime in and comment on the patch? > Date: Fri, 28 Jun 2024 03:50:10 +0300 > Cc: 71776@debbugs.gnu.org, Damien Cassou <damien@cassou.me> > From: Dmitry Gutov <dmitry@gutov.dev> > > Hi! > > On 27/06/2024 12:47, Eli Zaretskii wrote: > >> From: Vincenzo Pupillo<v.pupillo@gmail.com> > >> Date: Tue, 25 Jun 2024 16:16:21 +0200 > >> > >> The use of font lock faces by jsdoc in js-ts-mode is different from that done in > >> other major-modes such as java-mode or c++-mode. This patch makes them more similar. > > Thanks. > > > > Dmitry, any comments? On which branch should we install this, if you > > agree with the changes? > > It looks like an improvement (thanks!), and as a change to the feature > added just recently, should go to emacs-30 - the second revision of the > patch, naturally. > > Also Cc'ing Damien who did the original work. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-07-06 7:54 ` Eli Zaretskii @ 2024-07-06 8:51 ` Damien Cassou 2024-07-06 10:57 ` Eli Zaretskii 0 siblings, 1 reply; 8+ messages in thread From: Damien Cassou @ 2024-07-06 8:51 UTC (permalink / raw To: Eli Zaretskii, Dmitry Gutov; +Cc: 71776, v.pupillo Hi Eli, Eli Zaretskii <eliz@gnu.org> writes: > Ping! Damien, would you please chime in and comment on the patch? I did that privately last week, sorry :-). The patch looks good to me. Thank you everyone for your work. -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc. 2024-07-06 8:51 ` Damien Cassou @ 2024-07-06 10:57 ` Eli Zaretskii 0 siblings, 0 replies; 8+ messages in thread From: Eli Zaretskii @ 2024-07-06 10:57 UTC (permalink / raw To: Damien Cassou; +Cc: dmitry, v.pupillo, 71776-done > From: Damien Cassou <damien@cassou.me> > Cc: v.pupillo@gmail.com, 71776@debbugs.gnu.org > Date: Sat, 06 Jul 2024 10:51:53 +0200 > > Hi Eli, > > Eli Zaretskii <eliz@gnu.org> writes: > > Ping! Damien, would you please chime in and comment on the patch? > > I did that privately last week, sorry :-). The patch looks good to me. > > Thank you everyone for your work. Thanks, installed on the emacs-3w0 release branch, and closing the bug. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-07-06 10:57 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-06-25 14:16 bug#71776: 31.0.50; [PATCH] js-ts-mode: conforming use of font lock faces in jsdoc Vincenzo Pupillo 2024-06-27 9:47 ` Eli Zaretskii 2024-06-27 10:33 ` Vincenzo Pupillo 2024-06-27 19:20 ` Vincenzo Pupillo 2024-06-28 0:50 ` Dmitry Gutov 2024-07-06 7:54 ` Eli Zaretskii 2024-07-06 8:51 ` Damien Cassou 2024-07-06 10:57 ` Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.