From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#41897: 28.0.50; JavaScript comment filling with mhtml-mode Date: Wed, 24 Jun 2020 21:28:09 +0300 Message-ID: References: <20200620171827.7855.qmail@mail.muc.de> <87d05ta8z9.fsf@simenheg@gmail.com> <20200622191750.GA11506@ACM> <20200623083613.GA6957@ACM> <20200623162837.GB6957@ACM> <10235ec5-17c3-c281-b5ed-2c65a07bd02f@yandex.ru> <20200623191713.GC6957@ACM> <4c6a9c40-a72c-1413-4e08-c7097f8bc407@yandex.ru> <20200624174333.GA8870@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="10171"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 Cc: Simen =?UTF-8?Q?Heggest=C3=B8yl?= , 41897@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 24 20:29:11 2020 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 1joA91-0002WZ-2D for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Jun 2020 20:29:11 +0200 Original-Received: from localhost ([::1]:53864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joA90-0004Z4-4O for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Jun 2020 14:29:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joA8s-0004Yr-Nb for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2020 14:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55669) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1joA8s-0000a2-Dw for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2020 14:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1joA8s-0001rU-Ag for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2020 14:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jun 2020 18:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41897 X-GNU-PR-Package: emacs Original-Received: via spool by 41897-submit@debbugs.gnu.org id=B41897.15930233027103 (code B ref 41897); Wed, 24 Jun 2020 18:29:02 +0000 Original-Received: (at 41897) by debbugs.gnu.org; 24 Jun 2020 18:28:22 +0000 Original-Received: from localhost ([127.0.0.1]:38982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1joA8D-0001qV-OS for submit@debbugs.gnu.org; Wed, 24 Jun 2020 14:28:22 -0400 Original-Received: from mail-ej1-f46.google.com ([209.85.218.46]:34019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1joA8B-0001qH-22 for 41897@debbugs.gnu.org; Wed, 24 Jun 2020 14:28:20 -0400 Original-Received: by mail-ej1-f46.google.com with SMTP id y10so3457373eje.1 for <41897@debbugs.gnu.org>; Wed, 24 Jun 2020 11:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xk0Kw9W5Oznp0t2Gndqo8WqycR+6EZHuLJZgbbqL6Rw=; b=XpesGh1ljsObCrUqGqT+oSEPxjvKdPxIxC5olVnJ4lbkyYfSfM1Vz5uwi74BmK+jYa WvmqXTe8I7UYNdtG9ZCf/phIOS0d97sGmZerqm5vCQ9IE+W8g+gfLzSgwaun2TjAeO8k wL8R5OIiu/38Enj4JSk8nWMYfnPcqfsGycWxmVSt8Wyr6CXC3kq8XXOsysrrOnxPLNXW mRcXpgsKkoeehh0bJlh8PQ5Xfb4dab+REvdLbcNXotWVUAUZZC6opX+vl2njkveAvycL ZPka/c9P/B0jeL4KDjhLEOy35N672HLrP1c92Vs9NrFPu8CsQc9T2hU+/bTy2MQ+nbbU O+Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xk0Kw9W5Oznp0t2Gndqo8WqycR+6EZHuLJZgbbqL6Rw=; b=GvFP3f/MwaV3xZ2z6e2gnIvJnQv/D7/LA3cnSe2xQuvCBXk73o4Xqt50dG0c9zg6oW fQe/sCWXGkS/h8KXoWBtVuZ0auhAOrnegufs9zdpo+eH0qqwUqOy7sxAQf/gV1ZBvw8I 35CiO9gTjE5b06QmCMqdCKqtT0Q1jjXi9dfd55OzXpG1ZXujuzixmvUYFu7jSr1bm7Ki 6vdUO8Z763OFPBqmw+UCYYuBF//Oko7BB9OOVaU8E6ABOkB8mI2lHCDYll1T4MQzdHzx fBWcqQVFA3ycdR8RNeaxDe9hvqLiPKKNYik2kJoO0fzk7BQFLwAv8F5Ixl08MJ9HJUnK Z+iw== X-Gm-Message-State: AOAM5307X/jZw5UI/BxCPObpxnAg+v+Du9jdIqku4ktByJF+8ErCrB/a D0nDjhY3uVE7Ob/8n6tgprRGoPZm X-Google-Smtp-Source: ABdhPJyAMlYPLxUat1GldUlf6BmUPBKOsWDGCPYNvYPa7LnNbqyU5U2FYj00guZIImzF6gtNK+sRgA== X-Received: by 2002:a17:906:11d9:: with SMTP id o25mr25515650eja.377.1593023292775; Wed, 24 Jun 2020 11:28:12 -0700 (PDT) Original-Received: from [192.168.0.3] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id u19sm9283740edd.62.2020.06.24.11.28.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jun 2020 11:28:12 -0700 (PDT) In-Reply-To: <20200624174333.GA8870@ACM> Content-Language: en-US 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" Xref: news.gmane.io gmane.emacs.bugs:182354 Archived-At: Hi Alan, On 24.06.2020 20:43, Alan Mackenzie wrote: >>> That's what I mean. The cache persists over commands, reducing the >>> amount of recalculation needed, particularly for fast typing. Refilling >>> it from scratch on every keypress would likely make it sluggish. > >> Not on every keypress. Only when js-fill-paragraph is called. One-time >> delay only when required. > > But a substantial delay, involving (I think) analysing the code from BOB > each time. The current working setup has a negligible delay at each > buffer change (and, of course, recalculation of cache entries only when > required). I imagine that would not be a significant problem for the rare cases that fill-paragraph is called in a JS region. Considering most of the contents in mhtml-mode buffers are not JS code, on average, that should tilt the scales in favor of parsing lazily, rather than affecting every character insertion. >>> Anyhow, it works fine at the moment, so why change it? > >> The above scheme would require fewer references to CC Mode functions >> from outside. js-mode support would automatically transfer to mhtml-mode >> and mmm-mode with associated changes in them necessary. > > It sounds like you want to use a facility without initialising it. This > feels a bit unreasonable. That cache reset at the beginning of js-fill-paragraph could as well re-initialize the cache. >> One fewer before-change-functions element is also nothing to sneeze at. > > There's nothing wrong with having functions in > before/after-change-functions. It's a standard Emacs programming > technique. I'm not saying it's a terrible idea, but it has its downsides. >>>> js-mode mostly works, aside from features like this one. > >>> With the current patch, comment filling should work fine in js-mode. > >> Above, I meant that js-mode mostly works fine with mmm-mode. And my >> suggestion might make comment filling work there, too. Automatically. > > It works automatically at the moment (with the current patch applied). I > think you're saying again you don't want to be troubled by initialising > it. It doesn't automatically work in mmm-mode. With my suggestion, it very likely would. >>>>>> Have you considered adding variables that hold the cache to >>>>>> mhtml--crucial-variable-prefix as well? Would that make it work? > >>>>> Not without the before-change function, no. I'm trying to see what the >>>>> point of putting these variables into mhtml's crucial variables would be. > >>>> Hopefully, it would make the submode regions inside independent >>>> "islands", so to speak. Each of them having its own cache structure >>>> (used or not). > >>> Ah, OK. So, buffer positions would be offsets from the island start, or >>> something like that. > >> Not necessarily, but possibly. The key aspect is that the cache inside a >> particular submode is not affected by user actions outside of its >> bounds. Not directly, at least. > > Well, when a cached holds buffer positions, something has to give - > either markers need to be used, or an offset from a variable position, or > something. Makes sense. The alternative would be to index the positions from the beginning of the submode region. But then the related feature must respect narrowing, and it would require explicit integration from mmm-mode and friends.