Subject: Re: bug#77017: 31.0.50; Build warning from mhtml-ts-mode

From: Vincenzo Pupillo <[email-masked]>
Date: Sat, 22 Mar 2025 12:45:50 +0100

Sorry Eli, I missed this email.
The attached patch fixes the warnings.

Thanks.
Vincenzo

In data giovedì 20 marzo 2025 14:07:57 Ora standard dell’Europa centrale, Eli 
Zaretskii ha scritto:
> Vincenzo, could you please look into this?
> 
> > Cc: Vincenzo Pupillo <[email-masked]>
> > From: [email-masked]
> > Date: Fri, 14 Mar 2025 12:17:50 -0500
> > 
> > If you don’t have the tree-sitter html grammar installed then you
> > get a warning while building due to the ‘(require 'html-ts-mode)’
> > line.
> > 
> >   cd src/emacs
> >   make
> >   ...
> >   Warning (treesit): Cannot activate tree-sitter, because language
> >   grammar for html is unavailable (not-found):
> >   /home/jm/.emacs.d/tree-sitter/libtree-sitter-html: cannot open
> >   shared object file: No such file or directory
> >   /home/jm/.emacs.d/tree-sitter/libtree-sitter-html.0: cannot open
> >   shared object file: No such file or directory
> >   /home/jm/.emacs.d/tree-sitter/libtree-sitter-html.0.0: cannot
> >   open shared object file: No such file or directory
> >   /home/jm/.emacs.d/tree-sitter/libtree-sitter-html.so: cannot
> >   open shared object file: No such file or directory
> >   /home/jm/.emacs.d/tree-sitter/libtree-sitter-html.so.0: cannot
> >   open shared object file: No such file or directory
> >   /home/jm/.emacs.d/tree-sitter/libtree-sitter-html.so.0.0: cannot
> >   open shared object file: No such file or directory
> >   libtree-sitter-html: cannot open shared object file: No such
> >   file or directory libtree-sitter-html.0: cannot open shared
> >   object file: No such file or directory libtree-sitter-html.0.0:
> >   cannot open shared object file: No such file or directory
> >   libtree-sitter-html.so: cannot open shared object file: No such
> >   file or directory libtree-sitter-html.so.0: cannot open shared
> >   object file: No such file or directory
> >   libtree-sitter-html.so.0.0: cannot open shared object file: No
> >   such file or directory

>From 248805e23779777ddf42febc5984894038ceaa98 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
Date: Sat, 22 Mar 2025 12:30:30 +0100
Subject: [PATCH] Fix compiler warnings in mhtml-ts-mode.el (bug#77017).

* lisp/textmodes/mhtml-ts-mode.el
Added variable and function declarations to prevent compiler warnings.
(mhtml-ts-mode): Require 'html-ts-mode' after checking that the html
parser is available.
---
 lisp/textmodes/mhtml-ts-mode.el | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lisp/textmodes/mhtml-ts-mode.el b/lisp/textmodes/mhtml-ts-mode.el
index 5c4f90cd193..22c0455a4ee 100644
--- a/lisp/textmodes/mhtml-ts-mode.el
+++ b/lisp/textmodes/mhtml-ts-mode.el
@@ -50,13 +50,23 @@
 ;;; Code:
 
 (require 'treesit)
-(require 'html-ts-mode)
 (require 'css-mode) ;; for embed css into html
 (require 'js) ;; for embed javascript into html
 
 (eval-when-compile
   (require 'rx))
 
+;; Prevent compile warnings.
+(defvar html-ts-mode-indent-offset)
+(defvar html-ts-mode--treesit-font-lock-feature-list)
+(defvar html-ts-mode--font-lock-settings)
+(defvar html-ts-mode--treesit-things-settings)
+(defvar html-ts-mode--treesit-defun-type-regexp)
+(defvar html-ts-mode--indent-rules)
+(defvar html-ts-mode--treesit-simple-imenu-settings)
+(declare-function html-ts-mode--outline-predicate "html-ts-mode.el")
+(declare-function html-ts-mode--defun-name "html-ts-mode.el")
+
 ;; This tells the byte-compiler where the functions are defined.
 ;; Is only needed when a file needs to be able to byte-compile
 ;; in a Emacs not built with tree-sitter library.
@@ -447,12 +457,14 @@ mhtml-ts-mode
   "Major mode for editing HTML with embedded JavaScript and CSS.
 Powered by tree-sitter."
   (if (not (and
-            (treesit-ready-p 'html)
-            (treesit-ready-p 'javascript)
-            (treesit-ready-p 'css)))
+            (treesit-ready-p 'html t)
+            (treesit-ready-p 'javascript t)
+            (treesit-ready-p 'css t)))
       (error "Tree-sitter parsers for HTML isn't available.  You can
     install the parsers with M-x `mhtml-ts-mode-install-parsers'")
 
+    (require 'html-ts-mode)
+
     ;; When an language is embedded, you should initialize some variable
     ;; just like it's done in the original mode.
 
-- 
2.49.0