Alhadis / language-apl

APL language support for Atom.
https://atom.io/packages/language-apl
ISC License
7 stars 3 forks source link

Highlight the name of a defined function/operator #10

Closed jayfoad closed 6 years ago

jayfoad commented 6 years ago

When looking at the header line of a defined function or operator, it's really useful to the have the name of the function/operator highlighted. Currently it's the same colour as the result, arguments, operands and locals (example).

Currently we use scopes like entity.function.arguments.left.optional.apl and entity.function.local-variables.apl, which all end up coloured like entity.

Perhaps it would be better to use entity.function.name.apl only for the name of the function/operator, and for all other names on the header line use variable.other.apl just like we do when those names are mentioned in the body of the function.

Alhadis commented 6 years ago

Lightshow is currently down for maintenance, but definition headers should now look something like this:

Figure 1

This is a hack: I'm (ab)using the markup.bold scope to ensure unambiguous highlighting.

jayfoad commented 6 years ago

Lightshow is currently down for maintenance

... still. Any idea if/when it might come back up?

Alhadis commented 6 years ago

I'm afraid not. There's an issue filled upstream where you can subscribe for updates: github/linguist#4168

Until then, a workaround might be to install Atom, language-apl and a syntax theme deliberately designed to look close to the colours used by GitHub: https://atom.io/themes/github-atom-light-syntax

It should be enough to tide you over. =)

jayfoad commented 6 years ago

This seems to be working for niladic and dyadic functions, but not monadic functions. For example:

    ∇ onIdle
      :Access Public Overridable
    ⍝ Idle time handler - called when the server has gone idle for a period of time
    ∇

    ∇ Error req
      :Access Public Overridable
    ⍝ Handle trapped errors
      req.Response.HTML←'<font face="APL385 Unicode" color="red">',(⊃,/⎕DM,¨⊂'<br/>'),'</font>'
      req.Fail 500 ⍝ Internal Server Error
      1 Log ⎕DM
    ∇

    ∇ level Log msg
      :Access Public overridable
    ⍝ Logs server messages
    ⍝ levels implemented in MildServer are:
    ⍝ 1-error/important, 2-warning, 4-informational, 8-transaction (GET/POST)
      :If Config.LogMessageLevel bit level ⍝ if set to display this level of message
          ⎕←msg ⍝ display it
      :EndIf
    ∇

... onIdle and Log are correctly bolded, but Error is not.

Alhadis commented 6 years ago

Tip: You can get syntax highlighted code-blocks by typing the name of the language after the first three backticks:

```apl
∇ onIdle
     :Access Public Overridable
∇
```

But yeah, I see what you mean. 🤔 I'll look into it...

Alhadis commented 6 years ago

One of my least favourite things about the TextMate system is when you screw up, it accepts it silently without even hinting at what you may have done wrong. It offers you no guidance, or clues, just a stopwatch to see how long an obvious mistake like this would take me to pick up on....

@@ apl @@@
 12: {name: "keyword.operator.assignment.apl"}
-13: {name: "entity.function.name.apl", captures: {0: patterns: [include: "#embolden"]}}
+13: {name: "entity.function.name.apl", patterns: [include: "#embolden"]}

It's fortunate that you caught me at the right time, BTW. I'm scabbing somebody else's MacBook from them so I can get shitloads of Atom-related stuff that's gathered up since my regular one died. :(

jayfoad commented 6 years ago

Could you take a look at the highlighting of these 95 syntactically valid ways of defining a function or operator called f in Dyalog APL?

∇f
∇
∇f y
∇
∇f (y z)
∇
∇(p f) y
∇
∇(p f) (y z)
∇
∇(p f q) y
∇
∇(p f q) (y z)
∇
∇x f y
∇
∇x f (y z)
∇
∇x (p f) y
∇
∇x (p f) (y z)
∇
∇x (p f q) y
∇
∇x (p f q) (y z)
∇
∇{x} f y
∇
∇{x} f (y z)
∇
∇{x} (p f) y
∇
∇{x} (p f) (y z)
∇
∇{x} (p f q) y
∇
∇{x} (p f q) (y z)
∇
∇r←f
∇
∇r←f y
∇
∇r←f (y z)
∇
∇r←(p f) y
∇
∇r←(p f) (y z)
∇
∇r←(p f q) y
∇
∇r←(p f q) (y z)
∇
∇r←x f y
∇
∇r←x f (y z)
∇
∇r←x (p f) y
∇
∇r←x (p f) (y z)
∇
∇r←x (p f q) y
∇
∇r←x (p f q) (y z)
∇
∇r←{x} f y
∇
∇r←{x} f (y z)
∇
∇r←{x} (p f) y
∇
∇r←{x} (p f) (y z)
∇
∇r←{x} (p f q) y
∇
∇r←{x} (p f q) (y z)
∇
∇(r s)←f
∇
∇(r s)←f y
∇
∇(r s)←f (y z)
∇
∇(r s)←(p f) y
∇
∇(r s)←(p f) (y z)
∇
∇(r s)←(p f q) y
∇
∇(r s)←(p f q) (y z)
∇
∇(r s)←x f y
∇
∇(r s)←x f (y z)
∇
∇(r s)←x (p f) y
∇
∇(r s)←x (p f) (y z)
∇
∇(r s)←x (p f q) y
∇
∇(r s)←x (p f q) (y z)
∇
∇(r s)←{x} f y
∇
∇(r s)←{x} f (y z)
∇
∇(r s)←{x} (p f) y
∇
∇(r s)←{x} (p f) (y z)
∇
∇(r s)←{x} (p f q) y
∇
∇(r s)←{x} (p f q) (y z)
∇
∇{r}←f
∇
∇{r}←f y
∇
∇{r}←f (y z)
∇
∇{r}←(p f) y
∇
∇{r}←(p f) (y z)
∇
∇{r}←(p f q) y
∇
∇{r}←(p f q) (y z)
∇
∇{r}←x f y
∇
∇{r}←x f (y z)
∇
∇{r}←x (p f) y
∇
∇{r}←x (p f) (y z)
∇
∇{r}←x (p f q) y
∇
∇{r}←x (p f q) (y z)
∇
∇{r}←{x} f y
∇
∇{r}←{x} f (y z)
∇
∇{r}←{x} (p f) y
∇
∇{r}←{x} (p f) (y z)
∇
∇{r}←{x} (p f q) y
∇
∇{r}←{x} (p f q) (y z)
∇
∇{(r s)}←f
∇
∇{(r s)}←f y
∇
∇{(r s)}←f (y z)
∇
∇{(r s)}←(p f) y
∇
∇{(r s)}←(p f) (y z)
∇
∇{(r s)}←(p f q) y
∇
∇{(r s)}←(p f q) (y z)
∇
∇{(r s)}←x f y
∇
∇{(r s)}←x f (y z)
∇
∇{(r s)}←x (p f) y
∇
∇{(r s)}←x (p f) (y z)
∇
∇{(r s)}←x (p f q) y
∇
∇{(r s)}←x (p f q) (y z)
∇
∇{(r s)}←{x} f y
∇
∇{(r s)}←{x} f (y z)
∇
∇{(r s)}←{x} (p f) y
∇
∇{(r s)}←{x} (p f) (y z)
∇
∇{(r s)}←{x} (p f q) y
∇
∇{(r s)}←{x} (p f q) (y z)
∇

When I try this in Lightshow, forms like (p f) y and (p f q) y look odd. They have both p and f in the same style, and both q and ) in red.

Alhadis commented 6 years ago

@jayfoad It might be easier if you download Atom and install this package for yourself. Atom and GitHub/Lightshow all use the same highlighting engine, and there's even an Atom package that replicates the same colours used on GitHub (which is what I used while Lightshow was offline).

I know IME is a barrier, which is why I added support for typing APL using ASCII-fied mnemonics. For example, typing O| and hitting TAB inserts into the editor. Better yet, if you have a system-wide IME installed for APL entry, you be able to use that instead.

Alhadis commented 6 years ago

Now then... having inspected those expressions you've given me, I can conclude this could be a Lightshow bug, or some flaky handling of newlines on their end. 😥 Because what I'm seeing in Atom (which has until recently been exactly the same as what I've seen on GitHub) differs to what we're now seeing, well, on GitHub:

GitHub:

∇(r s)←f
∇
∇(r s)←f y
∇

Lightshow:
screen shot 2018-08-10 at 8 28 23 pm

Atom: .

Figure 2
jayfoad commented 6 years ago

download Atom and install this package for yourself

Is there an easy way to try out your latest commits before they've been released?

I know IME is a barrier

Not for me. X keyboard layouts for APL have been included in the Linux distros for many years now.

Alhadis commented 6 years ago

Is there an easy way to try out your latest commits before they've been released?

Yes. Under your ~/.atom/packages, you can replace the language-apl directory with a local checkout:

$ cd ~/.atom/packages;
$ rm -rf language-apl;
$ git clone git@github.com:Alhadis/language-apl.git

That's really it. Atom loads every immediate folder under ~/.atom/packages at startup, pretty much.

jayfoad commented 6 years ago

When I try this in Lightshow, forms like (p f) y and (p f q) y look odd.

I guess someone has fixed something. It all looks good in Lightshow now. Thanks!

Alhadis commented 6 years ago

You can thank @kivikakk for her hard work today getting it back online. 😉

And good to know! Let me know if you spot any more issues.