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

Newbie Q: Narrow-to-region

Expand Messages
  • Meino Christian Cramer
    Hi, (as so often... :) I am trying to get one macro, which I am writing to work. According that I have question: Suppose you have the following text fo
    Message 1 of 3 , Jul 7, 2005
      Hi,

      (as so often... :) I am trying to get one macro, which I am writing
      to work.

      According that I have question:

      Suppose you have the following text fo rtesting:

      a
      b
      c
      d
      e
      f
      g
      h

      (quite interesting contents, isn't it ??? ;)

      Now your macro does the following sequence, starting at the beginnig
      of the text:

      search-forward "d"
      beginning-of-line
      set-mark
      end-of-line
      4 narrow-buffer

      with the last command it fails with

      "illegal narrow"

      hmmm...

      Why?

      and:
      If a file has no final CR/LF or LF the last line cannot be
      narrowed...or am I wrong (as usual... ;)

      Thank you very much for any help or hint in advance! :)

      Have a nice weekend!
      Meino




























































      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
      a
      b
      c
      d
      e
      f
      g
      h
      i
      j
      k
      l
      m
      n
      o
      p
      q
      r
      s
      t
      u
      v
      w
      x
      y
      z
    • Phillips, Steven
      ... The narrow command works on lines, not part of lines, i.e. if I set the mark half way along this line and then did forward-line then 4 narrow-buffer the
      Message 2 of 3 , Jul 7, 2005
        > Now your macro does the following sequence, starting at the beginnig
        > of the text:
        >
        > search-forward "d"
        > beginning-of-line
        > set-mark
        > end-of-line
        > 4 narrow-buffer
        >
        > with the last command it fails with
        >
        > "illegal narrow"

        The narrow command works on lines, not part of lines, i.e. if I set the
        mark half way along this line and then did forward-line then 4
        narrow-buffer the whole line would be narrowed. Your region did not span
        a line so there were no lines to narrow.

        > and:
        > If a file has no final CR/LF or LF the last line cannot be
        > narrowed...or am I wrong (as usual... ;)

        ME has a line flag which tells it whether to write out a line
        termination or not, it sets this flag to no when it has to split a long
        line (greater that 65520) or if the last line does not have a CR. ME
        always inserts a blank line at the end so alas you are wrong, you will
        always be able to narrow the last text containing line.

        Steve
      • Thomas Hundt
        Without trying to figure out your exact problem, let me say that sometimes you end up using the technique: copy stuff to a temporary buffer, do some work on
        Message 3 of 3 , Jul 8, 2005
          Without trying to figure out your exact problem, let me say that
          sometimes you end up using the technique: copy stuff to a temporary
          buffer, do some work on it, and copy it back. Maybe that will help.

          -Th


          Phillips, Steven wrote:
          >> Now your macro does the following sequence, starting at the beginnig
          >> of the text:
          >>
          >> search-forward "d"
          >> beginning-of-line
          >> set-mark
          >> end-of-line
          >> 4 narrow-buffer
          >>
          >> with the last command it fails with
          >>
          >> "illegal narrow"
          >
          >
          > The narrow command works on lines, not part of lines, i.e. if I set the
          > mark half way along this line and then did forward-line then 4
          > narrow-buffer the whole line would be narrowed. Your region did not span
          > a line so there were no lines to narrow.
          >
          >
          >> and:
          >> If a file has no final CR/LF or LF the last line cannot be
          >> narrowed...or am I wrong (as usual... ;)
          >
          >
          > ME has a line flag which tells it whether to write out a line
          > termination or not, it sets this flag to no when it has to split a long
          > line (greater that 65520) or if the last line does not have a CR. ME
          > always inserts a blank line at the end so alas you are wrong, you will
          > always be able to narrow the last text containing line.
          >
          > Steve
        Your message has been successfully submitted and would be delivered to recipients shortly.