all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Anders Lindgren <andlind@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: Regarding Emacs, js.el, template-strings and syntax-tables
Date: Tue, 5 Sep 2017 09:00:03 +0200	[thread overview]
Message-ID: <CABr8ebb76fJJLk0=OBOUGgfByOkGwp8+-v_-=QakDYCh=Rp-Gg@mail.gmail.com> (raw)
In-Reply-To: <cadac750-7a5e-20cf-28b1-981416def5aa@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 2670 bytes --]

>
> 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

[-- Attachment #2: Type: text/html, Size: 3950 bytes --]

  reply	other threads:[~2017-09-05  7:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24  6:56 Regarding Emacs, js.el, template-strings and syntax-tables Jostein Kjønigsen
2017-08-24 10:53 ` Stefan Monnier
2017-08-24 12:13   ` Jostein Kjønigsen
2017-08-24 12:17     ` Jostein Kjønigsen
2017-08-24 13:47       ` Stefan Monnier
2017-08-24 14:04     ` Stefan Monnier
2017-08-24 12:31   ` Anders Lindgren
2017-08-24 14:20     ` Stefan Monnier
2017-08-27 16:37       ` Dmitry Gutov
2017-08-24 14:22     ` Stefan Monnier
2017-08-24 15:19       ` Anders Lindgren
2017-08-29 13:36         ` Stefan Monnier
2017-08-29 13:49           ` Anders Lindgren
2017-08-30  2:22             ` Richard Stallman
2017-09-01 12:14               ` Anders Lindgren
2017-09-04 23:40     ` Dmitry Gutov
2017-09-05  7:00       ` Anders Lindgren [this message]
2017-09-05  8:25         ` Dmitry Gutov
2017-09-05  9:30           ` Anders Lindgren
2017-09-05  9:53             ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABr8ebb76fJJLk0=OBOUGgfByOkGwp8+-v_-=QakDYCh=Rp-Gg@mail.gmail.com' \
    --to=andlind@gmail.com \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.