GNU bug report logs - #71380
30.0.50; Submitting php-ts-mode, new major mode for php

Previous Next

Package: emacs;

Reported by: Vincenzo Pupillo <v.pupillo <at> gmail.com>

Date: Wed, 5 Jun 2024 14:11:01 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Vincenzo Pupillo <v.pupillo <at> gmail.com>
Cc: 71380 <at> debbugs.gnu.org
Subject: bug#71380: 30.0.50; Submitting php-ts-mode, new major mode for php
Date: Fri, 07 Jun 2024 08:53:04 -0400
>>     (dolist (buffer (buffer-list))
>>       (with-current-buffer buffer
>>         (when (derived-mode-p 'php-ts-mode)
>>           (php-ts-mode-set-style val))))
>> 
>> ?
> Yes is better. The code above is a copy of c-ts-mode--indent-style-setter. 
> It seemed too complicated to me too, but since it had been used there 
> I thought there was some reason.

Aha!  Thanks, I guess we should check the
`c-ts-mode--indent-style-setter` situation, as well, then.

>> > +(defvar php-ts-mode--syntax-table
>> > +  (let ((table (make-syntax-table)))
>> > +    ;; Taken from the cc-langs version
>> 
>> Does this mean it comes from "the cc-mode-based `php-mode.el`" or from
>> `cc-langs.el` (and if so, which part, exactly)?
>> 
>> > +;; taken from c-ts-mode
>> [...]
>> > +;; taken from c-ts-mode
>> 
>> Are these literal copies?
>> Maybe we should consolidate the code with that of `c-ts-mode` to avoid
>> the code duplication?
>> 
> Yes, the first part is a literal copy of c-ts-mode--syntax-table.
> java-ts-mode does exactly the same thing, so I thought it best
> to avoid depending on c-ts-mode--syntax-table.

Hmm... that makes the comment hard to understand.

>> > +  (cond
>> > +   ((equal comment-start "/*") (setq-local comment-end "*/"))
>> > +   ((equal comment-start "//") (setq-local comment-end ""))
>> > +   ((equal comment-start "#") (setq-local comment-end ""))
>> > +   ((equal comment-start "/**") (setq-local comment-end "*/")))
>> > +  (setq mode-name (concat "PHP" (string-trim-right comment-start)))
>> > +  (force-mode-line-update))
>> Is `comment-start` important enough to merit being part of the mode name?
> Sorry. I didn't understand.  Could you please clarify?

You have:

    (setq mode-name (concat "PHP" (string-trim-right comment-start)))

which means the mode-line will display `comment-start` (along with the
usual other things).  Is it really a good idea, given how the mode-line
is already often "too full"?  Which other major mode does that?
What's special about `comment-start` to make it deserve this honor?


        Stefan





This bug report was last modified 1 year and 39 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.