Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ease the use of multi-line custom code by automatically adding necessary syntax #16

Open
ptar opened this issue Oct 5, 2018 · 1 comment

Comments

@ptar
Copy link
Collaborator

ptar commented Oct 5, 2018

Short description

If you enter custom code consisting of more than one line, the initial EOL and the final 'return' should be added automatically, if not present.

Detailed description

For example, generating the current timestamp in a way it can be used in filenames with the shortcut Ctrl-Win-e have to look like this in AHK:

;It will look like 2018-10-05_08.36h
^+#e:: 
FormatTime, CurrentDateTime,, yyyy-MM-dd_HH.mm'h 
SendInput %CurrentDateTime%
return

If I only put

FormatTime, CurrentDateTime,, yyyy-MM-dd_HH.mm'h 
SendInput %CurrentDateTime%

in the custom code field, it won't work, even if I append the line with 'return'.
There must be an initial EOL after the shortcut and before the code.

It would be great if this initial EOL and the return would added, if they don't exist.

@mshafer1
Copy link
Owner

mshafer1 commented Oct 6, 2018

This is another nuance that I thought about tweaking initially, but then realized that

a. Currently the only way to introduce custom functions is to take advantage of this. Something like

    do_something_in_hotkey()
    return

function ...
  • if we did do this, we should probably also add a sandbox option to the main category (in addition to hotkey and hotstring) so that there is still a way to do this (and now we're moving away from primary focus on being simple and easy to get off the ground with AHK using this).

b. Anyone that does expect it to just put the code that they put would be annoyed

  • although I can't say with certainty that this is a larger group than those that want it to do more like you are suggesting (and would also like it to validate hotkeys and such).

So I don't think that automatically wrapping in new lines and return statements is a good idea, unless we went the whole way and provided the main sandbox, and only:

  • provided the starting new line if:
    • the provided code has new lines but does not start with a new line and does not have a return
  • provide the return if:
    • the provided code has new lines but does not have a return somewhere in it.

I had thought a while back about setting up a downstream version with more features available at something like https://advanced.ahkgen.com - I would rather do this in that context, keeping the original focused on helping newcomers get up and going (people I don't expect to be using sandbox features).

With this additional information, where do you stand?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants