halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

copy-formatted-for-elm-repl: copy selected code into clipboard formatted for pasting into repl #167

Open stepheneb opened 5 years ago

stepheneb commented 5 years ago

I'd like to be able to copy selected multiline Elm code into the clipboard and be able to paste it into the elm repl formatted to be able to be successfully evaluated.

I'm curious whether this is possible ... and how hard it would be -- or maybe it already exists??

For example this code copied and pasted into the elm repl generates an error:

type alias Option =
    { id : Int
    , name : Stri

Adding \ at the end of each line except for the last allows the repl to evaluate it successfully:

type alias Option = \
    { id : Int \
    , name : String \
    }
SidneyNemzer commented 5 years ago

It seems like copying with newlines escaped could be useful for a text editor in general. Maybe it could be made into its own package? (I didn't see an existing package like this during a quick search).

halohalospecial commented 5 years ago

@stepheneb, the feature shouldn't be hard to implement, but it would be a special copy command (e.g. Elmjutsu: Copy For Repl). Are you okay with that?

stepheneb commented 5 years ago

That would be fine!

Also if you want to outline where changes should be made I'm also happy to try and implement the feature and generate a pull request.

On Tue, May 21, 2019 at 4:24 AM halohalospecial notifications@github.com wrote:

@stepheneb https://github.com/stepheneb, the feature shouldn't be hard to implement, but it would be a special copy command (e.g. Elmjutsu: Copy For Repl). Are you okay with that?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/halohalospecial/atom-elmjutsu/issues/167?email_source=notifications&email_token=AAABYFFV4RUQACUXHOJ6BGDPWOWSJA5CNFSM4HL6ATHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV3EWYQ#issuecomment-494291810, or mute the thread https://github.com/notifications/unsubscribe-auth/AAABYFB4O5DC33O4JV3YJKLPWOWSJANCNFSM4HL6ATHA .

-- Be curious and kind whenever possible, https://learnmaketeachshare.org/

halohalospecial commented 5 years ago

@stepheneb, you can add the command in lib/main.js

Somewhere here:

this.subscriptions.add(
      atom.commands.add(
        'atom-text-editor:not([mini])[data-grammar^="source elm"]',
        {
          'elmjutsu:quick-fix-file': () => this.quickFix.quickFixFileCommand(),
          'elmjutsu:set-main-paths': () =>
            this.elmMakeRunner.setMainPathsCommand(),
          'elmjutsu:set-compile-output-path': () =>
            this.elmMakeRunner.setCompileOutputPathCommand(),
          'elmjutsu:go-to-definition': () => this.goTo.goToDefinitionCommand(),
          'elmjutsu:go-to-symbol': () => this.goToSymbol.goToSymbolCommand(),
          'elmjutsu:find-usages': () =>
            this.findAndRenameUsages.findUsagesCommand(),