From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23501: Non-regex-based syntax highlighting Date: Wed, 11 May 2016 10:49:34 +0300 Message-ID: <83r3d9avap.fsf@gnu.org> References: <834ma5dhut.fsf@gnu.org> <83vb2lbtxc.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1462953026 32055 80.91.229.3 (11 May 2016 07:50:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 May 2016 07:50:26 +0000 (UTC) Cc: 23501@debbugs.gnu.org To: Nir Friedman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 11 09:50:15 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 1b0OuJ-0007HY-Qy for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 May 2016 09:50:11 +0200 Original-Received: from localhost ([::1]:50873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0OuJ-0000ZB-8V for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 May 2016 03:50:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0OuF-0000UA-1X for bug-gnu-emacs@gnu.org; Wed, 11 May 2016 03:50:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0OuA-0003vl-Nj for bug-gnu-emacs@gnu.org; Wed, 11 May 2016 03:50:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0OuA-0003vg-KF for bug-gnu-emacs@gnu.org; Wed, 11 May 2016 03:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b0OuA-0006Wq-BG for bug-gnu-emacs@gnu.org; Wed, 11 May 2016 03:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 May 2016 07:50:02 +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.146295298225063 (code B ref 23501); Wed, 11 May 2016 07:50:02 +0000 Original-Received: (at 23501) by debbugs.gnu.org; 11 May 2016 07:49:42 +0000 Original-Received: from localhost ([127.0.0.1]:46622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0Otp-0006WB-QE for submit@debbugs.gnu.org; Wed, 11 May 2016 03:49:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42798) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0Oto-0006Vy-5o for 23501@debbugs.gnu.org; Wed, 11 May 2016 03:49:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0Otd-0003sD-W1 for 23501@debbugs.gnu.org; Wed, 11 May 2016 03:49:34 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Otd-0003s2-ST; Wed, 11 May 2016 03:49:29 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4555 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1b0Otb-0004Lk-MN; Wed, 11 May 2016 03:49:28 -0400 In-reply-to: (message from Nir Friedman on Tue, 10 May 2016 16:16:03 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:118099 Archived-At: > From: Nir Friedman > Date: Tue, 10 May 2016 16:16:03 -0400 > Cc: 23501@debbugs.gnu.org > > 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 syntax highlighting should change also when you modify the buffer, not only when you save it. How will that work with your proposed hook? > 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. The hook cannot return a color, because the colors are defined via faces. It should return faces instead. > Is there a reason why that would not be workable? Maybe it is workable, but you are missing too many details of how syntax highlight works in Emacs. As I wrote previously, I encourage you to study how that works, in order for the proposal to be workable and practical. > Also, can you point me to where exactly (e.g. via link to the > emacs github mirror) the major modes are stored? It's not the major mode that you need to look at, it's the font-lock machinery. Major modes just use the font-lock features by setting the font-lock faces on portions of the buffer. Then at display time, the visible portion of the buffer are displayed as specified by those faces. You will see that each major mode simply sets the font-lock faces, and leaves the rest to the core features. See font-lock.el and font-core.el for the font-lock features, and jit-lock.el for the JIT coloring of the visible portions of the buffer.