Loading ...
Sorry, an error occurred while loading the content.

More indent questions

Expand Messages
  • Jeremy Cowgar
    Greetings... Everyone is probably getting tired of my weird indent problems, but I have another one... if a = 1 then ..say( a = 1 ); else ..say( a != 1 ); if a
    Message 1 of 11 , Feb 19, 2004
    • 0 Attachment
      Greetings... Everyone is probably getting tired of my weird indent
      problems, but I have another one...

      if a = 1 then
      ..say('a = 1');
      else
      ..say('a != 1');


      if a = 1 then
      ..begin
      ....say('a = 1');
      ..end;
      else
      ..say('a != 1');

      if a = 1 then
      ..say('a = 1');
      else
      ..begin
      ....say('a != 1');
      ..end;

      All of those are valid. What I don't know how to do is in the first example,
      indent the next line only. I can see where the "if" would indent 2, N, and
      the "else" would indent -2 "s" to make the first part work, but from
      then on, the indent will be in 2 characters because it never quit.

      Thanks,

      Jeremy
    • Jon Green
      ... I think you could use Steves new x and t modes and run multiple indent schemes. This would then allow you to drop out following a ; . These are very
      Message 2 of 11 , Feb 19, 2004
      • 0 Attachment
        Jeremy Cowgar wrote:

        > Greetings... Everyone is probably getting tired of my weird indent
        > problems, but I have another one...
        >
        > if a = 1 then
        > ..say('a = 1');
        > else
        > ..say('a != 1');
        >
        >
        > if a = 1 then
        > ..begin
        > ....say('a = 1');
        > ..end;
        > else
        > ..say('a != 1');
        >
        > if a = 1 then
        > ..say('a = 1');
        > else
        > ..begin
        > ....say('a != 1');
        > ..end;
        >
        > All of those are valid. What I don't know how to do is in the first example,
        > indent the next line only. I can see where the "if" would indent 2, N, and
        > the "else" would indent -2 "s" to make the first part work, but from
        > then on, the indent will be in 2 characters because it never quit.
        >
        > Thanks,
        >
        > Jeremy
        >

        I think you could use Steves new "x" and "t" modes
        and run multiple indent schemes. This would then allow
        you to drop out following a ';'. These are very
        new so nobody has really used then outside of
        inserting alternate schemes, but I think they could
        also be applicable in this case.

        See "hkxml.emf" and be a pioneer ! If you get
        it to work then post back the answer - would
        be interested to see how you applied it.

        Jon.
      • Jeremy Cowgar
        ... Hum. The problem I see with that is much duplication, for instance: if a = 1 then ..begin ....if b = 1 then ......say( a=1,b=1 ); ....else .....begin
        Message 3 of 11 , Feb 19, 2004
        • 0 Attachment
          Quoting Jon Green <jnaught@...>:
          > I think you could use Steves new "x" and "t" modes
          > and run multiple indent schemes. This would then allow
          > you to drop out following a ';'. These are very
          > new so nobody has really used then outside of
          > inserting alternate schemes, but I think they could
          > also be applicable in this case.
          >
          > See "hkxml.emf" and be a pioneer ! If you get
          > it to work then post back the answer - would
          > be interested to see how you applied it.

          Hum. The problem I see with that is much duplication, for instance:

          if a = 1 then
          ..begin
          ....if b = 1 then
          ......say('a=1,b=1');
          ....else
          .....begin
          ......for c = 1 to 10 do
          ........begin
          ..........say('I''m running out of ideas of things to say');
          ..........if c = 5 then
          ............say('c = 5, we are half way done');
          ........end;
          .....end;
          ..end;

          I originally thought, ok... when we hit a begin, we will enter a diff mode,
          but that's not making sense either. We can't hit another mode once we go
          into an if either because the same problem exists with many different
          constructs, do, while, for, if, case, procedure, function, etc...

          Here's another one:

          const
          ..a = 10;

          var
          ..name : string;
          ..age : integer;

          begin
          ..do_something();
          end;


          the const/var I could see being a diff indent... a blank line indents -2,
          but then again, you can have something like:

          type
          ..a = array[1..10] of integer;
          ..TObj = object
          ....public
          ......procedure SayHi();
          ....private
          ......whats_up();
          ....end;

          it's rather complex, but that would need a indent -2 on a blank line also.
          Maybe it's just too complex to work in the indent scheme.

          Jeremy
        • Jeremy Cowgar
          I am trying to write a mode for the Josl programming language, http://www.josl.org I can get everything to indent, i.e. is-person? if Hello, Person! println
          Message 4 of 11 , Apr 12, 2010
          • 0 Attachment
            I am trying to write a mode for the Josl programming language,
            http://www.josl.org

            I can get everything to indent, i.e.

            is-person? if
            "Hello, Person!" println
            end

            except for the new words...

            say-hello
            "Hello" println

            main
            say-hello
            say-hello
            10 times
            say-hello
            next

            So, if a word starts in column 1, then it's a new top level word. That
            top level word's definition continues until a new top level word begins.
            Now, in practical use, you separate two top level words by two blank
            lines, so that could be used to detect the end of a word for indentation.

            Does anyone have an idea on how this can be accomplished?

            Jeremy
          • Jeremy Cowgar
            No input on this? Just to make sure formatting was correct, period = space say-hello .... Hello println say-hello-10-times ....10 times ........say-hello
            Message 5 of 11 , Apr 20, 2010
            • 0 Attachment
              No input on this? Just to make sure formatting was correct, period = space

              say-hello
              ...."Hello" println

              say-hello-10-times
              ....10 times
              ........say-hello
              ....next

              main
              ....say-hello-10-times

              I can make the things such as 10 times ... say-hello indent properly,
              but how do I make things such as say-hello, then the next line (and all
              subsequent lines) be indented?

              Jeremy

              On 4/12/2010 1:34 PM, Jeremy Cowgar wrote:
              > I am trying to write a mode for the Josl programming language,
              > http://www.josl.org
              >
              > I can get everything to indent, i.e.
              >
              > is-person? if
              > "Hello, Person!" println
              > end
              >
              > except for the new words...
              >
              > say-hello
              > "Hello" println
              >
              > main
              > say-hello
              > say-hello
              > 10 times
              > say-hello
              > next
              >
              > So, if a word starts in column 1, then it's a new top level word. That
              > top level word's definition continues until a new top level word
              > begins. Now, in practical use, you separate two top level words by two
              > blank lines, so that could be used to detect the end of a word for
              > indentation.
              >
              > Does anyone have an idea on how this can be accomplished?
              >
              > Jeremy
              >
            • Jon Green
              ... Hi Jeremy, Sorry I have not had a lot of time and to help you then we have to actually write a complete template and find some examples. After looking at
              Message 6 of 11 , Apr 20, 2010
              • 0 Attachment
                Jeremy Cowgar wrote:
                > No input on this? Just to make sure formatting was correct, period = space
                >
                > say-hello
                > ...."Hello" println
                >
                > say-hello-10-times
                > ....10 times
                > ........say-hello
                > ....next
                >
                > main
                > ....say-hello-10-times
                >
                > I can make the things such as 10 times ... say-hello indent properly,
                > but how do I make things such as say-hello, then the next line (and all
                > subsequent lines) be indented?
                >
                > Jeremy

                Hi Jeremy,

                Sorry I have not had a lot of time and to help you then we have to actually
                write a complete template and find some examples.

                After looking at the examples on the web page then I am struggling because
                there is no clear anchor in the syntax to determine when the indent is supposed
                to end.

                Anyway I had a play around and have so far come up with nothing that works
                every case of your examples and the document on josl. When I look at your
                example below I am wondering how you got the indent working at all?

                My implementation is so far this:

                !if &sin "d" .fhook-josl.setup
                0 indent .hilight.josl 0 10
                indent .hilight.josl u "^\\w+" -t t
                indent .hilight.josl n "if" t
                ; indent .hilight.josl n "is" t
                ; indent .hilight.josl n "do" t
                indent .hilight.josl s "else" -t
                indent .hilight.josl o "end" -t
                ; indent .hilight.josl o "until" -t
                ; indent .hilight.josl n "begin" t
                indent .hilight.josl e "\"" "\"" "\\"
                indent .hilight.josl i "#"
                !endif

                And I am struggling.


                Regards
                Jon.



                >
                > On 4/12/2010 1:34 PM, Jeremy Cowgar wrote:
                >> I am trying to write a mode for the Josl programming language,
                >> http://www.josl.org
                >>
                >> I can get everything to indent, i.e.
                >>
                >> is-person? if
                >> "Hello, Person!" println
                >> end
                >>
                >> except for the new words...
                >>
                >> say-hello
                >> "Hello" println
                >>
                >> main
                >> say-hello
                >> say-hello
                >> 10 times
                >> say-hello
                >> next
                >>
                >> So, if a word starts in column 1, then it's a new top level word. That
                >> top level word's definition continues until a new top level word
                >> begins. Now, in practical use, you separate two top level words by two
                >> blank lines, so that could be used to detect the end of a word for
                >> indentation.
                >>
                >> Does anyone have an idea on how this can be accomplished?
                >>
                >> Jeremy
                >>
                >
                >
                >
                > ------------------------------------
                >
                > __________________________________________________________________________
                >
                > This is an unmoderated list, but new members are moderated to ensure that there are no spam users. JASSPA is not responsible for the content of
                > any material posted to this list.
                >
                > To un-subscribe, send a mail message to
                >
                > mailto:jasspa-unsubscribe@yahoogroups.com
                >
                > or visit http://groups.yahoo.com/group/jasspa and
                > modify your account settings manually.
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
              • Jon Green
                ... Actually this line works better for keeping the first 0 column line indent. You must start in the margin but once it is there then it sticks irrespective
                Message 7 of 11 , Apr 20, 2010
                • 0 Attachment
                  Jon Green wrote:
                  > Jeremy Cowgar wrote:
                  >> No input on this? Just to make sure formatting was correct, period = space
                  >>
                  >> say-hello
                  >> ...."Hello" println
                  >>
                  >> say-hello-10-times
                  >> ....10 times
                  >> ........say-hello
                  >> ....next
                  >>
                  >> main
                  >> ....say-hello-10-times
                  >>
                  >> I can make the things such as 10 times ... say-hello indent properly,
                  >> but how do I make things such as say-hello, then the next line (and all
                  >> subsequent lines) be indented?
                  >>
                  >> Jeremy
                  >
                  > Hi Jeremy,
                  >
                  > Sorry I have not had a lot of time and to help you then we have to actually
                  > write a complete template and find some examples.
                  >
                  > After looking at the examples on the web page then I am struggling because
                  > there is no clear anchor in the syntax to determine when the indent is supposed
                  > to end.
                  >
                  > Anyway I had a play around and have so far come up with nothing that works
                  > every case of your examples and the document on josl. When I look at your
                  > example below I am wondering how you got the indent working at all?
                  >
                  > My implementation is so far this:
                  >
                  > !if &sin "d" .fhook-josl.setup
                  > 0 indent .hilight.josl 0 10
                  > indent .hilight.josl u "^\\w+" -t t
                  > indent .hilight.josl n "if" t
                  > ; indent .hilight.josl n "is" t
                  > ; indent .hilight.josl n "do" t
                  > indent .hilight.josl s "else" -t
                  > indent .hilight.josl o "end" -t
                  > ; indent .hilight.josl o "until" -t
                  > ; indent .hilight.josl n "begin" t
                  > indent .hilight.josl e "\"" "\"" "\\"
                  > indent .hilight.josl i "#"
                  > !endif
                  >
                  > And I am struggling.
                  >
                  >
                  > Regards
                  > Jon.
                  >


                  Actually this line works better for keeping the first 0 column line indent. You
                  must start in the margin but once it is there then it sticks irrespective of
                  the indent in the previous block (assuming it is not more than 5 - could put 9
                  here).

                  indent .hilight.josl u "^\\w+" -5t t

                  Noted for the following:

                  is-person? if
                  "Hello, Person!" println
                  end

                  Then I think the following is more correct because the 'if' causes another
                  indent and the 'end' is indented in the correct place.

                  is-person? if
                  "Hello, Person!" println
                  end

                  except for the new words...

                  say-hello
                  "Hello" println


                  Regards
                  Jon.
                • Jeremy Cowgar
                  Jon, I am leaving for the evening but will look at the code in tonight. I did not intend on anyone having to write the indentation themselves, I was simply
                  Message 8 of 11 , Apr 20, 2010
                  • 0 Attachment
                    Jon,

                    I am leaving for the evening but will look at the code in tonight. I did not intend on anyone having to write the indentation themselves, I was simply looking for guidance :-)...

                    As for the rule... The rule for Josl is that a new word begins when a non-space/non-comment character is in column 1. Josl has very minimal syntax requirements by design. The words (function in other languages) continues until the next one begins. So...

                    hello-world 10 times
                    ........"Hello" println
                    ....next

                    goodbye-word 10 times
                    ........"Hello" println
                    ....next

                    main hello-world
                    ....goodbye-world

                    That defines 3 words, the "main" word being the entry point. In Josl, the only separator is a space. There is a special syntax for strings, "... content ... ". Other than that, anything is valid in a word name, for example:

                    [10-{times},do-a()] 10 times a next

                    defines a new word that is perfectly valid and would be called as "[10-{times},do-a()]". I understand this complicates the indentation in any editor. I am thankful that you wrote some code but did not mean to place that burden on you.

                    Thanks, will get back with you later this evening.

                    Jeremy

                    On 4/20/2010 4:13 PM, Jon Green wrote:
                     

                    Jon Green wrote:
                    > Jeremy Cowgar wrote:
                    >> No input on this? Just to make sure formatting was correct, period = space
                    >>
                    >> say-hello
                    >> ...."Hello" println
                    >>
                    >> say-hello-10- times
                    >> ....10 times
                    >> ........say- hello
                    >> ....next
                    >>
                    >> main
                    >> ....say-hello- 10-times
                    >>
                    >> I can make the things such as 10 times ... say-hello indent properly,
                    >> but how do I make things such as say-hello, then the next line (and all
                    >> subsequent lines) be indented?
                    >>
                    >> Jeremy
                    >
                    > Hi Jeremy,
                    >
                    > Sorry I have not had a lot of time and to help you then we have to actually
                    > write a complete template and find some examples.
                    >
                    > After looking at the examples on the web page then I am struggling because
                    > there is no clear anchor in the syntax to determine when the indent is supposed
                    > to end.
                    >
                    > Anyway I had a play around and have so far come up with nothing that works
                    > every case of your examples and the document on josl. When I look at your
                    > example below I am wondering how you got the indent working at all?
                    >
                    > My implementation is so far this:
                    >
                    > !if &sin "d" .fhook-josl. setup
                    > 0 indent .hilight.josl 0 10
                    > indent .hilight.josl u "^\\w+" -t t
                    > indent .hilight.josl n "if" t
                    > ; indent .hilight.josl n "is" t
                    > ; indent .hilight.josl n "do" t
                    > indent .hilight.josl s "else" -t
                    > indent .hilight.josl o "end" -t
                    > ; indent .hilight.josl o "until" -t
                    > ; indent .hilight.josl n "begin" t
                    > indent .hilight.josl e "\"" "\"" "\\"
                    > indent .hilight.josl i "#"
                    > !endif
                    >
                    > And I am struggling.
                    >
                    >
                    > Regards
                    > Jon.
                    >

                    Actually this line works better for keeping the first 0 column line indent. You
                    must start in the margin but once it is there then it sticks irrespective of
                    the indent in the previous block (assuming it is not more than 5 - could put 9
                    here).

                    indent .hilight.josl u "^\\w+" -5t t

                    Noted for the following:

                    is-person? if
                    "Hello, Person!" println
                    end

                    Then I think the following is more correct because the 'if' causes another
                    indent and the 'end' is indented in the correct place.

                    is-person? if
                    "Hello, Person!" println
                    end

                    except for the new words...

                    say-hello
                    "Hello" println

                    Regards
                    Jon.


                  • Jeremy Cowgar
                    ... Oh... My indentation was only working for the constructs which was pretty easy, obviously: TRUE if .... Hello println end I did not get anything working
                    Message 9 of 11 , Apr 20, 2010
                    • 0 Attachment
                      On 4/20/2010 4:00 PM, Jon Green wrote:  

                      Hi Jeremy,

                      Sorry I have not had a lot of time and to help you then we have to actually
                      write a complete template and find some examples.

                      After looking at the examples on the web page then I am struggling because
                      there is no clear anchor in the syntax to determine when the indent is supposed
                      to end.

                      Anyway I had a play around and have so far come up with nothing that works
                      every case of your examples and the document on josl. When I look at your
                      example below I am wondering how you got the indent working at all?


                      Oh... My indentation was only working for the constructs which was pretty easy, obviously:

                      TRUE if
                      ...."Hello" println
                      end

                      I did not get anything working for indenting a word definition properly. So, for me things would indent like this:

                      main
                      TRUE if
                      ...."Hello" println
                      end

                      which is wrong in Josl, as *any* non-space, non-comment in column 1 defines a new word (function). The above should look like:

                      main
                      ....TRUE if
                      ........"Hello" println
                      ....end

                      Jeremy

                    • Jon Green
                      ... OK, seems that I have solved this problem then with my abuse of the indent u which should sort this out as it will cause an indent to start on the next
                      Message 10 of 11 , Apr 20, 2010
                      • 0 Attachment
                        Jeremy Cowgar wrote:
                        > On 4/20/2010 4:00 PM, Jon Green wrote:
                        >>
                        >> Hi Jeremy,
                        >>
                        >> Sorry I have not had a lot of time and to help you then we have to
                        >> actually
                        >> write a complete template and find some examples.
                        >>
                        >> After looking at the examples on the web page then I am struggling
                        >> because
                        >> there is no clear anchor in the syntax to determine when the indent is
                        >> supposed
                        >> to end.
                        >>
                        >> Anyway I had a play around and have so far come up with nothing that
                        >> works
                        >> every case of your examples and the document on josl. When I look at your
                        >> example below I am wondering how you got the indent working at all?
                        >>
                        >
                        > Oh... My indentation was only working for the constructs which was
                        > pretty easy, obviously:
                        >
                        > TRUE if
                        > ...."Hello" println
                        > end
                        >
                        > I did not get anything working for indenting a word definition properly.
                        > So, for me things would indent like this:
                        >
                        > main
                        > TRUE if
                        > ...."Hello" println
                        > end
                        >
                        > which is wrong in Josl, as *any* non-space, non-comment in column 1
                        > defines a new word (function). The above should look like:
                        >
                        > main
                        > ....TRUE if
                        > ........"Hello" println
                        > ....end
                        >

                        OK, seems that I have solved this problem then with my abuse of the 'indent
                        "u"' which should sort this out as it will cause an indent to start on the next
                        line.

                        Best of luck.

                        Regards
                        Jon.

                        > Jeremy
                        >
                      • Jeremy Cowgar
                        Jon, Thank you. It seems to be working great. What I have thus far is: http://fossil.josl.org/finfo?name=support/editors/microemacs/hkjosl.emf I m very happy
                        Message 11 of 11 , Apr 20, 2010
                        • 0 Attachment
                          Jon,

                          Thank you. It seems to be working great. What I have thus far is:

                          http://fossil.josl.org/finfo?name=support/editors/microemacs/hkjosl.emf

                          I'm very happy to have a working mode now for MicroEmacs. It's just so
                          nice to have indentation, the tools pane (displaying buffer items). The
                          ease of creating these modes (albeit indentation sometimes gets tricky)
                          in MicroEmacs is just awesome.

                          Jeremy Cowgar
                        Your message has been successfully submitted and would be delivered to recipients shortly.