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

Re: [jasspa] Re: Diff file hook mode (first try)

Expand Messages
  • Jon Green
    ... The item list is quite easy for patch files and then you can do M-x item-list. Simply add the following after the set-variable .fhook-diff.command-3 ...
    Message 1 of 6 , Oct 20, 2009
    • 0 Attachment
      azynheira wrote:
      > Hi Jon,
      > That was the final ideia yeah :-) - Quite nice.
      > The step further I will probably do is to have in the item list the list of the diffs so one can select any of them via the panel.
      >
      > Thanks,
      > Regards,
      > Pedro

      The item list is quite easy for patch files and then you can do M-x item-list.

      Simply add the following after the

      set-variable .fhook-diff.command-3 ...

      New stuff to add:

      ; setup item-list
      set-variable .fhook-diff.item-list-s1 "^diff\\(\\s+-[^\\s]*\\)*\\s*\\([^\\s]*\\)"
      set-variable .fhook-diff.item-list-r1 "File \ecB\\2\ecA"
      set-variable .fhook-diff.item-list-s2 "^@@\\s+\\(.*\\)\\s+@@$"
      set-variable .fhook-diff.item-list-r2 "Diff \ecB\\1\ecA"

      This is not quite right for normal diff files, but works for patch files.

      I was really surprised that the \\2 worked for item 1 because of the multiple groups, but it seems to do the job when multiple parameters are present. All credit to Steve for
      getting this right.

      Regards
      Jon.


      >
      >
      > --- In jasspa@yahoogroups.com, Jon Green <jon@...> wrote:
      >> Gomes, Pedro (NSN - PT/Amadora) wrote:
      >>> Hi All,
      >>> Please see attached a first version of a hook file for .diff files. I'm
      >>> distributing to you first since I dont know if you want wild hacked
      >>> material rigth on the mailing list :-)
      >>>
      >>> Regards,
      >>>
      >>> Pedro
      >>>
      >>> Add this to user.emf (maybe a regexp for the first line would be nice
      >>> too!)
      >>> add-file-hook ".diff" fhook-diff
      >>> add-file-hook ".patch" fhook-diff
      >>> <<hkdiff.emf>>
      >>>
      >> Hi Pedro,
      >>
      >> There is already a hkdiff.emf which handles diff files.
      >>
      >> After looking at your script I have a feeling that you are talking about patch
      >> files only rather than a straight forward diff output (i.e. the kind when you
      >> do a M-x diff-changes)
      >>
      >> So patch files are the kind made by the command (performed on the Me source
      >> bundle):
      >>
      >> % gdiff -Naur me090909 me091011 > patch_file.patch
      >>
      >> Which outputs something like:
      >>
      >> diff -Naur me090909/src/eval.c me091011/src/eval.c
      >> --- me090909/src/eval.c 2009-09-12 12:16:46.000000000 +0100
      >> +++ me091011/src/eval.c 2009-10-12 08:44:52.000000000 +0100
      >> @@ -2426,11 +2426,13 @@
      >> else
      >> cmpIFunc = meStrnicmp ;
      >>
      >> - do
      >> + for(;;)
      >> {
      >> ii = cmpIFunc(arg2,ss,mlen) ;
      >> if(!ii)
      >> {
      >> + if((dlen+rlen) >= meBUF_SIZE_MAX)
      >> + break ;
      >> meStrcpy(evalResult+dlen,arg3) ;
      >> dlen += rlen ;
      >> ss += mlen ;
      >> @@ -2439,6 +2441,8 @@
      >> break ;
      >> if(ii || (mlen == 0))
      >> {
      >> + if(dlen >= meBUF_SIZE_MAX-2)
      >> + break ;
      >> ss++ ;
      >> if(cc == meCHAR_LEADER)
      >> {
      >> @@ -2447,7 +2451,7 @@
      >> }
      >> evalResult[dlen++] = cc ;
      >> }
      >> - } while(dlen+rlen < meBUF_SIZE_MAX) ;
      >> + }
      >> evalResult[dlen] = '\0' ;
      >> return evalResult ;
      >> }
      >> diff -Naur me090909/src/evers.h me091011/src/evers.h
      >> --- me090909/src/evers.h 2009-09-12 12:16:46.000000000 +0100
      >>
      >> I would suggest that the existing hkdiff.emf should perhaps be extended with
      >> your suggestions. To do this then I think we do not need to add a .patch
      >> extension as some patch files do not have this extension. Instead should use a
      >> content sensitive hook as follows to add to your <user.emf>:
      >>
      >> -1 add-file-hook "^diff " fhook-diff
      >>
      >> Rolling your changes into the supplied hkdiff.emf then my first stab at the changes is as follows:
      >>
      >> >>> FILE START hkdiff.emf
      >> ; -!- emf -!-
      >> ; This is part of the JASSPA MicroEmacs macro files
      >> ; Copyright (C) 2000-2009 JASSPA (www.jasspa.com)
      >> ; See the file me.emf for copying and conditions.
      >> ;
      >> ; Created: Wed Aug 23 2000
      >> ; Synopsis: Hilighting for diff files
      >> ; Authors: Jon Green + Pedro Gomes
      >> ;
      >> ; Notes:
      >> ; This has been extrapolated from the tools.emf file that originally
      >> ; handled the diff utility and associated hilighting.
      >> ;
      >> ; 2009-10-20 Pedro Gomes - Extensions for patch files
      >> ; - Handle patch files i.e. % gdiff -Naur me090909 me091011 > patch_file.patch
      >> ; - Extentions for next/previous difference.
      >> ; - Added support for patch files.
      >> ; - Patch files detected with: -1 add-file-hook "^diff " fhook-diff
      >> ;
      >> define-macro fhook-diff
      >> ; Set up the buffer modes
      >> @# buffer-init "diff"
      >> -1 buffer-mode "time"
      >> !if &band .hilight.flags 0x02
      >> set-variable $buffer-hilight .hilight.diff
      >> !endif
      >> buffer-init-hooks
      >> !emacro
      >>
      >> ; Setup the buffer
      >> set-variable .fhook-diff.name "Differences File"
      >> set-variable .fhook-diff.setup ® "/history/fhook/diff" "Ughpo"
      >> set-variable .fhook-diff.setup-mask "aeghmpo1"
      >> set-variable .fhook-diff.command-0 "|btho||diff-next-change|C-down|\HNext change||"
      >> set-variable .fhook-diff.command-1 "|btho||diff-previous-change|C-up|\HPrevious change||"
      >> set-variable .fhook-diff.command-2 "|btho||diff-next-file|C-right|Next file||"
      >> set-variable .fhook-diff.command-3 "|btho||diff-previous-file|C-left|Previous file||"
      >>
      >> !if ¬ &exi .hilight.diff
      >> set-variable .hilight.diff &pinc .hilight.next 1
      >> !endif
      >>
      >> !if &band .hilight.flags 0x02
      >> 0 hilight .hilight.diff 0 $global-scheme
      >> ; Gnu diff utility, uses --context
      >> hilight .hilight.diff 0x102 "!" .scheme.no1
      >> hilight .hilight.diff 0x102 "+" .scheme.no1
      >> hilight .hilight.diff 0x102 "-" .scheme.no1
      >> ; Regular diff utility. May be a bit too colored !!
      >> hilight .hilight.diff 0x102 "<" .scheme.no2
      >> hilight .hilight.diff 0x102 ">" .scheme.prepro
      >> ; Patch files GNU diff -Naur old new > file.patch
      >> hilight .hilight.diff 0x102 "diff" .scheme.function
      >> hilight .hilight.diff 0x102 "@@" .scheme.keyword
      >> ; Common
      >> hilight .hilight.diff 0x102 "*\\*\\*\\*" .scheme.keyword
      >> hilight .hilight.diff 0x102 "*\\*\\*" .scheme.no2
      >> hilight .hilight.diff 0x102 "--- " .scheme.prepro
      >> hilight .hilight.diff 0x102 "Only" .scheme.comment
      >> hilight .hilight.diff 0x102 "Files" .scheme.comment
      >> !endif
      >> ; Find the next file
      >> 0 define-macro diff-next-file
      >> !if &les @# 0
      >> !if &equ $window-line 1
      >> end-of-buffer
      >> !endif
      >> !elif &seq @wc ""
      >> beginning-of-buffer
      >> !endif
      >> !force search-forward "^diff "
      >> !if ¬ $status
      >> ml-write "[No more files]"
      >> !bell
      >> !abort
      >> !endif
      >> recenter
      >> !emacro
      >> ; Find the previous file
      >> 0 define-macro diff-previous-file
      >> !if &les @# 0
      >> !if &equ $window-line 1
      >> end-of-buffer
      >> !endif
      >> !elif &seq @wc ""
      >> beginning-of-buffer
      >> !endif
      >> !force search-backward "^diff "
      >> !if ¬ $status
      >> ml-write "[No more files]"
      >> !bell
      >> !abort
      >> !endif
      >> recenter
      >> !emacro
      >> ; Find the next change
      >> 0 define-macro diff-next-change
      >> !if &les @# 0
      >> !if &equ $window-line 1
      >> end-of-buffer
      >> !endif
      >> !elif &seq @wc ""
      >> beginning-of-buffer
      >> !endif
      >> !force search-forward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
      >> !if ¬ $status
      >> ml-write "[No more differences]"
      >> !bell
      >> !abort
      >> !endif
      >> recenter
      >> !emacro
      >> ; Find the previous change
      >> 0 define-macro diff-previous-change
      >> !if &les @# 0
      >> !if &equ $window-line 1
      >> end-of-buffer
      >> !endif
      >> !elif &seq @wc ""
      >> beginning-of-buffer
      >> !endif
      >> !force search-backward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
      >> !if ¬ $status
      >> ml-write "[No more differences]"
      >> !bell
      >> !abort
      >> !endif
      >> recenter
      >> !emacro
      >>
      >> buffer-init-fhook "diff"
      >> <<< FILE END hkdiff.emf
      >>
      >> Does this work for you??
      >>
      >> Regards
      >> Jon.
      >>
      >
      >
      >
      >
      > ------------------------------------
      >
      > __________________________________________________________________________
      >
      > 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
      >
      >
      >
      >
    • azynheira
      Hi All, This got just fantastic :-) Thanks a lot, Pedro
      Message 2 of 6 , Oct 20, 2009
      • 0 Attachment
        Hi All,
        This got just fantastic :-)

        Thanks a lot,
        Pedro

        --- In jasspa@yahoogroups.com, Jon Green <jon@...> wrote:
        >
        > azynheira wrote:
        > > Hi Jon,
        > > That was the final ideia yeah :-) - Quite nice.
        > > The step further I will probably do is to have in the item list the list of the diffs so one can select any of them via the panel.
        > >
        > > Thanks,
        > > Regards,
        > > Pedro
        >
        > The item list is quite easy for patch files and then you can do M-x item-list.
        >
        > Simply add the following after the
        >
        > set-variable .fhook-diff.command-3 ...
        >
        > New stuff to add:
        >
        > ; setup item-list
        > set-variable .fhook-diff.item-list-s1 "^diff\\(\\s+-[^\\s]*\\)*\\s*\\([^\\s]*\\)"
        > set-variable .fhook-diff.item-list-r1 "File \ecB\\2\ecA"
        > set-variable .fhook-diff.item-list-s2 "^@@\\s+\\(.*\\)\\s+@@$"
        > set-variable .fhook-diff.item-list-r2 "Diff \ecB\\1\ecA"
        >
        > This is not quite right for normal diff files, but works for patch files.
        >
        > I was really surprised that the \\2 worked for item 1 because of the multiple groups, but it seems to do the job when multiple parameters are present. All credit to Steve for
        > getting this right.
        >
        > Regards
        > Jon.
        >
        >
        > >
        > >
        > > --- In jasspa@yahoogroups.com, Jon Green <jon@> wrote:
        > >> Gomes, Pedro (NSN - PT/Amadora) wrote:
        > >>> Hi All,
        > >>> Please see attached a first version of a hook file for .diff files. I'm
        > >>> distributing to you first since I dont know if you want wild hacked
        > >>> material rigth on the mailing list :-)
        > >>>
        > >>> Regards,
        > >>>
        > >>> Pedro
        > >>>
        > >>> Add this to user.emf (maybe a regexp for the first line would be nice
        > >>> too!)
        > >>> add-file-hook ".diff" fhook-diff
        > >>> add-file-hook ".patch" fhook-diff
        > >>> <<hkdiff.emf>>
        > >>>
        > >> Hi Pedro,
        > >>
        > >> There is already a hkdiff.emf which handles diff files.
        > >>
        > >> After looking at your script I have a feeling that you are talking about patch
        > >> files only rather than a straight forward diff output (i.e. the kind when you
        > >> do a M-x diff-changes)
        > >>
        > >> So patch files are the kind made by the command (performed on the Me source
        > >> bundle):
        > >>
        > >> % gdiff -Naur me090909 me091011 > patch_file.patch
        > >>
        > >> Which outputs something like:
        > >>
        > >> diff -Naur me090909/src/eval.c me091011/src/eval.c
        > >> --- me090909/src/eval.c 2009-09-12 12:16:46.000000000 +0100
        > >> +++ me091011/src/eval.c 2009-10-12 08:44:52.000000000 +0100
        > >> @@ -2426,11 +2426,13 @@
        > >> else
        > >> cmpIFunc = meStrnicmp ;
        > >>
        > >> - do
        > >> + for(;;)
        > >> {
        > >> ii = cmpIFunc(arg2,ss,mlen) ;
        > >> if(!ii)
        > >> {
        > >> + if((dlen+rlen) >= meBUF_SIZE_MAX)
        > >> + break ;
        > >> meStrcpy(evalResult+dlen,arg3) ;
        > >> dlen += rlen ;
        > >> ss += mlen ;
        > >> @@ -2439,6 +2441,8 @@
        > >> break ;
        > >> if(ii || (mlen == 0))
        > >> {
        > >> + if(dlen >= meBUF_SIZE_MAX-2)
        > >> + break ;
        > >> ss++ ;
        > >> if(cc == meCHAR_LEADER)
        > >> {
        > >> @@ -2447,7 +2451,7 @@
        > >> }
        > >> evalResult[dlen++] = cc ;
        > >> }
        > >> - } while(dlen+rlen < meBUF_SIZE_MAX) ;
        > >> + }
        > >> evalResult[dlen] = '\0' ;
        > >> return evalResult ;
        > >> }
        > >> diff -Naur me090909/src/evers.h me091011/src/evers.h
        > >> --- me090909/src/evers.h 2009-09-12 12:16:46.000000000 +0100
        > >>
        > >> I would suggest that the existing hkdiff.emf should perhaps be extended with
        > >> your suggestions. To do this then I think we do not need to add a .patch
        > >> extension as some patch files do not have this extension. Instead should use a
        > >> content sensitive hook as follows to add to your <user.emf>:
        > >>
        > >> -1 add-file-hook "^diff " fhook-diff
        > >>
        > >> Rolling your changes into the supplied hkdiff.emf then my first stab at the changes is as follows:
        > >>
        > >> >>> FILE START hkdiff.emf
        > >> ; -!- emf -!-
        > >> ; This is part of the JASSPA MicroEmacs macro files
        > >> ; Copyright (C) 2000-2009 JASSPA (www.jasspa.com)
        > >> ; See the file me.emf for copying and conditions.
        > >> ;
        > >> ; Created: Wed Aug 23 2000
        > >> ; Synopsis: Hilighting for diff files
        > >> ; Authors: Jon Green + Pedro Gomes
        > >> ;
        > >> ; Notes:
        > >> ; This has been extrapolated from the tools.emf file that originally
        > >> ; handled the diff utility and associated hilighting.
        > >> ;
        > >> ; 2009-10-20 Pedro Gomes - Extensions for patch files
        > >> ; - Handle patch files i.e. % gdiff -Naur me090909 me091011 > patch_file.patch
        > >> ; - Extentions for next/previous difference.
        > >> ; - Added support for patch files.
        > >> ; - Patch files detected with: -1 add-file-hook "^diff " fhook-diff
        > >> ;
        > >> define-macro fhook-diff
        > >> ; Set up the buffer modes
        > >> @# buffer-init "diff"
        > >> -1 buffer-mode "time"
        > >> !if &band .hilight.flags 0x02
        > >> set-variable $buffer-hilight .hilight.diff
        > >> !endif
        > >> buffer-init-hooks
        > >> !emacro
        > >>
        > >> ; Setup the buffer
        > >> set-variable .fhook-diff.name "Differences File"
        > >> set-variable .fhook-diff.setup ® "/history/fhook/diff" "Ughpo"
        > >> set-variable .fhook-diff.setup-mask "aeghmpo1"
        > >> set-variable .fhook-diff.command-0 "|btho||diff-next-change|C-down|\HNext change||"
        > >> set-variable .fhook-diff.command-1 "|btho||diff-previous-change|C-up|\HPrevious change||"
        > >> set-variable .fhook-diff.command-2 "|btho||diff-next-file|C-right|Next file||"
        > >> set-variable .fhook-diff.command-3 "|btho||diff-previous-file|C-left|Previous file||"
        > >>
        > >> !if ¬ &exi .hilight.diff
        > >> set-variable .hilight.diff &pinc .hilight.next 1
        > >> !endif
        > >>
        > >> !if &band .hilight.flags 0x02
        > >> 0 hilight .hilight.diff 0 $global-scheme
        > >> ; Gnu diff utility, uses --context
        > >> hilight .hilight.diff 0x102 "!" .scheme.no1
        > >> hilight .hilight.diff 0x102 "+" .scheme.no1
        > >> hilight .hilight.diff 0x102 "-" .scheme.no1
        > >> ; Regular diff utility. May be a bit too colored !!
        > >> hilight .hilight.diff 0x102 "<" .scheme.no2
        > >> hilight .hilight.diff 0x102 ">" .scheme.prepro
        > >> ; Patch files GNU diff -Naur old new > file.patch
        > >> hilight .hilight.diff 0x102 "diff" .scheme.function
        > >> hilight .hilight.diff 0x102 "@@" .scheme.keyword
        > >> ; Common
        > >> hilight .hilight.diff 0x102 "*\\*\\*\\*" .scheme.keyword
        > >> hilight .hilight.diff 0x102 "*\\*\\*" .scheme.no2
        > >> hilight .hilight.diff 0x102 "--- " .scheme.prepro
        > >> hilight .hilight.diff 0x102 "Only" .scheme.comment
        > >> hilight .hilight.diff 0x102 "Files" .scheme.comment
        > >> !endif
        > >> ; Find the next file
        > >> 0 define-macro diff-next-file
        > >> !if &les @# 0
        > >> !if &equ $window-line 1
        > >> end-of-buffer
        > >> !endif
        > >> !elif &seq @wc ""
        > >> beginning-of-buffer
        > >> !endif
        > >> !force search-forward "^diff "
        > >> !if ¬ $status
        > >> ml-write "[No more files]"
        > >> !bell
        > >> !abort
        > >> !endif
        > >> recenter
        > >> !emacro
        > >> ; Find the previous file
        > >> 0 define-macro diff-previous-file
        > >> !if &les @# 0
        > >> !if &equ $window-line 1
        > >> end-of-buffer
        > >> !endif
        > >> !elif &seq @wc ""
        > >> beginning-of-buffer
        > >> !endif
        > >> !force search-backward "^diff "
        > >> !if ¬ $status
        > >> ml-write "[No more files]"
        > >> !bell
        > >> !abort
        > >> !endif
        > >> recenter
        > >> !emacro
        > >> ; Find the next change
        > >> 0 define-macro diff-next-change
        > >> !if &les @# 0
        > >> !if &equ $window-line 1
        > >> end-of-buffer
        > >> !endif
        > >> !elif &seq @wc ""
        > >> beginning-of-buffer
        > >> !endif
        > >> !force search-forward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
        > >> !if ¬ $status
        > >> ml-write "[No more differences]"
        > >> !bell
        > >> !abort
        > >> !endif
        > >> recenter
        > >> !emacro
        > >> ; Find the previous change
        > >> 0 define-macro diff-previous-change
        > >> !if &les @# 0
        > >> !if &equ $window-line 1
        > >> end-of-buffer
        > >> !endif
        > >> !elif &seq @wc ""
        > >> beginning-of-buffer
        > >> !endif
        > >> !force search-backward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
        > >> !if ¬ $status
        > >> ml-write "[No more differences]"
        > >> !bell
        > >> !abort
        > >> !endif
        > >> recenter
        > >> !emacro
        > >>
        > >> buffer-init-fhook "diff"
        > >> <<< FILE END hkdiff.emf
        > >>
        > >> Does this work for you??
        > >>
        > >> Regards
        > >> Jon.
        > >>
        > >
        > >
        > >
        > >
        > > ------------------------------------
        > >
        > > __________________________________________________________________________
        > >
        > > 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
        ... Hi Pedro, Below is the final version. This fixes the item-list (f6/esc-f6) when running in a normal diff mode (rather than with the patch options). I would
        Message 3 of 6 , Oct 20, 2009
        • 0 Attachment
          azynheira wrote:
          > Hi All,
          > This got just fantastic :-)
          >
          > Thanks a lot,
          > Pedro

          Hi Pedro,

          Below is the final version. This fixes the item-list (f6/esc-f6) when running in a normal diff mode (rather than with the patch options).

          I would also suggest that the M-x diff command in tools.emf should have wrapping disabled by changing the ipipe parameter.

          cd /home/jon/.jasspa/
          gdiff --context --minimal --ignore-space-change --recursive "/home/jon/.jasspa/tools.emf~" "/home/jon/.jasspa/tools.emf"

          *** /home/jon/.jasspa/tools.emf~ 2009-10-20 14:56:33.500554000 +0100
          --- /home/jon/.jasspa/tools.emf 2009-10-20 14:56:38.626295000 +0100
          ***************
          *** 120,126 ****
          set-variable #l1 &rep #l1 "/" "\\"
          set-variable #l1 &xrep #l1 "\\\\$" ""
          !endif
          ! 4 ipipe-shell-command &spr "%s%s \"%s\" \"%s\"" %diff-com &cond &band @# 2 " -r" "" #l0 #l1 "*diff*"
          !force popup-window "*diff*"
          !emacro
          define-macro diff-changes
          --- 120,126 ----
          set-variable #l1 &rep #l1 "/" "\\"
          set-variable #l1 &xrep #l1 "\\\\$" ""
          !endif
          ! 0x204 ipipe-shell-command &spr "%s%s \"%s\" \"%s\"" %diff-com &cond &band @# 2 " -r" "" #l0 #l1 "*diff*"
          !force popup-window "*diff*"
          !emacro
          define-macro diff-changes
          [EXIT 1]

          We will also need to change "me.emf" to add:

          -1 add-file-hook "^diff " fhook-diff

          for the time being this can be performed in <user.emf>.

          It is noted that the item list will not be quite right when there is a space in the directory or file name. I am not sure how to get around this at the moment but will have to
          think about it.

          Anyway nice idea and definitely something that I will be using.

          Thanks
          Jon.

          >>> FILE START hkdiff.emf
          ; -!- emf -!-
          ; This is part of the JASSPA MicroEmacs macro files
          ; Copyright (C) 2000-2009 JASSPA (www.jasspa.com)
          ; See the file me.emf for copying and conditions.
          ;
          ; Created: Wed Aug 23 2000
          ; Synopsis: Hilighting for diff files
          ; Authors: Jon Green + Pedro Gomes
          ;
          ; Notes:
          ; This has been extrapolated from the tools.emf file that originally
          ; handled the diff utility and associated hilighting.
          ;
          ; 2009-10-20 Pedro Gomes - Extensions for patch files
          ; - Handle patch files i.e. % gdiff -Naur me090909 me091011 > patch_file.patch
          ; - Extentions for next/previous difference and previous/next file.
          ; - Patch files detected with: -1 add-file-hook "^diff " fhook-diff
          ;
          define-macro fhook-diff
          ; Set up the buffer modes
          @# buffer-init "diff"
          -1 buffer-mode "time"
          !if &band .hilight.flags 0x02
          set-variable $buffer-hilight .hilight.diff
          !endif
          buffer-init-hooks
          !emacro

          ; Setup the buffer
          set-variable .fhook-diff.name "Differences File"
          set-variable .fhook-diff.setup ® "/history/fhook/diff" "Ughpo"
          set-variable .fhook-diff.setup-mask "aeghmpo1"
          set-variable .fhook-diff.command-0 "|btho||diff-next-change|C-down|\HNext change||"
          set-variable .fhook-diff.command-1 "|btho||diff-previous-change|C-up|\HPrevious change||"
          set-variable .fhook-diff.command-2 "|btho||diff-next-file|C-right|Next file||"
          set-variable .fhook-diff.command-3 "|btho||diff-previous-file|C-left|Previous file||"
          ; Setup item-list
          set-variable .fhook-diff.item-list-s1 "^diff\\(\\s+-[^\\s]*\\)*\\s*\\([^\\s]*\\)"
          set-variable .fhook-diff.item-list-r1 "File \ecB\\2\ecA"
          set-variable .fhook-diff.item-list-s2 "^@@\\s+\\(.*\\)\\s+@@$"
          set-variable .fhook-diff.item-list-r2 "Diff \ecB\\1\ecA"
          set-variable .fhook-diff.item-list-s3 "^---\\s+\\([0-9]+,[0-9]+\\)\\s+---"
          set-variable .fhook-diff.item-list-r3 "Diff \ecB\\1\ecA"
          set-variable .fhook-diff.item-list-s4 "^Only[^:]*:\\s*\\(.*\\)\\s*$"
          set-variable .fhook-diff.item-list-r4 "Add/Del \ecB\\1\ecA"

          !if ¬ &exi .hilight.diff
          set-variable .hilight.diff &pinc .hilight.next 1
          !endif

          !if &band .hilight.flags 0x02
          0 hilight .hilight.diff 0 $global-scheme
          ; Gnu diff utility, uses --context
          hilight .hilight.diff 0x102 "!" .scheme.no1
          hilight .hilight.diff 0x102 "+" .scheme.no1
          hilight .hilight.diff 0x102 "-" .scheme.no1
          ; Regular diff utility. May be a bit too colored !!
          hilight .hilight.diff 0x102 "<" .scheme.no2
          hilight .hilight.diff 0x102 ">" .scheme.prepro
          ; Patch files GNU diff -Naur old new > file.patch
          hilight .hilight.diff 0x102 "diff" .scheme.function
          hilight .hilight.diff 0x102 "@@" .scheme.keyword
          ; Common
          hilight .hilight.diff 0x102 "*\\*\\*\\*" .scheme.keyword
          hilight .hilight.diff 0x102 "*\\*\\*" .scheme.no2
          hilight .hilight.diff 0x102 "--- " .scheme.prepro
          hilight .hilight.diff 0x102 "Only" .scheme.comment
          hilight .hilight.diff 0x102 "Files" .scheme.comment
          !endif
          ; Find the next file
          0 define-macro diff-next-file
          !if &les @# 0
          !if &equ $window-line 1
          end-of-buffer
          !endif
          !elif &seq @wc ""
          beginning-of-buffer
          !endif
          !force search-forward "^diff "
          !if ¬ $status
          ml-write "[No more files]"
          !bell
          !abort
          !endif
          recenter
          !emacro
          ; Find the previous file
          0 define-macro diff-previous-file
          !if &les @# 0
          !if &equ $window-line 1
          end-of-buffer
          !endif
          !elif &seq @wc ""
          beginning-of-buffer
          !endif
          !force search-backward "^diff "
          !if ¬ $status
          ml-write "[No more files]"
          !bell
          !abort
          !endif
          recenter
          !emacro
          ; Find the next change
          0 define-macro diff-next-change
          !if &les @# 0
          !if &equ $window-line 1
          end-of-buffer
          !endif
          !elif &seq @wc ""
          beginning-of-buffer
          !endif
          !force search-forward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
          !if ¬ $status
          ml-write "[No more differences]"
          !bell
          !abort
          !endif
          recenter
          !emacro
          ; Find the previous change
          0 define-macro diff-previous-change
          !if &les @# 0
          !if &equ $window-line 1
          end-of-buffer
          !endif
          !elif &seq @wc ""
          beginning-of-buffer
          !endif
          !force search-backward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
          !if ¬ $status
          ml-write "[No more differences]"
          !bell
          !abort
          !endif
          recenter
          !emacro

          buffer-init-fhook "diff"
          <<< FILE END hkdiff.emf
        • Jon Green
          ... A small correction to the buffer modes. I needed to clean out the original manual buffer setting and use the more conventional buffer setup. This one is a
          Message 4 of 6 , Oct 20, 2009
          • 0 Attachment
            Jon Green wrote:
            > azynheira wrote:
            >> Hi All,
            >> This got just fantastic :-)
            >>
            >> Thanks a lot,
            >> Pedro
            >
            > Hi Pedro,
            >
            > Below is the final version. This fixes the item-list (f6/esc-f6) when running in a normal diff mode (rather than with the patch options).
            >
            > I would also suggest that the M-x diff command in tools.emf should have wrapping disabled by changing the ipipe parameter.
            >
            > cd /home/jon/.jasspa/
            > gdiff --context --minimal --ignore-space-change --recursive "/home/jon/.jasspa/tools.emf~" "/home/jon/.jasspa/tools.emf"
            >
            > *** /home/jon/.jasspa/tools.emf~ 2009-10-20 14:56:33.500554000 +0100
            > --- /home/jon/.jasspa/tools.emf 2009-10-20 14:56:38.626295000 +0100
            > ***************
            > *** 120,126 ****
            > set-variable #l1 &rep #l1 "/" "\\"
            > set-variable #l1 &xrep #l1 "\\\\$" ""
            > !endif
            > ! 4 ipipe-shell-command &spr "%s%s \"%s\" \"%s\"" %diff-com &cond &band @# 2 " -r" "" #l0 #l1 "*diff*"
            > !force popup-window "*diff*"
            > !emacro
            > define-macro diff-changes
            > --- 120,126 ----
            > set-variable #l1 &rep #l1 "/" "\\"
            > set-variable #l1 &xrep #l1 "\\\\$" ""
            > !endif
            > ! 0x204 ipipe-shell-command &spr "%s%s \"%s\" \"%s\"" %diff-com &cond &band @# 2 " -r" "" #l0 #l1 "*diff*"
            > !force popup-window "*diff*"
            > !emacro
            > define-macro diff-changes
            > [EXIT 1]
            >
            > We will also need to change "me.emf" to add:
            >
            > -1 add-file-hook "^diff " fhook-diff
            >
            > for the time being this can be performed in <user.emf>.
            >
            > It is noted that the item list will not be quite right when there is a space in the directory or file name. I am not sure how to get around this at the moment but will have to
            > think about it.
            >
            > Anyway nice idea and definitely something that I will be using.
            >
            > Thanks
            > Jon.
            >

            A small correction to the buffer modes.
            I needed to clean out the original manual buffer setting and use the more conventional buffer setup.
            This one is a little cleaner than the last with respect to the buffer configuration.

            Jon.

            >>> START FILE hkdiff.emf
            ; -!- emf -!-
            ; This is part of the JASSPA MicroEmacs macro files
            ; Copyright (C) 2000-2009 JASSPA (www.jasspa.com)
            ; See the file me.emf for copying and conditions.
            ;
            ; Created: Wed Aug 23 2000
            ; Synopsis: Hilighting for diff files
            ; Authors: Jon Green + Pedro Gomes
            ;
            ; Notes:
            ; This has been extrapolated from the tools.emf file that originally
            ; handled the diff utility and associated hilighting.
            ;
            ; 2009-10-20 Pedro Gomes - Extensions for patch files
            ; - Handle patch files i.e. % gdiff -Naur me090909 me091011 > patch_file.patch
            ; - Extentions for next/previous difference and previous/next file.
            ; - Patch files detected with: -1 add-file-hook "^diff " fhook-diff
            ;
            define-macro fhook-diff
            ; Set up the buffer modes
            @# buffer-init "diff"
            buffer-init-hooks
            !emacro

            ; Setup the buffer
            set-variable .fhook-diff.name "Differences File"
            set-variable .fhook-diff.setup ® "/history/fhook/diff" "UXghpo"
            set-variable .fhook-diff.setup-mask "aeghmpo"
            set-variable .fhook-diff.command-0 "|btho||diff-next-change|C-down|\HNext change||"
            set-variable .fhook-diff.command-1 "|btho||diff-previous-change|C-up|\HPrevious change||"
            set-variable .fhook-diff.command-2 "|btho||diff-next-file|C-right|Next file||"
            set-variable .fhook-diff.command-3 "|btho||diff-previous-file|C-left|Previous file||"
            ; Setup item-list
            set-variable .fhook-diff.item-list-s1 "^diff\\(\\s+-[^\\s]*\\)*\\s*\\([^\\s]*\\)"
            set-variable .fhook-diff.item-list-r1 "File \ecB\\2\ecA"
            set-variable .fhook-diff.item-list-s2 "^@@\\s+\\(.*\\)\\s+@@"
            set-variable .fhook-diff.item-list-r2 "Diff \ecB\\1\ecA"
            set-variable .fhook-diff.item-list-s3 "^---\\s+\\([0-9]+,[0-9]+\\)\\s+---"
            set-variable .fhook-diff.item-list-r3 "Diff \ecB\\1\ecA"
            set-variable .fhook-diff.item-list-s4 "^Only[^:]*:\\s*\\(.*\\)\\s*$"
            set-variable .fhook-diff.item-list-r4 "Add/Del \ecB\\1\ecA"

            !if ¬ &exi .hilight.diff
            set-variable .hilight.diff &pinc .hilight.next 1
            !endif

            !if &and &sin "h" .fhook-diff.setup &band .hilight.flags 0x02
            0 hilight .hilight.diff 0 $global-scheme
            ; Gnu diff utility, uses --context
            hilight .hilight.diff 0x102 "!" .scheme.no1
            hilight .hilight.diff 0x102 "+" .scheme.no1
            hilight .hilight.diff 0x102 "-" .scheme.no1
            ; Regular diff utility. May be a bit too colored !!
            hilight .hilight.diff 0x102 "<" .scheme.no2
            hilight .hilight.diff 0x102 ">" .scheme.prepro
            ; Patch files GNU diff -Naur old new > file.patch
            hilight .hilight.diff 0x102 "diff" .scheme.function
            hilight .hilight.diff 0x102 "@@" .scheme.keyword
            ; Common
            hilight .hilight.diff 0x102 "*\\*\\*\\*" .scheme.keyword
            hilight .hilight.diff 0x102 "*\\*\\*" .scheme.no2
            hilight .hilight.diff 0x102 "--- " .scheme.prepro
            hilight .hilight.diff 0x102 "Only" .scheme.comment
            hilight .hilight.diff 0x102 "Files" .scheme.comment
            !endif

            ; Find the next file
            0 define-macro diff-next-file
            !if &les @# 0
            !if &equ $window-line 1
            end-of-buffer
            !endif
            !elif &seq @wc ""
            beginning-of-buffer
            !endif
            !force search-forward "^diff "
            !if ¬ $status
            ml-write "[No more files]"
            !bell
            !abort
            !endif
            recenter
            !emacro
            ; Find the previous file
            0 define-macro diff-previous-file
            !if &les @# 0
            !if &equ $window-line 1
            end-of-buffer
            !endif
            !elif &seq @wc ""
            beginning-of-buffer
            !endif
            !force search-backward "^diff "
            !if ¬ $status
            ml-write "[No more files]"
            !bell
            !abort
            !endif
            recenter
            !emacro
            ; Find the next change
            0 define-macro diff-next-change
            !if &les @# 0
            !if &equ $window-line 1
            end-of-buffer
            !endif
            !elif &seq @wc ""
            beginning-of-buffer
            !endif
            !force search-forward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
            !if ¬ $status
            ml-write "[No more differences]"
            !bell
            !abort
            !endif
            recenter
            !emacro
            ; Find the previous change
            0 define-macro diff-previous-change
            !if &les @# 0
            !if &equ $window-line 1
            end-of-buffer
            !endif
            !elif &seq @wc ""
            beginning-of-buffer
            !endif
            !force search-backward "^\\(@@.*@@\\)\\|\\(--- [0-9]*,[0-9]* ---\\)"
            !if ¬ $status
            ml-write "[No more differences]"
            !bell
            !abort
            !endif
            recenter
            !emacro

            buffer-init-fhook "diff"
            <<< END FILE hkdiff.emf
          Your message has been successfully submitted and would be delivered to recipients shortly.