Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Moonscript Support? #322

Open
shakna-israel opened this issue Jul 10, 2017 · 4 comments
Open

Moonscript Support? #322

shakna-israel opened this issue Jul 10, 2017 · 4 comments
Labels

Comments

@shakna-israel
Copy link

Moonscript makes writing Lua a lot less boilerplate-y.

Would support be possible at all?

Something like if a *.moon file is found in the usual directories, and moonc is in $PATH, try and compile them to Lua. (Probably only at launch).

Quick contrived example:

with Config
   -- Set the location of your Maildir folders, and your sent-folder
   \set( "maildir.prefix", os.getenv( "HOME" ) .. "/Maildir/" );
   \set( "global.sent-mail", os.getenv( "HOME" ) .. "/Maildir/sent/" )
   -- Set your outgoing mail-handler, and email-address:
   \set( "global.mailer", "/usr/lib/sendmail -t" )
   \set( "global.sender", "Some User <steve@example.com>" )
   -- Set your preferred editor
   \set( "global.editor", "vim  +/^$ ++1 '+set tw=72'" )

As opposed to:

 -- Set the location of your Maildir folders, and your sent-folder
 Config:set( "maildir.prefix", os.getenv( "HOME" ) .. "/Maildir/" );
 Config:set( "global.sent-mail", os.getenv( "HOME" ) .. "/Maildir/sent/" )

 -- Set your outgoing mail-handler, and email-address:
 Config:set( "global.mailer", "/usr/lib/sendmail -t" )
 Config:set( "global.sender", "Some User <steve@example.com>" )

 -- Set your preferred editor
 Config:set( "global.editor", "vim  +/^$ ++1 '+set tw=72'" )
@skx
Copy link
Member

skx commented Jul 10, 2017

I'm not sure what the benefit would/could be? In your include example it doesn't save any configuration-option, or simplify the syntax to any useful extent.

(I must admit I've never looked at moonscript before, I might be missing something obvious.)

@shakna-israel
Copy link
Author

shakna-israel commented Jul 10, 2017

More thinking from the user side of things, moonscript does tend to be somewhat popular, and compiles cleanly, so why not let the user use it?

But some things that a user might like are probably:

  • String interpolation.
  • Table comprehensions.

So if I were to go further with the incredibly contrived example:

  settings = {
    "maildir.prefix": "#{os.getenv("Home"}/Maildir/"
    "global.sent-mail": "#{os.getenv( "HOME" )}/Maildir/sent/"
    "global.mailer": "/usr/lib/sendmail -t"
    "global.sender": "Some User <steve@example.com>"
    "global.editor": "vim  +/^$ ++1 '+set tw=72'"
  }
  with Config
    [\set(k, v) for k,v in pairs(settings)]

@skx
Copy link
Member

skx commented Jul 10, 2017

If it were a new project I think that argument would be more compelling.

As things stand 100% of the core, and user-scripts, are pure lua. Users are familiar with it, and it works well. There might be nice things, but changing just to gain string interpolation seems like a step too far.

Your sample could be just as easily a table in the current setup, obviously. But I appreciate that is contrived example.

I think I'll say wontfix because it would require a lot of documentation changes and churn for no obvious gain.

@shakna-israel
Copy link
Author

I'm not suggesting a switch, or much changed behaviour.

Basically avoid adding this to my own config.lua

Something like:

if string.match(os.getenv("PATH"), "moonc") then
  local handle = io.popen("moonc" .. os.getenv("HOME") .. "/.config/lumail/*.moon")
  handle:close()
  handle = io.popen("moonc" .. os.getenv("HOME") .. "/.lumail/lumail/*.moon")
  handle:close()
  handle = io.popen("moonc" .. os.getenv("$XDG_CONFIG_HOME") .. "/lumail/*.moon")
  handle:close()
end

If a user wants to use moonscript, then they probably know what it is, and as it compiles to Lua, the API doesn't change.

@skx skx added the wontfix label Jul 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants