How can Smalltalk codes in Squeak be automatically indented ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How can Smalltalk codes in Squeak be automatically indented ?

RedTigerFish
I was wondering if Squeak has some automatic  indentation function to make
codes in disorder become clean and well-indented in a flash, just like what
we can do in VIM and MS VISUAL STUDIO.



-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
Reply | Threaded
Open this post in threaded view
|

Re: How can Smalltalk codes in Squeak be automatically indented ?

David Mitchell-10
Away from my computer, but search for prettyPrint.
On Tue, Nov 7, 2017 at 2:20 AM RedTigerFish <[hidden email]> wrote:
I was wondering if Squeak has some automatic  indentation function to make
codes in disorder become clean and well-indented in a flash, just like what
we can do in VIM and MS VISUAL STUDIO.



-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How can Smalltalk codes in Squeak be automatically indented ?

RedTigerFish
I  choose  the block of codes which I want indented > right click > more >
pretty print.

Nothing happens. Why?



-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
Reply | Threaded
Open this post in threaded view
|

Re: How can Smalltalk codes in Squeak be automatically indented ?

Chris Muller-3
You don't need to select the code you wish to format, it formats the
entire method.

If it is already formatted, pretty print it will appear to have no
effect other than making the method dirty (changed).

Not sure what version of Squeak you're using, but there is also a
hot-key which invokes the pretty print function in the code pane:
Shift+Command+S


On Tue, Nov 7, 2017 at 4:01 PM, RedTigerFish <[hidden email]> wrote:

> I  choose  the block of codes which I want indented > right click > more >
> pretty print.
>
> Nothing happens. Why?
>
>
>
> -----
> Dig, dig where you are,
> Down below's well.
> Let those that walk in darkness shout,
> Down below's hell.
> --
> Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How can Smalltalk codes in Squeak be automatically indented ?

RedTigerFish
This post was updated on .
*1 to: 9 do: [ :i |
    1 to: i do: [ :j |
        Transcript
            show: ('{1} * {2} = {3}' format: {j. i. j * i});
            show: ' '
    ].
    Transcript show: ' '; cr.
].*

The above is well-indented codes. Then I intentionally add or reduce a few spaces, like
this
*1 to: 9 do: [ :i |
             1 to: i do: [ :j |
    Transcript
                 show: ('{1} * {2} = {3} ' format: {j. i. j * i});
                    show: ' '
    ].
            Transcript show: ' '; cr.
].*


Then I use pretty print or pretty print with color, nothing happens.

I recorded a video to illustrate my issue.

 <https://youtu.be/cB0N3L1Ou6w> *Video Link*

I do not understand why "pretty print" does not indent anything.



-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
Reply | Threaded
Open this post in threaded view
|

Re: How can Smalltalk codes in Squeak be automatically indented ?

David T. Lewis
On Thu, Nov 09, 2017 at 11:21:35PM -0700, RedTigerFish wrote:

> *1 to: 9 do: [ :i |
>     1 to: i do: [ :j |
>         Transcript
>             show: ('{1} * {2} = {3}' format: {j. i. j * i});
>             show: ' '
>     ].
>     Transcript show: ' '; cr.
> ].*
>
> The above is well-indented codes. Then I intentionally add more spaces, like
> this
> *1 to: 9 do: [ :i |
>              1 to: i do: [ :j |
>     Transcript
>                  show: ('{1} * {2} = {3} ' format: {j. i. j * i});
>                     show: ' '
>     ].
>             Transcript show: ' '; cr.
> ].*
>
>
> Then I use pretty print or pretty print with color, nothing happens.
>
> I recorded a video to illustrate my issue.
>
>  <https://youtu.be/cB0N3L1Ou6w> *Video Link*
>
> I do not understand why "pretty print" does not indent anything.
>

Oh, I see now, the video makes your question clear :-)

You are working in a workspace, and the menu option "pretty print" is
doing nothing for your selected code in the workspace.

Indeed, this does seem like a bug, because if pretty printing does not
work in a workspace selection, we should not be presenting the option
in a menu.

I do not know if it would be a good idea to have pretty print for
workspace selections (it is not something that I would think to use),
but either way the menu options should agree with the actual behavior.

Dave
 
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners