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

RE: [jasspa] Bug

Expand Messages
  • Phillips, Steven
    Gabriel, This also catches me out and while I found it to be a feature rather than a bug (:) I still think this behaviour should be changed/avoided. But it
    Message 1 of 4 , Apr 6, 2004
    • 0 Attachment
      Gabriel,

      This also catches me out and while I found it to be a feature rather than a bug (:) I still think this behaviour should be changed/avoided. But it looks to me like you are trying to do something pretty odd like reducing the whole file to one line of text? If so a much better way of doing this is to use binary mode, e.g. if you are trying to replace "\n" with the string "<NL>" load the file in binary mode (C-x 9) and do:

      replace-string " 0A " " 3C 43 52 3E "

      (tip: to get the " 3C 43 52 3E " string create a temporary text file with the required string in it, save it, delete the buffer and load the file in binary mode) You may need to do a further:

      replace-string " 0D " " "

      If the file is windows format, and job done, this also fixes the long line issue. If you are not removing the '\n' then I suggest you use magic mode and '$', i.e. to replace all '\n' with '<CR>\n' do:

      replace-string "$" "<CR>"

      If this does not help I will need a more explicit example of what you are trying to do,

      Steve

      > -----Original Message-----
      > From: first last [mailto:prelude_2_murder@...]
      > Sent: 06 April 2004 12:51
      > To: jasspa@yahoogroups.com
      > Subject: [jasspa] Bug
      >
      >
      > One bug that I have found and that it annoys me quite a lot:
      >
      > If I have a file with some text and do a "replace all" replacing "\n"
      > with whatever the file grows enormously (until the line is too long or
      > I stop it).
      >
      > I know this is caused by ME adding a "\n" at the end of the file but,
      > if it is gonna do this, it should ignore the "\n" before the EOF when
      > replacing, shouldn't it?
      >
      > As a workaround, can the "append "\n" to the end of the file" be
      > disabled?
      >
      > Also, is there any special reason for having a maximum line size? I
      > find that limit annoying sometimes, when I get data files and want to
      > convert them (replacing the "\n"s with ","s and so on).
      >
      > Thanks
      >
      > Gabriel
      >
      > ______________________________________________________________
      > __________
      > Yahoo! Messenger - Communicate instantly..."Ping"
      > your friends today! Download Messenger Now
      > http://uk.messenger.yahoo.com/download/index.html
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      > ---------------------~-->
      > Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
      > Printer at MyInks.com. Free s/h on orders $50 or more to the
      > US & Canada.
      > http://www.c1tracking.com/l.asp?cid=5511
      > http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/89EolB/TM
      > --------------------------------------------------------------
      > -------~->
      >
      > ______________________________________________________________
      > ____________
      >
      > 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
      >
      >
      >
      >
      >
      >
    • first last
      Hi Jon, what I am trying to do is to change the format of a list of words. An example of this is when I created the keyword list for the css mode: Using the
      Message 2 of 4 , Apr 7, 2004
      • 0 Attachment
        Hi Jon,

        what I am trying to do is to change the format of a list of words. An
        example of this is when I created the keyword list for the css mode:

        Using the command line I created a list of the keywords (then into sort
        and then into uniq), then I had a list like:

        keyword1
        keyword2
        keyword3
        ....

        what I did was to replace (Esc-R)
        '\n' with

        " .scheme.keyword hilight\n hilight .hilight.css 1
        "

        so I got:

        hilight .hilight.css 1 "keyword1" .scheme.keyword
        hilight .hilight.css 1 "keyword2" .scheme.keyword
        hilight .hilight.css 1 "keyword3" .scheme.keyword

        Well, that is the theory. Because of the bug I just mentioned I got the
        expected result plus millions of extra lines like
        hilight .hilight.css 1 "" .scheme.keyword

        If I do the same and I don't use a "\n" anywhere in the replacement
        string I then get the "line too long" message.

        I normally use the latter to empty html files of all whitespace so they
        get smaller (/\n[ ]*/). I then end up with one long line that contains
        the whole file (Dreamweaver is terrible, the pages get extremely
        bloated with whitespace).

        Does it make sense now?

        Thanks

        Gabriel

        ________________________________________________________________________
        Yahoo! Messenger - Communicate instantly..."Ping"
        your friends today! Download Messenger Now
        http://uk.messenger.yahoo.com/download/index.html
      • Phillips, Steven
        It does make sense but this is not the best way to do it. You should use magic mode and try the following: replace-string ^ hilight .hilight.css 1
        Message 3 of 4 , Apr 7, 2004
        • 0 Attachment
          It does make sense but this is not the best way to do it. You should use magic mode and try the following:

          replace-string "^" "hilight .hilight.css 1 \""
          beginning-of-buffer
          replace-string "$" "\" .scheme.keyword"

          This wraps the text around the keyword. However once you get a bit more familiar with magic mode (see the regex docs) you can easily do this in one step as follows:

          replace-string "\\(.+\\)" "hilight .hilight.css 1 \"\\1\" .scheme.keyword"

          (Note I have back-quoted to make this legitimate macro code, the search string is:
          \(.+\)
          And replace string is:
          hilight .hilight.css 1 "\1" .scheme.keyword

          See docs on regex groups '\(...\)' or play!

          As a side note, the line length limit is there for memory efficiency, each line is stored as a structure and this structure stores the length of a line as an unsigned short (2 bytes) giving an maximum length of 65535 chars, realistically if your lines are longer than this you are trying to edit a binary file in text mode, done something wrong (like your search-replace) or doing something very weird. So this limit has not been much of an issue to date.

          Steve

          > -----Original Message-----
          > From: first last [mailto:prelude_2_murder@...]
          > Sent: 07 April 2004 11:20
          > To: jasspa@yahoogroups.com
          > Subject: RE: [jasspa] Bug
          >
          >
          > Hi Jon,
          >
          > what I am trying to do is to change the format of a list of words. An
          > example of this is when I created the keyword list for the css mode:
          >
          > Using the command line I created a list of the keywords (then
          > into sort
          > and then into uniq), then I had a list like:
          >
          > keyword1
          > keyword2
          > keyword3
          > ....
          >
          > what I did was to replace (Esc-R)
          > '\n' with
          >
          > " .scheme.keyword hilight\n hilight .hilight.css 1
          > "
          >
          > so I got:
          >
          > hilight .hilight.css 1 "keyword1" .scheme.keyword
          > hilight .hilight.css 1 "keyword2" .scheme.keyword
          > hilight .hilight.css 1 "keyword3" .scheme.keyword
          >
          > Well, that is the theory. Because of the bug I just mentioned
          > I got the
          > expected result plus millions of extra lines like
          > hilight .hilight.css 1 "" .scheme.keyword
          >
          > If I do the same and I don't use a "\n" anywhere in the replacement
          > string I then get the "line too long" message.
          >
          > I normally use the latter to empty html files of all
          > whitespace so they
          > get smaller (/\n[ ]*/). I then end up with one long line that contains
          > the whole file (Dreamweaver is terrible, the pages get extremely
          > bloated with whitespace).
          >
          > Does it make sense now?
          >
          > Thanks
          >
          > Gabriel
          >
          > ______________________________________________________________
          > __________
          > Yahoo! Messenger - Communicate instantly..."Ping"
          > your friends today! Download Messenger Now
          > http://uk.messenger.yahoo.com/download/index.html
          >
          >
          > ------------------------ Yahoo! Groups Sponsor
          > ---------------------~-->
          > Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
          > Printer at MyInks.com. Free s/h on orders $50 or more to the
          > US & Canada.
          > http://www.c1tracking.com/l.asp?cid=5511
          > http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/89EolB/TM
          > --------------------------------------------------------------
          > -------~->
          >
          > ______________________________________________________________
          > ____________
          >
          > 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
          >
          >
          >
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.