From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nir Friedman Newsgroups: gmane.emacs.bugs Subject: bug#23501: Non-regex-based syntax highlighting Date: Tue, 10 May 2016 16:16:03 -0400 Message-ID: References: <834ma5dhut.fsf@gnu.org> <83vb2lbtxc.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113f63d64f3148053282994f X-Trace: ger.gmane.org 1462911441 10608 80.91.229.3 (10 May 2016 20:17:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 May 2016 20:17:21 +0000 (UTC) Cc: 23501@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 10 22:17:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b0E5f-0002md-Dq for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 May 2016 22:17:11 +0200 Original-Received: from localhost ([::1]:48804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0E5e-0005is-MV for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 May 2016 16:17:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0E5a-0005gR-Cg for bug-gnu-emacs@gnu.org; Tue, 10 May 2016 16:17:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0E5W-0004Q0-6I for bug-gnu-emacs@gnu.org; Tue, 10 May 2016 16:17:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0E5W-0004Pw-3R for bug-gnu-emacs@gnu.org; Tue, 10 May 2016 16:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b0E5V-0007Zs-Vp for bug-gnu-emacs@gnu.org; Tue, 10 May 2016 16:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nir Friedman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2016 20:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23501-submit@debbugs.gnu.org id=B23501.146291139129088 (code B ref 23501); Tue, 10 May 2016 20:17:01 +0000 Original-Received: (at 23501) by debbugs.gnu.org; 10 May 2016 20:16:31 +0000 Original-Received: from localhost ([127.0.0.1]:46291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0E50-0007Z6-Pg for submit@debbugs.gnu.org; Tue, 10 May 2016 16:16:31 -0400 Original-Received: from mail-io0-f179.google.com ([209.85.223.179]:33924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0E4y-0007Yt-KM for 23501@debbugs.gnu.org; Tue, 10 May 2016 16:16:29 -0400 Original-Received: by mail-io0-f179.google.com with SMTP id 190so30157157iow.1 for <23501@debbugs.gnu.org>; Tue, 10 May 2016 13:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=c/8AYhQs3YdA5pLtvoVSYpZObINaPRWuMXu967INrVw=; b=E0yJeqICwV6dV7/e94nDiI+6b9pIjDYn41ftMNWVr30LxNpV1sv4ZaTlcp+HTB8Kn5 Cb69cHuI7JJe6A9dIPRykJ6wBsPNU3XV7aG9JSXHkeosA7bVK9hOGbIVybP+I9bH2Y20 TysFMw6jaKGgHtFaNzEdDwLRBOuAaVlL/Kq8JPM+FDXwT8jIg8XOZ+qZG8M6D7h0U6ak 6nJpSviPHxq4dldPj4qIBbiPMf/+u4bc/hmG/jqnnpTV0mZu4cbNQ30LzqiXj3hrUzCV +ROPLg8v4GcZT4kFm/p8fwtHZ7UamGact2kSNwydj2dI1uYTLXI+PR2MoPZYMEJDYQq9 p9rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=c/8AYhQs3YdA5pLtvoVSYpZObINaPRWuMXu967INrVw=; b=kuY1YmmWJcUB4XUybBmsZpf8wI7p4qAk4hPE+LXAJZabxtyfyP177GQNG7q5+Crb6w qeyOf5Cl1kN8Pb/WDU3hnKZdZHhf92xG4uc6Z0yJNjF32OLPD3sleWBxSc2IgOIKgdnY 3Ecs8SVMMubS92xOBoT8u53zCzholyU7yQoKIHTF+/8rMWH6XTiLHFEXr2kOJ5azGFEd H8mFarilAYDB9U92Mq0/NiumK8jpEa7RP3VEYswhJNRXrWaWKUds2lVAjB0jPapby8o/ 8sTc+bTYTo81a82bZSlFL22AIQGUZioVrJIP6IFM18WU7ZqzLgTj3EduJRPJPXYYKrFY NZYg== X-Gm-Message-State: AOPr4FWrfafWLNcxLnHALuWsWenLlNRrbUE3A/fehfKWS8hERyYEjC2nk3YZExAbqDHT0PEa7W0j6sGYzSo5vw== X-Received: by 10.36.13.76 with SMTP id 73mr11378itx.87.1462911382787; Tue, 10 May 2016 13:16:22 -0700 (PDT) Original-Received: by 10.79.129.11 with HTTP; Tue, 10 May 2016 13:16:03 -0700 (PDT) In-Reply-To: <83vb2lbtxc.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:118084 Archived-At: --001a113f63d64f3148053282994f Content-Type: text/plain; charset=UTF-8 My idea for a hook was basically to make it possible to provide a callback function to the Major mode. If this callback function is provided, then when a new file is loaded or an existing one saved with modifications, the callback function is called with the full path to the file. The callback function must return something that basically tells the major mode how to color everything. A simple way would just be to return a list of the colors for every single non-whitespace character taken sequentially. A single very fast pass through this list would then be able to color every character. Is there a reason why that would not be workable? Also, can you point me to where exactly (e.g. via link to the emacs github mirror) the major modes are stored? On Tue, May 10, 2016 at 3:21 PM, Eli Zaretskii wrote: > > From: Nir Friedman > > Date: Tue, 10 May 2016 14:55:41 -0400 > > Cc: 23501@debbugs.gnu.org > > > > I guess I'm a bit less clear on the solution, because I don't have a > good sense of who the owner of the C++ > > major mode is, and how the code is structured. My thinking was that > perhaps hooks could be added to make > > it easier for plugin writers to modify the syntax coloring of the major > mode. As opposed to plugin writers > > needing to rewrite the C++ major mode from scratch just to change the > syntax coloring. > > Colors are added at display time, so hooks will not help here. Or at > least it isn't immediately clear to me how they could help. > > I suggest to study how syntax highlighting works in Emacs, including > the JIT font-lock feature and its relation to the display engine. > Until you have a good understanding of how this stuff works, I don't > think you will be able to come with a design for hooks which external > tools could use for this purpose. > --001a113f63d64f3148053282994f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
My idea for a hook was basically to make it possible to pr= ovide a callback function to the Major mode. If this callback function is p= rovided, then when a new file is loaded or an existing one saved with modif= ications, the callback function is called with the full path to the file. T= he callback function must return something that basically tells the major m= ode how to color everything. A simple way would just be to return a list of= the colors for every single non-whitespace character taken sequentially. A= single very fast pass through this list would then be able to color every = character.

Is there a reason why that would not be worka= ble? Also, can you point me to where exactly (e.g. via link to the emacs gi= thub mirror) the major modes are stored?


<= /div>

On Tue= , May 10, 2016 at 3:21 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> From: Nir Friedman <quicknir@gmail.com>
> Date: Tue, 10 May 2016 14:55:41 -0400
> Cc: 23501@debbugs.gnu.org=
>
> I guess I'm a bit less clear on the solution, because I don't = have a good sense of who the owner of the C++
> major mode is, and how the code is structured. My thinking was that pe= rhaps hooks could be added to make
> it easier for plugin writers to modify the syntax coloring of the majo= r mode. As opposed to plugin writers
> needing to rewrite the C++ major mode from scratch just to change the = syntax coloring.

Colors are added at display time, so hooks will not help here.=C2=A0= Or at
least it isn't immediately clear to me how they could help.

I suggest to study how syntax highlighting works in Emacs, including
the JIT font-lock feature and its relation to the display engine.
Until you have a good understanding of how this stuff works, I don't think you will be able to come with a design for hooks which external
tools could use for this purpose.

--001a113f63d64f3148053282994f--