unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
@ 2019-09-09  8:49 Jostein Kjønigsen
  2019-09-09 10:48 ` Andy Moreton
  2019-09-09 21:41 ` Stefan Monnier
  0 siblings, 2 replies; 15+ messages in thread
From: Jostein Kjønigsen @ 2019-09-09  8:49 UTC (permalink / raw)
  To: emacs-devel

Hey everyone.

Right now Emacs' bat-mode has an inconsistent use of faces, both 
internally and w.r.t. to the rest of the Emacs universe.

In batch files you can create "labels". A label is a line whose 
character is : followed by alpha-numerical characters.

    :EXAMPLE_LABEL

These labels are often used via GOTO-statements for direct control flow, 
but they can also be used via CALL-statements and then they work like 
functions/subroutines and control is eventually returned to the caller.

    CALL :subroutine param1 param2
    GOTO :EOF
    etc

Right now labels have one custom-face defined for bat-mode 
(bat-label-face), and all -uses- of this label via GOTO or 
CALL-statements has this label highlighted using font-lock-constant-face.

My proposal is that we change both these rules to instead be 
font-lock-function-name-face. This solves both constency-problems:

- internal consistency of label/function fontification
- external consistency of function-name fontification.

Does anyone have an issue with such a change?

--
Vennlig hilsen
*Jostein Kjønigsen*

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjønigsen.no



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09  8:49 bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face Jostein Kjønigsen
@ 2019-09-09 10:48 ` Andy Moreton
  2019-09-09 16:09   ` Eli Zaretskii
  2019-09-09 21:41 ` Stefan Monnier
  1 sibling, 1 reply; 15+ messages in thread
From: Andy Moreton @ 2019-09-09 10:48 UTC (permalink / raw)
  To: emacs-devel

On Mon 09 Sep 2019, Jostein Kjønigsen wrote:

> Hey everyone.
>
> Right now Emacs' bat-mode has an inconsistent use of faces, both internally
> and w.r.t. to the rest of the Emacs universe.
>
> In batch files you can create "labels". A label is a line whose character is :
> followed by alpha-numerical characters.
>
>    :EXAMPLE_LABEL
>
> These labels are often used via GOTO-statements for direct control flow, but
> they can also be used via CALL-statements and then they work like
> functions/subroutines and control is eventually returned to the caller.
>
>    CALL :subroutine param1 param2
>    GOTO :EOF
>    etc
>
> Right now labels have one custom-face defined for bat-mode (bat-label-face),
> and all -uses- of this label via GOTO or CALL-statements has this label
> highlighted using font-lock-constant-face.
>
> My proposal is that we change both these rules to instead be
> font-lock-function-name-face. This solves both constency-problems:

That is not consistent with c-mode, which uses font-lock-constant-face
for both goto statements and labels.

    AndyM




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09 10:48 ` Andy Moreton
@ 2019-09-09 16:09   ` Eli Zaretskii
  2019-09-09 17:34     ` Jostein Kjønigsen
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2019-09-09 16:09 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Mon, 09 Sep 2019 11:48:09 +0100
> 
> > My proposal is that we change both these rules to instead be
> > font-lock-function-name-face. This solves both constency-problems:
> 
> That is not consistent with c-mode, which uses font-lock-constant-face
> for both goto statements and labels.

That's my feeling as well.  We fontify labels with
font-lock-constant-face in other programming modes, so it would feel
wrong to deviate from that in bat-mode.

As for uses of labels, I see your point about inconsistency, but maybe
this is justified due to the fact that batch-file labels can be
CALLed?



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09 16:09   ` Eli Zaretskii
@ 2019-09-09 17:34     ` Jostein Kjønigsen
  2019-09-09 18:10       ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Jostein Kjønigsen @ 2019-09-09 17:34 UTC (permalink / raw)
  To: Eli Zaretskii, Andy Moreton; +Cc: emacs-devel

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


On 9/9/19 6:09 PM, Eli Zaretskii wrote:
>> That is not consistent with c-mode, which uses font-lock-constant-face
>> for both goto statements and labels.
> That's my feeling as well.  We fontify labels with
> font-lock-constant-face in other programming modes, so it would feel
> wrong to deviate from that in bat-mode.
>
> As for uses of labels, I see your point about inconsistency, but maybe
> this is justified due to the fact that batch-file labels can be
> CALLed?
If the concept of a label is used consistently across many major-modes, 
maybe it would make sense to define this as a first-class font-lock concept?

Basically we could have an official "font-lock-label-face" instead, 
which by default would be derived from font-lock-constant-face. That way 
people who want labels to look more like functions can customize it on 
their end.

Would that be a better option?

-- 
Kind regards
*Jostein Kjønigsen*

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjønigsen.no

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09 17:34     ` Jostein Kjønigsen
@ 2019-09-09 18:10       ` Eli Zaretskii
  2019-09-09 19:26         ` Jostein Kjønigsen
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2019-09-09 18:10 UTC (permalink / raw)
  To: Jostein Kjønigsen; +Cc: andrewjmoreton, emacs-devel

> Cc: emacs-devel@gnu.org
> From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
> Date: Mon, 9 Sep 2019 19:34:44 +0200
> 
> If the concept of a label is used consistently across many major-modes, maybe it would make sense to define
> this as a first-class font-lock concept?
> 
> Basically we could have an official "font-lock-label-face" instead, which by default would be derived from
> font-lock-constant-face. That way people who want labels to look more like functions can customize it on their
> end.
> 
> Would that be a better option?

I don't know, I never felt the need to distinguish them.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09 18:10       ` Eli Zaretskii
@ 2019-09-09 19:26         ` Jostein Kjønigsen
  2019-09-09 20:32           ` Clément Pit-Claudel
  0 siblings, 1 reply; 15+ messages in thread
From: Jostein Kjønigsen @ 2019-09-09 19:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: andrewjmoreton, emacs-devel


On 9/9/19 8:10 PM, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org
>> From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
>> Date: Mon, 9 Sep 2019 19:34:44 +0200
>>
>> If the concept of a label is used consistently across many major-modes, maybe it would make sense to define
>> this as a first-class font-lock concept?
>>
>> Basically we could have an official "font-lock-label-face" instead, which by default would be derived from
>> font-lock-constant-face. That way people who want labels to look more like functions can customize it on their
>> end.
>>
>> Would that be a better option?
> I don't know, I never felt the need to distinguish them.
Thanks for your feedback Eli.

Not knowing your background, I'd hate to make assumptions, but could it 
be that your work mainly involves languages where a label (a pointer) 
and a constant (also possibly a pointer) largely represents the same 
thing, as it does in C?

To contrast your experience with mine, I mostly work with languages 
where a label and a constant represents 2 semantically different things, 
and mixing them in code will more often than not cause  the compiler to 
error out.

IMO they may be -used- similarly in some languages, but there's 
intrinsically nothing fundamentally similar about them outside those 
languages.

Even completely discounting that, I don't believe adding some additional 
default font-lock faces adds any considerable bloat or runtime-cost to 
Emacs. Or am I wrong about this?

If it doesn't, I really don't see any good argument -against- adding 
more semanticly accurate font-lock faces. I'm sure there are several 
major-modes where this can be put to good use (instead of relying on 
custom-faces, like bat-mode already does).

I'll admit to not following emacs-devel intimitely, so it may be that 
this is already a common ("done to death") discussion. If so I'd 
appreciate a pointer to a thread which better highlights the current  
consensus wrt to font-lock faces.

--
Jostein



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09 19:26         ` Jostein Kjønigsen
@ 2019-09-09 20:32           ` Clément Pit-Claudel
  0 siblings, 0 replies; 15+ messages in thread
From: Clément Pit-Claudel @ 2019-09-09 20:32 UTC (permalink / raw)
  To: emacs-devel

On 2019-09-09 15:26, Jostein Kjønigsen wrote:
>>> Would that be a better option?
>> I don't know, I never felt the need to distinguish them.

FWIW, I like the idea of adding extra font-lock faces.  At the moment many more define their own custom faces and they often don't have a good candidate to inherit from, leading to inconsistent rendering between mores.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09  8:49 bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face Jostein Kjønigsen
  2019-09-09 10:48 ` Andy Moreton
@ 2019-09-09 21:41 ` Stefan Monnier
  2019-09-10  4:29   ` Jostein Kjønigsen
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2019-09-09 21:41 UTC (permalink / raw)
  To: Jostein Kjønigsen; +Cc: emacs-devel

> Right now labels have one custom-face defined for bat-mode (bat-label-face),
> and all -uses- of this label via GOTO or CALL-statements has this label
> highlighted using font-lock-constant-face.
>
> My proposal is that we change both these rules to instead be
> font-lock-function-name-face. This solves both constency-problems:
>
> - internal consistency of label/function fontification

FWIW, most modes distinguish function-definitions from
function-references (aka function-calls), and I think that's a good
thing (I like my definition to be highlighted in bold, but I like my
function calls not to be highlighted at all).


        Stefan




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-09 21:41 ` Stefan Monnier
@ 2019-09-10  4:29   ` Jostein Kjønigsen
  2019-09-10 12:48     ` Stefan Monnier
  2019-09-10 14:54     ` Eli Zaretskii
  0 siblings, 2 replies; 15+ messages in thread
From: Jostein Kjønigsen @ 2019-09-10  4:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

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


On 9/9/19 11:41 PM, Stefan Monnier wrote:
>
> FWIW, most modes distinguish function-definitions from
> function-references (aka function-calls), and I think that's a good
> thing (I like my definition to be highlighted in bold, but I like my
> function calls not to be highlighted at all).
>
>
>          Stefan
>

Working mostly with OOP-related languages where functions can be 
contained in both types -and- variables, I find the opposite is true for me.

Either way, isn't that a good argument to create dedicated font-lock 
faces for those different uses, so that people with different 
preferences can customize Emacs to their preferences?

For instance font-lock-function-name-face and font-lock-function-call-face ?

Again, are there any objectively negative or adverse side-effects of 
adding more default-faces which authors can use and users can customize?

-- 
Vennlig hilsen
*Jostein Kjønigsen*

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjønigsen.no

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-10  4:29   ` Jostein Kjønigsen
@ 2019-09-10 12:48     ` Stefan Monnier
  2019-09-10 14:54     ` Eli Zaretskii
  1 sibling, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2019-09-10 12:48 UTC (permalink / raw)
  To: Jostein Kjønigsen; +Cc: emacs-devel

> Again, are there any objectively negative or adverse side-effects of adding
> more default-faces which authors can use and users can customize?

I think adding a few more standard font-lock faces would be
good, indeed.


        Stefan




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-10  4:29   ` Jostein Kjønigsen
  2019-09-10 12:48     ` Stefan Monnier
@ 2019-09-10 14:54     ` Eli Zaretskii
  2019-09-10 16:56       ` Jostein Kjønigsen
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2019-09-10 14:54 UTC (permalink / raw)
  To: Jostein Kjønigsen; +Cc: monnier, emacs-devel

> From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
> Date: Tue, 10 Sep 2019 06:29:58 +0200
> Cc: emacs-devel@gnu.org
> 
> Again, are there any objectively negative or adverse side-effects of adding more default-faces which authors
> can use and users can customize?

You mean, except requiring all the other major modes to implement it,
including those outside the Emacs core?  No other objections.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-10 14:54     ` Eli Zaretskii
@ 2019-09-10 16:56       ` Jostein Kjønigsen
  2019-09-10 18:10         ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Jostein Kjønigsen @ 2019-09-10 16:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Monnier, Ergus via Emacs development discussions.

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

On Tue, Sep 10, 2019, at 4:54 PM, Eli Zaretskii wrote:
> > From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
> > Date: Tue, 10 Sep 2019 06:29:58 +0200
> > Cc: emacs-devel@gnu.org
> > 
> > Again, are there any objectively negative or adverse side-effects of adding more default-faces which authors
> > can use and users can customize?
> 
> You mean, except requiring all the other major modes to implement it,
> including those outside the Emacs core? No other objections.
> 

I don’t think that’s a fair way of putting it. 

Giving major-mode authors more options with regard to faces they can use in their modes, does in no way -force- major-mode authors into using those if they don’t think they provide value. 

Right now major-mode authors are already inventing their own non-standard font-lock-faces and giving them standard options to use instead can IMO only be considered an improvement. 

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-10 16:56       ` Jostein Kjønigsen
@ 2019-09-10 18:10         ` Eli Zaretskii
  2019-09-10 19:49           ` Michael Albinus
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2019-09-10 18:10 UTC (permalink / raw)
  To: jostein; +Cc: monnier, emacs-devel

> Date: Tue, 10 Sep 2019 18:56:08 +0200
> From: Jostein Kjønigsen <jostein@secure.kjonigsen.net>
> Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>,
>  "Ergus via Emacs development discussions." <emacs-devel@gnu.org>
> 
>  You mean, except requiring all the other major modes to implement it,
>  including those outside the Emacs core?  No other objections.
> 
> I don’t think that’s a fair way of putting it. 
> 
> Giving major-mode authors more options with regard to faces they can use in their modes, does in no way
> -force- major-mode authors into using those if they don’t think they provide value. 

The moment new faces are added I expect users to start complaining
that these faces are not supported by this and that foo-mode.  So mode
authors aren't forced to implement them only in theory, IMO.

This is just my opinion.  You asked a question, and I gave my answer
to it.  When you ask a question, you should be prepared to hear some
answers that you may not like, right?



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-10 18:10         ` Eli Zaretskii
@ 2019-09-10 19:49           ` Michael Albinus
  2019-09-18 19:21             ` Jostein Kjønigsen
  0 siblings, 1 reply; 15+ messages in thread
From: Michael Albinus @ 2019-09-10 19:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jostein, monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> The moment new faces are added I expect users to start complaining
> that these faces are not supported by this and that foo-mode.  So mode
> authors aren't forced to implement them only in theory, IMO.

For modes in elpa, there is also the backward compatibility problem. So
they cannot feel forced to apply such new faces directly.

Asking for similar faces for similar syntactic entities in different
modes is legitimate. IMHO.

These new faces give mode authors a hint how to provide own customized
faces as long as necessary. And moving to the new faces will happen over
the years only.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face
  2019-09-10 19:49           ` Michael Albinus
@ 2019-09-18 19:21             ` Jostein Kjønigsen
  0 siblings, 0 replies; 15+ messages in thread
From: Jostein Kjønigsen @ 2019-09-18 19:21 UTC (permalink / raw)
  To: Michael Albinus, Eli Zaretskii
  Cc: Clément Pit-Claudel, Andy Moreton, Ergus, emacs-devel,
	monnier, jostein

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


On 9/10/19 9:49 PM, Michael Albinus wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>> The moment new faces are added I expect users to start complaining
>> that these faces are not supported by this and that foo-mode.  So mode
>> authors aren't forced to implement them only in theory, IMO.
> For modes in elpa, there is also the backward compatibility problem. So
> they cannot feel forced to apply such new faces directly.
>
> Asking for similar faces for similar syntactic entities in different
> modes is legitimate. IMHO.
>
> These new faces give mode authors a hint how to provide own customized
> faces as long as necessary. And moving to the new faces will happen over
> the years only.
>
> Best regards, Michael.

Thanks everyone for your feedback. I've been quite busy the last few 
weeks, so sorry my lack of response.

So to sum up the responses I've gotten so far:

- personally would appreciate more default font-lock faces to better 
differentiate between things which are semanticly different,
- don't personally have a need for additional default font-lock faces, 
but don't see anything wrong with it.
- critical of the pressure and expectations adding more default-faces 
would put on major-mode authors.

I'll be optimistic and consider that a slight majority in favour of 
moving forwards.

Based on the discussion so far, my proposal last year[1], not to mention 
the recent parallell thread started by Ergus[2] we have at least these 
candidates:

- font-lock-decorator-face
- font-lock-number-face
- font-lock-label-face (font-lock-label-reference-face?)
- font-lock-function-name-face (font-lock-function-reference-face)
- font-lock-function-declaration-face

Is that a reasonable list of faces to add? Is it OK for me at this point 
to create a patch for this, or should that list undergo further 
discussion first?

The advice I received last time[1] I asked about adding faces was that I 
would need to:

- clarify usage of these modes precisely
- add them to font-lock.el
- document this in the proper **/*.texi files
- add news of these additions to ETC/news

Does that still hold true?

[1] https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00258.html
[2] https://lists.gnu.org/archive/html/emacs-devel/2019-09/msg00194.html


-- 
Kind regards
*Jostein Kjønigsen*

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjønigsen.no

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-09-18 19:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09  8:49 bat-mode: Inconsistent fontification. Consider using font-lock-function-name-face Jostein Kjønigsen
2019-09-09 10:48 ` Andy Moreton
2019-09-09 16:09   ` Eli Zaretskii
2019-09-09 17:34     ` Jostein Kjønigsen
2019-09-09 18:10       ` Eli Zaretskii
2019-09-09 19:26         ` Jostein Kjønigsen
2019-09-09 20:32           ` Clément Pit-Claudel
2019-09-09 21:41 ` Stefan Monnier
2019-09-10  4:29   ` Jostein Kjønigsen
2019-09-10 12:48     ` Stefan Monnier
2019-09-10 14:54     ` Eli Zaretskii
2019-09-10 16:56       ` Jostein Kjønigsen
2019-09-10 18:10         ` Eli Zaretskii
2019-09-10 19:49           ` Michael Albinus
2019-09-18 19:21             ` Jostein Kjønigsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).