From: Philip Kaludercic <philipk@posteo.net>
To: Theodor Thornhill <theo@thornhill.no>
Cc: Eli Zaretskii <eliz@gnu.org>,
emacs-devel@gnu.org, Yuan Fu <casouri@gmail.com>
Subject: Re: Unifying "foo-mode"s and "foo-ts-mode"s
Date: Fri, 30 Dec 2022 15:02:37 +0000 [thread overview]
Message-ID: <87o7rl7x4i.fsf@posteo.net> (raw)
In-Reply-To: <87tu1dowpp.fsf@thornhill.no> (Theodor Thornhill's message of "Fri, 30 Dec 2022 14:19:30 +0100")
Theodor Thornhill <theo@thornhill.no> writes:
> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Theodor Thornhill <theo@thornhill.no> writes:
>>
>>> Philip Kaludercic <philipk@posteo.net> writes:
>>>
>>>> Eli Zaretskii <eliz@gnu.org> writes:
>>>>
>>>>> You can try. I would like to start a full feature freeze in a day or
>>>>> two, so I'm not sure you will have enough time. And it isn't like we
>>>>> didn't try various approaches during the past two months, so frankly I
>>>>> don't think that a better way even exists. But if you come up with
>>>>> some very bright idea, who knows?
>>>>
>>>> I have attached a sketch of my proposal with support for Python.
>>>> Instead of a separate python-ts-mode, we regulate tree-sitter support
>>>> using a user option `treesit-enabled-modes'. It can either be a list
>>>>
>>>
>>> [...]
>>>
>>> IIUC this will make all other config run before the treesit-related
>>> code?
>>
>> If that is the problem, that we can solve that by re-adjusting the order
>> in which the expanded code occurs.
>>
>>> In that case I think this cannot work, because we _don't_ want to
>>> set all the before/after-change functions many modes set, for example.
>>
>> What exactly is the issue here? Can't we overwrite it again if
>> necessary?
>>
>
> For example the CC modes set up lots of functions in the mode init, many
> of which override things like '*-function' variables, that if either not
> overriden explicitly by a treesit alternative or removed before mode
> init will impact performance. There are some modes that will be worse
> in this regard than others, but one of my earlier suggestions was to
> just:
>
> (define-derived-mode foo ........
>
> (cond
> (use-treesit-p
> (init-all-the-treesit-stuff))
> (use-hypothetical-future-thing
> (init-all-the-hypothetical-future-stuff))
> (t
> (init-all-the-other-stuff))))
This also looks good.
> In this case we don't let any code bleed in between the modes, which IMO
> is necessary. At least we should be very careful with _when_ it is ok
> for such settings to bleed in. Things like comment-start/end etc can
> bleed in just fine, but stuff like
>
> ```
> (c-init-language-vars js-mode)
> (setq-local indent-line-function #'js-indent-line)
> (setq-local beginning-of-defun-function #'js-beginning-of-defun)
> (setq-local end-of-defun-function #'js-end-of-defun)
> (setq-local open-paren-in-column-0-is-defun-start nil)
> (setq-local font-lock-defaults
> (list js--font-lock-keywords nil nil nil nil
> '(font-lock-syntactic-face-function
> . js-font-lock-syntactic-face-function)))
> (setq-local syntax-propertize-function #'js-syntax-propertize)
> (add-hook 'syntax-propertize-extend-region-functions
> #'syntax-propertize-multiline 'append 'local)
> (add-hook 'syntax-propertize-extend-region-functions
> #'js--syntax-propertize-extend-region 'append 'local)
> (setq-local prettify-symbols-alist js--prettify-symbols-alist)
>
> (setq-local parse-sexp-ignore-comments t)
> (setq-local which-func-imenu-joiner-function #'js--which-func-joiner)
> ```
>
> Should absolutely not.
>
> Does that make sense? I don't think this is impossible, but my biggest
> argument was that we need to keep things distinct, or at least be very
> explicit on when we share code.
Yes, I do understand this point, yet my impression has been that this
was not always necessary. The relative complexity of cc-mode might
necessitate a separate mode, but I don't see why that should be the rule
instead of an exception?
next prev parent reply other threads:[~2022-12-30 15:02 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 17:08 Need for "-ts-mode" modes Philip Kaludercic
2022-12-29 17:42 ` Eli Zaretskii
2022-12-29 18:26 ` Philip Kaludercic
2022-12-29 19:27 ` Yuan Fu
2022-12-29 19:42 ` Eli Zaretskii
2022-12-30 4:05 ` Richard Stallman
2022-12-30 8:49 ` Eli Zaretskii
2022-12-29 19:57 ` Eli Zaretskii
2022-12-29 20:23 ` Eli Zaretskii
2022-12-30 10:58 ` Unifying "foo-mode"s and "foo-ts-mode"s Philip Kaludercic
2022-12-30 12:50 ` Theodor Thornhill
2022-12-30 13:08 ` Philip Kaludercic
2022-12-30 13:19 ` Theodor Thornhill
2022-12-30 15:02 ` Philip Kaludercic [this message]
2022-12-30 15:24 ` Theodor Thornhill
2022-12-30 15:45 ` Philip Kaludercic
2022-12-30 15:42 ` Eli Zaretskii
2022-12-30 15:57 ` Philip Kaludercic
2022-12-30 16:20 ` Eli Zaretskii
2022-12-30 16:39 ` Philip Kaludercic
2022-12-30 17:05 ` Eli Zaretskii
2022-12-31 0:13 ` Philip Kaludercic
2022-12-31 6:38 ` Eli Zaretskii
2022-12-30 15:02 ` Eli Zaretskii
2022-12-30 15:20 ` Philip Kaludercic
2022-12-30 15:52 ` Eli Zaretskii
2022-12-30 16:09 ` Philip Kaludercic
2022-12-30 16:30 ` Stefan Monnier
2022-12-30 17:03 ` Eli Zaretskii
2023-01-01 3:03 ` Richard Stallman
2023-01-01 7:28 ` Eli Zaretskii
2023-01-03 4:07 ` Richard Stallman
2023-01-03 12:11 ` Eli Zaretskii
2023-01-05 3:34 ` Richard Stallman
2022-12-30 17:10 ` Gregory Heytings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7rl7x4i.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).