From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: CC Mode and electric-pair "problem". Date: Tue, 19 Jun 2018 02:38:44 -0400 Message-ID: References: <20180531123747.GA24752@ACM> <20180617201351.GA4580@ACM> <20180618103654.GA9771@ACM> <20180618154227.GB3973@ACM> <20180618180846.GC3973@ACM> <8f6c273f-9a20-0744-7f26-533aabb97a48@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1529390257 7875 195.159.176.226 (19 Jun 2018 06:37:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 19 Jun 2018 06:37:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 19 08:37:33 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fVAGi-0001x0-IW for ged-emacs-devel@m.gmane.org; Tue, 19 Jun 2018 08:37:32 +0200 Original-Received: from localhost ([::1]:39695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVAIo-0007Pk-22 for ged-emacs-devel@m.gmane.org; Tue, 19 Jun 2018 02:39:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVAI5-0007PS-Bc for emacs-devel@gnu.org; Tue, 19 Jun 2018 02:38:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVAI2-0005hD-6u for emacs-devel@gnu.org; Tue, 19 Jun 2018 02:38:57 -0400 Original-Received: from [195.159.176.226] (port=57412 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVAI2-0005gu-0Q for emacs-devel@gnu.org; Tue, 19 Jun 2018 02:38:54 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fVAFs-00015C-5u for emacs-devel@gnu.org; Tue, 19 Jun 2018 08:36:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:ShxexIUlxjYIjVThwjsMKeQeLUA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226494 Archived-At: >> 1- Make sure the programmer is aware there's a problem in its code. >> I.e. highlight the opening quote or the non-escaped end-of-line or >> something in bright red or something like that. > Agreed. Given this criterion, the patch is an improvement: making sure that > lines past the first one are not highlighted suppresses the risk of > misleading the programmer into thinking that they have a multiline-string. The old behavior highlighted the opening (and not-closed on the same line) quote in font-lock-warning-face, which seemed perfectly adequate. > (This happens to me from time to time in Python, actually: I write "abc > def" instead of """abc > def""", and the highlighting doesn't immediately reveal the error. > Simply not highlighting the second line would help a lot. It's easier to highlight the unmatched opener than to try and prevent the second line from being highlighted (and you want to highlight that opener in any case). >> 2- Don't try to guess what the user intended to do. >> Instead keep our code as simple as possible: the C code we're handed >> is broken, so there's no real clear "right behavior" anyway. > > I'm not sure whether we can afford to bail out like that — for people who > don't use some form of structured editing, most of the code that the IDE > ends up seeing is broken in some way (unmatched { or ", incomplete > declarations, incorrect numbers of arguments, undeclared identifiers, etc.) Not sure what you mean by "bail out". Point 1 has added highlighting to warn the user about the presence of a problem. Short of changing the actual code behind the user's back, there's really not much more we can do to prevent the compiler/IDE from seeing that broken code. > Modeling our error recovery behaviors on the one used by relevant compilers > seems like a pretty good approach (ultimately, for the modes I maintain, I'd > like to delegate fontification to a language server provided by the > compiler). Point 2 suggest to go with the simplest implementation (i.e. let the behavior be dictated by the implementation), so if your highlighting is provided by LSP (say), then point 2 would suggest that there's no point trying to provide a different behavior from the one provided by the LSP server. Stefan