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

Re: [jasspa] java indent and highligting

Expand Messages
  • Jon Green
    ... That was quick! - Thanks Bryan Jon.
    Message 1 of 29 , Oct 4, 2006
    • 0 Attachment
      Bryan Schofield wrote:
      > crap... I pasted in a line accidentally...
      > delete the following:
      >
      > 0 indent .indent.java-enum 1 20
      >

      That was quick! - Thanks Bryan
      Jon.
    • Jon Green
      ... Would you want to add this as well? Jon. ; fix throws indent at start of line, typically a statement ; continuation. indent .indent.java s ^ s*throws s
      Message 2 of 29 , Oct 4, 2006
      • 0 Attachment
        Bryan Schofield wrote:
        > crap... I pasted in a line accidentally...
        > delete the following:
        >
        > 0 indent .indent.java-enum 1 20
        >

        Would you want to add this as well?
        Jon.

        ; fix throws indent at start of line, typically a statement
        ; continuation.
        indent .indent.java s "^\\s*throws\\s" t
      • Jon Green
        ... A few more to add to that maybe? ; fix throws/implements/extends indent at start of line, typically a ; statement continuation. indent .indent.java s
        Message 3 of 29 , Oct 4, 2006
        • 0 Attachment
          Jon Green wrote:
          > Bryan Schofield wrote:
          >> crap... I pasted in a line accidentally...
          >> delete the following:
          >>
          >> 0 indent .indent.java-enum 1 20
          >>
          >
          > Would you want to add this as well?
          > Jon.
          >
          > ; fix throws indent at start of line, typically a statement
          > ; continuation.
          > indent .indent.java s "^\\s*throws\\s" t
          >

          A few more to add to that maybe?

          ; fix throws/implements/extends indent at start of line, typically a
          ; statement continuation.
          indent .indent.java s "^\\s*throws\\s" t
          indent .indent.java s "^\\s*implements\\s" t
          indent .indent.java s "^\\s*extends\\s" t
        • Bryan Schofield
          I took a look at the java hilighting. It was missing some java keywords and it had a bunch of c keywords that don t really apply. Below is a suggestion for
          Message 4 of 29 , Oct 5, 2006
          • 0 Attachment
            I took a look at the java hilighting. It was missing some java
            keywords and it had a bunch of c keywords that don't really apply.
            Below is a suggestion for hilighting. In hkjava.emf if you replace
            from around line 60
            hilight .hilight.java 0x12 "import" .scheme.prepro
            to around line 131
            hilight .hilight.java 1 "virtual" .scheme.type



            ; annotations
            hilight .hilight.java 4 "@" "\\}\\W" "" .scheme.prepro
            ; constants: A_CONSTANT_VARAIBLE
            hilight .hilight.java 1 "[A-Z_]+" .scheme.constant
            ; class names: AJavaClassName
            hilight .hilight.java 1 "[A-Z]+[a-z]+\\w*" .scheme.type

            ; Java keywords
            ; The following conventions are used:
            ; .scheme.type primitive types
            ; .scheme.operator flow control keywords
            ; .scheme.prepro package declaration and imports
            ; .scheme.error reserved keywords that have not been implemented
            ; .scheme.keyword other java keywords that are not covered above
            hilight .hilight.java 1 "abstract" .scheme.keyword
            hilight .hilight.java 1 "assert" .scheme.keyword
            hilight .hilight.java 1 "boolean" .scheme.type
            hilight .hilight.java 1 "break" .scheme.operator
            hilight .hilight.java 1 "byte" .scheme.type
            hilight .hilight.java 1 "case" .scheme.operator
            hilight .hilight.java 1 "catch" .scheme.operator
            hilight .hilight.java 1 "char" .scheme.type
            hilight .hilight.java 1 "class" .scheme.keyword
            hilight .hilight.java 1 "const" .scheme.error ; reserved but
            not implemented in java
            hilight .hilight.java 1 "continue" .scheme.operator
            hilight .hilight.java 1 "default" .scheme.operator
            hilight .hilight.java 1 "do" .scheme.operator
            hilight .hilight.java 1 "double" .scheme.type
            hilight .hilight.java 1 "else" .scheme.operator
            hilight .hilight.java 1 "enum" .scheme.keyword
            hilight .hilight.java 1 "extends" .scheme.keyword
            hilight .hilight.java 1 "false" .scheme.constant
            hilight .hilight.java 1 "final" .scheme.keyword
            hilight .hilight.java 1 "finally" .scheme.operator
            hilight .hilight.java 1 "float" .scheme.type
            hilight .hilight.java 1 "for" .scheme.operator
            hilight .hilight.java 1 "goto" .scheme.error ; reserved but
            not implemented
            hilight .hilight.java 1 "if" .scheme.operator
            hilight .hilight.java 1 "implements" .scheme.keyword
            hilight .hilight.java 0x12 "import" .scheme.prepro
            hilight .hilight.java 1 "instanceof" .scheme.keyword
            hilight .hilight.java 1 "int" .scheme.type
            hilight .hilight.java 1 "interface" .scheme.keyword
            hilight .hilight.java 1 "long" .scheme.type
            hilight .hilight.java 1 "native" .scheme.keyword
            hilight .hilight.java 1 "new" .scheme.keyword
            hilight .hilight.java 1 "null" .scheme.constant
            hilight .hilight.java 0x12 "package" .scheme.prepro
            hilight .hilight.java 1 "private" .scheme.keyword
            hilight .hilight.java 1 "protected" .scheme.keyword
            hilight .hilight.java 1 "public" .scheme.keyword
            hilight .hilight.java 1 "return" .scheme.keyword
            hilight .hilight.java 1 "short" .scheme.type
            hilight .hilight.java 1 "static" .scheme.keyword
            hilight .hilight.java 1 "strictfp" .scheme.keyword
            hilight .hilight.java 1 "super" .scheme.keyword
            hilight .hilight.java 1 "switch" .scheme.operator
            hilight .hilight.java 1 "synchronized" .scheme.keyword
            hilight .hilight.java 1 "this" .scheme.keyword
            hilight .hilight.java 1 "throw" .scheme.keyword
            hilight .hilight.java 1 "throws" .scheme.keyword
            hilight .hilight.java 1 "transient" .scheme.keyword
            hilight .hilight.java 1 "true" .scheme.constant
            hilight .hilight.java 1 "try" .scheme.operator
            hilight .hilight.java 1 "void" .scheme.keyword
            hilight .hilight.java 1 "volatile" .scheme.keyword
            hilight .hilight.java 1 "while " .scheme.operator
          • Jon Green
            ... Thanks Bryan, I have re-worked hkjava.emf with all of the suggestions received to date. If you install this then delete the myjava.emf file (or rename to
            Message 5 of 29 , Oct 5, 2006
            • 0 Attachment
              Bryan Schofield wrote:
              > I took a look at the java hilighting. It was missing some java
              > keywords and it had a bunch of c keywords that don't really apply.
              > Below is a suggestion for hilighting. In hkjava.emf if you replace

              Thanks Bryan,

              I have re-worked hkjava.emf with all of the suggestions received to
              date. If you install this then delete the myjava.emf file (or rename to
              myjava-1.emf so that it is not picked up) and then execute the file (or
              restart the editor).

              This includes the token highlighting as suggested and the indent as
              suggested. The language template includes the new indent method and the
              existing 'C' method. The indent mode may be changed with
              esc-x major-mode-setup.

              I am proposing that this gets shipped with the next release. Is this OK
              with everybody? Does this solve the Java problems that people are
              experiencing?

              Thanks
              Jon.
            • Thomas Hundt
              Hold it. This release is unusable. Basic functionality has been broken: private static final Logger LOG = Logger.getLogger(PeakHourReportRunner.class); now
              Message 6 of 29 , Oct 5, 2006
              • 0 Attachment
                Hold it. This release is unusable.

                Basic functionality has been broken:

                private static final Logger LOG =
                Logger.getLogger(PeakHourReportRunner.class);

                now comes out as

                private static final Logger LOG =
                Logger.getLogger(PeakHourReportRunner.class);

                and if-else statements come out as

                if (something)
                do_something();
                else
                do_something_else();

                (Bryan feels the whole world should have to put in braces, but --
                idealism aside -- I know I'm going to be editing plenty of peoples' code
                without all the braces where he would like them. It IS a legitimate
                Java feature not to have to put in extra braces where they aren't
                necessary, and having the editor properly indent them will allow one to
                find out where one screwed it up, right? I mean that is why we are
                doing this, yes?)

                I'm rather have it work the way it used to, minus any of the new
                "improvements", if basic functionality like this goes out the window.

                Sorry, Jon. It was looking great there for a while, but this is too much.

                Regards,

                -Th


                Jon Green wrote:
                > Bryan Schofield wrote:
                >> I took a look at the java hilighting. It was missing some java
                >> keywords and it had a bunch of c keywords that don't really apply.
                >> Below is a suggestion for hilighting. In hkjava.emf if you replace
                >
                > Thanks Bryan,
                >
                > I have re-worked hkjava.emf with all of the suggestions received to
                > date. If you install this then delete the myjava.emf file (or rename to
                > myjava-1.emf so that it is not picked up) and then execute the file (or
                > restart the editor).
                >
                > This includes the token highlighting as suggested and the indent as
                > suggested. The language template includes the new indent method and the
                > existing 'C' method. The indent mode may be changed with
                > esc-x major-mode-setup.
                >
                > I am proposing that this gets shipped with the next release. Is this OK
                > with everybody? Does this solve the Java problems that people are
                > experiencing?
                >
                > Thanks
                > Jon.


                --
                Thomas Hundt <tom@...> +1-415-867-6698
              • Jon Green
                ... Hi Thomas, Thanks for the info and knee jerk reaction, just what I was looking for. M-x major-mode-setup will allow you to turn on C indentation again
                Message 7 of 29 , Oct 5, 2006
                • 0 Attachment
                  Thomas Hundt wrote:
                  > Hold it. This release is unusable.
                  >
                  > Basic functionality has been broken:
                  >
                  > private static final Logger LOG =
                  > Logger.getLogger(PeakHourReportRunner.class);
                  >
                  > now comes out as
                  >
                  > private static final Logger LOG =
                  > Logger.getLogger(PeakHourReportRunner.class);
                  >
                  > and if-else statements come out as
                  >
                  > if (something)
                  > do_something();
                  > else
                  > do_something_else();
                  >
                  > (Bryan feels the whole world should have to put in braces, but --
                  > idealism aside -- I know I'm going to be editing plenty of peoples' code
                  > without all the braces where he would like them. It IS a legitimate
                  > Java feature not to have to put in extra braces where they aren't
                  > necessary, and having the editor properly indent them will allow one to
                  > find out where one screwed it up, right? I mean that is why we are
                  > doing this, yes?)
                  >
                  > I'm rather have it work the way it used to, minus any of the new
                  > "improvements", if basic functionality like this goes out the window.
                  >
                  > Sorry, Jon. It was looking great there for a while, but this is too much.
                  >
                  > Regards,
                  >
                  > -Th
                  >

                  Hi Thomas,

                  Thanks for the info and knee jerk reaction, just what I was looking for.

                  M-x major-mode-setup

                  will allow you to turn on 'C' indentation again this should restore what
                  you had before. I'll make C mode the default and then leave the other
                  method in for the 'Java pure' people.

                  Regards
                  Jon.
                • Jon Green
                  ... OK, here is the next one! This time the default mode of operation is the built in indentation with the bracket alignment disabled. Note that your history
                  Message 8 of 29 , Oct 5, 2006
                  • 0 Attachment
                    Thomas Hundt wrote:
                    > Hold it. This release is unusable.
                    >
                    > Basic functionality has been broken:
                    >
                    > private static final Logger LOG =
                    > Logger.getLogger(PeakHourReportRunner.class);
                    >
                    > now comes out as
                    >
                    > private static final Logger LOG =
                    > Logger.getLogger(PeakHourReportRunner.class);
                    >
                    > and if-else statements come out as
                    >
                    > if (something)
                    > do_something();
                    > else
                    > do_something_else();
                    >
                    > (Bryan feels the whole world should have to put in braces, but --
                    > idealism aside -- I know I'm going to be editing plenty of peoples' code
                    > without all the braces where he would like them. It IS a legitimate
                    > Java feature not to have to put in extra braces where they aren't
                    > necessary, and having the editor properly indent them will allow one to
                    > find out where one screwed it up, right? I mean that is why we are
                    > doing this, yes?)
                    >
                    > I'm rather have it work the way it used to, minus any of the new
                    > "improvements", if basic functionality like this goes out the window.
                    >
                    > Sorry, Jon. It was looking great there for a while, but this is too much.
                    >
                    > Regards,
                    >
                    > -Th
                    >

                    OK, here is the next one!

                    This time the default mode of operation is the built in indentation with
                    the bracket alignment disabled.

                    Note that your history will likely be retained so you will have to
                    reconfigure the major mode to return to some default using

                    M-x major-mode-setup

                    The defaults are:

                    Brace Hilighting:OFF
                    Enable Bracket Alignment:OFF (Enables old brace alignment)
                    Alternative Indent Mode:OFF (Pure Java mode)

                    I understand that neither method is ideal. With the 'C' type indent then
                    there are issues with "@" statements. These are not present in the
                    Alternative indent - but this then needs to be fully bracketed.

                    Regards
                    Jon.
                  • Bryan Schofield
                    unfortunately, the indent syntax isn t powerful enough to describe the situtations needed. For example... if (true) continuedStatement(); if (true) {
                    Message 9 of 29 , Oct 6, 2006
                    • 0 Attachment
                      unfortunately, the indent syntax isn't powerful enough to describe the
                      situtations needed.

                      For example...

                      if (true)
                      continuedStatement();

                      if (true) {
                      indentedStatement();
                      }

                      if (true)
                      {
                      indentedStatement();
                      }

                      I do not know how to tell indent that the next line is a continuation,
                      unless it is a "{". I can write indent rules to handle the first 2 or
                      the last 2 but not all 3 at the same time.


                      indent .indent.java c "=\\s*$" t

                      handles:

                      private static final Logger LOG =
                      Logger.getLogger(PeakHourReportRunner.class);
                    • jon@jasspa.com
                      ... Hi Bryan, We are aware of the short comings of the indentation. We have yet to come up with a better way of describing the indentation in terms of its
                      Message 10 of 29 , Oct 6, 2006
                      • 0 Attachment
                        > unfortunately, the indent syntax isn't powerful enough to describe the
                        > situtations needed.
                        >
                        > For example...
                        >
                        > if (true)
                        > continuedStatement();
                        >
                        > if (true) {
                        > indentedStatement();
                        > }
                        >
                        > if (true)
                        > {
                        > indentedStatement();
                        > }
                        >
                        > I do not know how to tell indent that the next line is a continuation,
                        > unless it is a "{". I can write indent rules to handle the first 2 or
                        > the last 2 but not all 3 at the same time.
                        >
                        >
                        > indent .indent.java c "=\\s*$" t
                        >
                        > handles:
                        >
                        > private static final Logger LOG =
                        > Logger.getLogger(PeakHourReportRunner.class);
                        >

                        Hi Bryan,

                        We are aware of the short comings of the indentation. We have yet to come
                        up with a better way of describing the indentation in terms of its
                        grammer. At the moment we seem to do reasonably well with very little
                        knowledge of the language in the template. All of the items that you have
                        raised above require a little more information about the syntax in order
                        to make them work properly. This is actually why C is burnt in because it
                        is easier to handle it like this than coming up with all of the correct
                        rules that are programmable.

                        We have considered how we might express this, but so far have not come up
                        with a sufficiently good way of minimally and generically describing the
                        syntax of the target language for indentation.

                        If anybody has any thoughts on how we can do this I would like to hear
                        them because it is not trivial.

                        Anybody looking for a Comp. Sci. project at University????

                        Regards
                        Jon.
                      • Bryan Schofield
                        I see I missed the official release... but the java indentation needs a little something to fix handling of Strings indent .indent.java e indent
                        Message 11 of 29 , Oct 9, 2006
                        • 0 Attachment
                          I see I missed the official release... but the java indentation needs
                          a little something to fix handling of Strings

                          indent .indent.java e "\"" "\"" "\\"
                          indent .indent.java e "\'" "\'" "\\"



                          On 10/6/06, jon@... <jon@...> wrote:
                          > > unfortunately, the indent syntax isn't powerful enough to describe the
                          > > situtations needed.
                          > >
                          > > For example...
                          > >
                          > > if (true)
                          > > continuedStatement();
                          > >
                          > > if (true) {
                          > > indentedStatement();
                          > > }
                          > >
                          > > if (true)
                          > > {
                          > > indentedStatement();
                          > > }
                          > >
                          > > I do not know how to tell indent that the next line is a continuation,
                          > > unless it is a "{". I can write indent rules to handle the first 2 or
                          > > the last 2 but not all 3 at the same time.
                          > >
                          > >
                          > > indent .indent.java c "=\\s*$" t
                          > >
                          > > handles:
                          > >
                          > > private static final Logger LOG =
                          > > Logger.getLogger(PeakHourReportRunner.class);
                          > >
                          >
                          > Hi Bryan,
                          >
                          > We are aware of the short comings of the indentation. We have yet to come
                          > up with a better way of describing the indentation in terms of its
                          > grammer. At the moment we seem to do reasonably well with very little
                          > knowledge of the language in the template. All of the items that you have
                          > raised above require a little more information about the syntax in order
                          > to make them work properly. This is actually why C is burnt in because it
                          > is easier to handle it like this than coming up with all of the correct
                          > rules that are programmable.
                          >
                          > We have considered how we might express this, but so far have not come up
                          > with a sufficiently good way of minimally and generically describing the
                          > syntax of the target language for indentation.
                          >
                          > If anybody has any thoughts on how we can do this I would like to hear
                          > them because it is not trivial.
                          >
                          > Anybody looking for a Comp. Sci. project at University????
                          >
                          > Regards
                          > Jon.
                          >
                          >
                          >
                          > __________________________________________________________________________
                          >
                          > This is an unmoderated list. JASSPA is not responsible for the content of
                          > any material posted to this list.
                          >
                          > To unsubscribe, 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
                          >
                          >
                          >
                          >
                          >
                          >
                          >
                          >
                          >
                          >
                        • Bryan Schofield
                          Perhaps you add in a hook to allow a function to specified as the last argument in an indent rule. This function would return an indicator on whether the
                          Message 12 of 29 , Oct 9, 2006
                          • 0 Attachment
                            Perhaps you add in a hook to allow a function to specified as the last
                            argument in an indent rule. This function would return an indicator on
                            whether the indent rule should actually be applied. The function could
                            be passed the line number and do whatever language-specific analysis
                            is required.

                            indent .indent.java c "if.*)\\s*$" t java-check-if

                            define-macro java-check-if
                            ; @1 = line number
                            ; ...
                            set-variable $result true
                            !emacro
                          • jon@jasspa.com
                            ... OK Thanks, As it turns out it looks like we need a patch to jst.etf so I can slip this one in as well as they are both macro problems. Fortunately there
                            Message 13 of 29 , Oct 9, 2006
                            • 0 Attachment
                              > I see I missed the official release... but the java indentation needs
                              > a little something to fix handling of Strings
                              >
                              > indent .indent.java e "\"" "\"" "\\"
                              > indent .indent.java e "\'" "\'" "\\"
                              >

                              OK Thanks,

                              As it turns out it looks like we need a patch to jst.etf so I can slip
                              this one in as well as they are both macro problems. Fortunately there are
                              no binary problems at the moment, but does mean that some of the packages
                              have to be re-built.

                              This is why one release per year is more than enough for us! As usual it
                              does look like there are some more sweeping changes in the pipeline that
                              will come fairly soon after the release on the development side however we
                              cannot afford to delay this release any longer because of the amount of
                              time it takes us to prove it is stable.

                              As an aside: In building the 2006 release I was forced back to 20050505 on
                              some platforms where I had not installed 2006 yet and was surprised by
                              some of the features that were missing (e.g. being able to delete
                              directories in the file browser, infact all of the file browser controls).
                              Obviously most users will not be aware of this but we have been using
                              these internally for the last year and miss them when they are not there -
                              hence we really cannot delay this release any more.

                              Regards
                              Jon.
                            • jon@jasspa.com
                              ... I think you are right. I did try and prototype this type of schema about a year ago and got into a real mess because of problems with the macro context
                              Message 14 of 29 , Oct 9, 2006
                              • 0 Attachment
                                > Perhaps you add in a hook to allow a function to specified as the last
                                > argument in an indent rule. This function would return an indicator on
                                > whether the indent rule should actually be applied. The function could
                                > be passed the line number and do whatever language-specific analysis
                                > is required.
                                >
                                > indent .indent.java c "if.*)\\s*$" t java-check-if
                                >
                                > define-macro java-check-if
                                > ; @1 = line number
                                > ; ...
                                > set-variable $result true
                                > !emacro

                                I think you are right.

                                I did try and prototype this type of schema about a year ago and got into
                                a real mess because of problems with the macro context (i.e. you are in a
                                macro that then calls back into native and then want to come out and run a
                                macro again) - anyway I ran out of time doing some other stuff. I do
                                believe that this is the way to go but have not found enough time to
                                follow it through to a conclusion and get it working.

                                The only problem with this type of scheme is if you mess up in your macro
                                the editor will die a horrible death - error recovery is likely to be
                                difficult.

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