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

259Re: Highlighting anomalies -- when deleting tokens (fix enclosed)

Expand Messages
  • Steven Phillips
    May 8, 2000
      Th

      I've found and fixed the delete hilight problem, fix is enclosed below.

      Note that the use of:

      -39 buffer-mode ; wrap mode off

      is not recommended. This is because the numbers (-39) are subject to change,
      if we introduce a new 'new' mode, as 'new' is alphabetically before 'wrap' it
      would come before it in the list so 'wrap's numerical value will change to
      -40.

      So why have the numerical form? For easy key binding, look at the binding used
      for the insert key.

      What should be used instead? The numerical argument of -1 should be used which
      prompts the user for the mode, as the mode name will not change this is far
      more stable, i.e. use:

      -1 buffer-mode "wrap" ; wrap mode off

      I think I've caught up with my mail now, if there's something I've missed let
      me know.

      Steve

      > Subject: [jasspa] Highlighting anomalies -- when deleting tokens
      > From: Thomas Hundt <thundt@...>
      > Date: Tue, 14 Mar 2000 12:16:46 -0800
      > To: "JASSPA MicroEmacs Mailing List" <jasspa@egroups.com>
      >
      > Ok here's another totally obscure behavior/bug.
      >
      > For a certain class of text files (phone lists, in this case, which have a
      > special format: fields are tagged by identifiers like H= for home number and
      > W= for work number) I add a few highlighting tokens:
      >
      > ; mydoc.emf thundt rev 10 12-Mar-00
      > define-macro my-fhook-doc
      > :
      > :
      > ;-----
      > ; Special settings for *phone.txt files
      > ;-----
      > !if &isequal "phone.txt" &right $buffer-fname &sub &len $buffer-fname 9 9
      > -39 buffer-mode ; wrap mode off
      > set-variable $screen-width 120
      >
      > ; Special highlighting for phone.txt
      > hilight .hilight.txt 0 "[A-Za-z]+=" .scheme.keyword ; E=xxx
      > hilight .hilight.txt 0 ";" .scheme.comment
      > hilight .hilight.txt 0x002 "^\*=" .scheme.variable ; *=xxx
      > ; .variable = grn, .keyword = blu, .header = org, .comment = red
      >
      > ml-write "[special settings for *phone.txt loaded]"
      > !else
      > ; Delete special highlighting for phone.txt
      > ; (because we don't want it happening in letter_to_mom.txt)
      > -1 hilight .hilight.txt 0 "[A-Za-z]+="
      > -1 hilight .hilight.txt 0 ";"
      > -1 hilight .hilight.txt 0x002 "^\*="
      > !endif
      > :
      > :
      > !emacro
      >
      > Now, this basically works as intended. When I edit a file named xyzphone.txt,
      > the tokens "H=" and "W=" and ";" and "*=ABC" are highlighted in pretty colors.
      > Right.
      >
      > But, when I then edit a file named foo.txt, and hope these little artifacts go
      > away, I see instead a weird, new form of highlighting: the exact same tokens
      > are discolored or shaded (not colored, but more like the way the current line
      > is brighter than the normal text). For example, semicolons are reverse video.
      > "W=" tokens are the same color as the current line highlight.
      >
      > My suspicion is that the deletion isn't actually taking (since ME still,
      > obviously, is finding the tokens) and the colors are mostly being deleted.
      >
      > The current workaround is simply to use a different ME after editing phone.txt
      > files.
      >
      > N.b. I use the Black on Cream color scheme.
      >
      >
      > -Th
      >

      *** /home/stevenp/me/src/.hilight.c.~0~ Thu May 4 10:53:44 2000
      --- /home/stevenp/me/src/hilight.c Mon May 8 08:33:06 2000
      ***************
      *** 814,820 ****
      dd++ ;
      }
      }
      ! if((node = addTokenNode(root,ss,flags)) == NULL)
      return NULL ;

      if(flags & (HLBRANCH|HLBRACKET))
      --- 814,820 ----
      dd++ ;
      }
      }
      ! if(((node = addTokenNode(root,ss,flags)) == NULL) || (flags & ADDTOKEN_REMOVE))
      return NULL ;

      if(flags & (HLBRANCH|HLBRACKET))