From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.devel Subject: Re: Regarding Emacs, js.el, template-strings and syntax-tables Date: Tue, 5 Sep 2017 09:00:03 +0200 Message-ID: References: <1503557767.41308.1083341824.4A2103C1@webmail.messagingengine.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c18faacdc877a05586bc616" X-Trace: blaine.gmane.org 1504594861 28402 195.159.176.226 (5 Sep 2017 07:01:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Sep 2017 07:01:01 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 05 09:00:36 2017 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 1dp7qP-0005k1-GP for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2017 09:00:21 +0200 Original-Received: from localhost ([::1]:57157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dp7qW-0002TC-FN for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2017 03:00:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dp7qK-0002Sy-Qp for emacs-devel@gnu.org; Tue, 05 Sep 2017 03:00:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dp7qA-0007Fr-Sf for emacs-devel@gnu.org; Tue, 05 Sep 2017 03:00:16 -0400 Original-Received: from mail-ua0-x236.google.com ([2607:f8b0:400c:c08::236]:38036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dp7qA-0007F4-Lw for emacs-devel@gnu.org; Tue, 05 Sep 2017 03:00:06 -0400 Original-Received: by mail-ua0-x236.google.com with SMTP id l24so6279963uaa.5 for ; Tue, 05 Sep 2017 00:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+ccViKV0V8me0r6PTVkH6jOULzklqcfngQKLn+kv3Gw=; b=m0o25no4pzBvXw9xgcAkRiRlOBgoMwBiKSnhHpLIireaDKjjxTnvxI/cFXrGNkz/i5 O9E/B2jbnYPTs5+ZlPk7nHmwoTfQlMUC6gxuvZ4g+ET6U4kWiEbpudUSmfWxvw27YMJo 1BlfM+YyYrPo4fuPiGb1PtEt5XbmFeYKYGgU3R5xIs4keumlWWp8ur2L5NJ5HuRQmT9+ WQEoKK+iFW6WS1zpZH8gyB2+j4CXx2tFxlj0vFkieZl+vt4rRO7Uqujxr8a3oG6Sg27x sVLWKc62q0mKgflnd5nQILQQoRPFg+u1YSxcmp1rSk0kuOR+dinuQg8W2G+yCj1QFQID ZwyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+ccViKV0V8me0r6PTVkH6jOULzklqcfngQKLn+kv3Gw=; b=Dog+yhFEQjS29HfQXuK9eZX7DftPnkiz/E79i0PGOFLFA6veaf+S0lH1mgDvWK+7qQ 1GO2/XXU48PuB2qHixcqA7ddaSjemdrVLukmKnd6SDxRyz97lMCQgBZXSZgTppii0bY1 3NnMK3MQjYF0G1+UM5XZ6TDlb2dU9jRdhKJvuBR1hgb8LbruYm4zFO85pxTZ50TO+ChN GRg+3sIVBFmtesFBb1eNbo0DH/cNw0QNF7hIkr56zHcYS/+XCrIyIfQhkXV3eae3WajN QxzYvj7qeN7R3OM13dbrCoqAbXv6ulRphccXR4pyahTq5nsnBEZ87oXAZYs7dNDYyeY6 5TqA== X-Gm-Message-State: AHPjjUj5HOn8CdF8naHXD3et7FmbCH0921KM1Qv6mmyoUcnTjoUGVqDz w0r/3o3cfC4wzoQmzvAKaRoanKrQRA== X-Google-Smtp-Source: ADKCNb5LXsaxfXGD18aOiFr1it6vVfVpId2NY7ySm/fewVMd+9NTvA+g32VRL7s0Ee/IRZddyFX/z3b3iKTEADn8wnU= X-Received: by 10.176.82.210 with SMTP id w18mr1878849uaw.29.1504594804638; Tue, 05 Sep 2017 00:00:04 -0700 (PDT) Original-Received: by 10.31.171.202 with HTTP; Tue, 5 Sep 2017 00:00:03 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::236 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:217938 Archived-At: --94eb2c18faacdc877a05586bc616 Content-Type: text/plain; charset="UTF-8" > > If you use a string face with, say, both a background and a foreground >> color, it will matter if you *replace* the existing face as opposed to >> *prepend* a new face on top of it. >> >> For example, the default Ruby mode replace the face, >> > > That is a legacy behavior, as far as I'm concerned. In some other editors > that I've looked at (e.g. Vim and either Sublime Text or Atom), the > contents of the interpolation construct look like normal text. You can have > nested strings and interpolations inside them, so it's a good semantic cue. I guess it all depends om the level of complexity that the language supports. In the shell and Ruby cases, nested constructs can be complex, so I guess it makes sense to go back to the normal face (contrary to what I said before). In other languages where the constructs only can be simple variables, I would prefer to retain the string face (for the sake of things like the background color) and color the variable name by prepending the variable name face. One question is if the delimiters around the expression should be >> highlighted as well? In Ruby they are highlighted. In my cmake-font-lock[1] >> package I have opted not to highlight them, as it makes it easier to read >> the variable name: >> > > If the contents are highlighted differently, the variable name will stand > out just the same, even with the delimiters highlighted. In my experience, I can read code easier if the delimiters aren't highlighted the same way the content is. (In other words, the current Ruby implementation isn't ideal for me.) In all cases I've seen, the content is displayed using >> `font-lock-variable-name-face', even for the cases where the content is >> more complex than a plain variable. I would say that this is OK, as they >> stand out and, most of the time, it is a plain variable anyway. >> > > We don't use font-lock-variable-name-face for "plain variables" outside of > strings, though. Not in ruby-mode, at least. > While we're on the subject. I've been thinking about highlighting parameters in functions and blocks in Ruby. It wouldn't be too difficult, and it would make code easier to read. Unfortunately, it doesn't include all variables as local variables can be created on the fly using a plain assignment in Ruby. As a parallel, my lisp-extra-font-lock package ( https://github.com/Lindydancer/lisp-extra-font-lock) do this in Lisp modes for function and lambda parameters and local variables introduces using `let`, `dolist` et.c. Now that I've been using it for a couple of years, I would not dream of going back to the near black-and-white world of the default lisp modes. -- Anders --94eb2c18faacdc877a05586bc616 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
If you use a string face with, = say, both a background and a foreground color, it will matter if you *repla= ce* the existing face as opposed to *prepend* a new face on top of it.

For example, the default Ruby mode replace the face,

That is a legacy behavior, as far as I'm concerned. In some other edito= rs that I've looked at (e.g. Vim and either Sublime Text or Atom), the = contents of the interpolation construct look like normal text. You can have= nested strings and interpolations inside them, so it's a good semantic= cue.

I guess it all depends om the level o= f complexity that the language supports. In the shell and Ruby cases, neste= d constructs can be complex, so I guess it makes sense to go back to the no= rmal face (contrary to what I said before). In other languages where the co= nstructs only can be simple variables, I would prefer to retain the string = face (for the sake of things like the background color) and color the varia= ble name by prepending the variable name face.

One question is if t= he delimiters around the expression should be highlighted as well? In Ruby = they are highlighted. In my cmake-font-lock[1] package I have opted not to = highlight them, as it makes it easier to read the variable name:

If the contents are highlighted differently, the variable name will stand o= ut just the same, even with the delimiters highlighted.
In my experience, I can read code easier if the delimiters are= n't highlighted the same way the content is. (In other words, the curre= nt Ruby implementation isn't ideal for me.)

In all cases I'= ve seen, the content is displayed using `font-lock-variable-name-face'<= wbr>, even for the cases where the content is more complex than a plain var= iable. I would say that this is OK, as they stand out and, most of the time= , it is a plain variable anyway.

We don't use font-lock-variable-name-face for "plain variables&quo= t; outside of strings, though. Not in ruby-mode, at least.
=

While we're on the subject. I've been thinking = about highlighting parameters in functions and blocks in Ruby. It wouldn= 9;t be too difficult, and it would make code easier to read. Unfortunately,= it doesn't include all variables as local variables can be created on = the fly using a plain assignment in Ruby.

As a par= allel, my lisp-extra-font-lock package (https://github.com/Lindydancer/lisp-extra-font= -lock) do this in Lisp modes for function and lambda parameters and loc= al variables introduces using `let`, `dolist` et.c. Now that I've been = using it for a couple of years, I would not dream of going back to the near= black-and-white world of the default lisp modes.

= =C2=A0 =C2=A0 -- Anders

--94eb2c18faacdc877a05586bc616--