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

Graceful kill

Expand Messages
  • Meino Christian Cramer
    Hi, is there a way to quickly kill the contents of a buffer except those few lines, which are narrowed out (invisible, 4 narrow-buffer used) ? Keep
    Message 1 of 6 , Jul 9, 2005
    • 0 Attachment
      Hi,

      is there a way to quickly kill the contents of a buffer except those
      few lines, which are narrowed out (invisible, 4 narrow-buffer used) ?

      Keep microemacsing!
      Meino
    • Thomas Hundt
      The obvious thing to try is beginning-of-buffer set-mark end-of-buffer kill-region Did you try this? It seems pretty quick to me. Another obvious way is to
      Message 2 of 6 , Jul 9, 2005
      • 0 Attachment
        The obvious thing to try is

        beginning-of-buffer
        set-mark
        end-of-buffer
        kill-region

        Did you try this? It seems pretty "quick" to me.

        Another obvious way is to copy the part you've narrowed to somewhere
        else, and kill the buffer.





        Meino Christian Cramer wrote:
        > Hi,
        >
        > is there a way to quickly kill the contents of a buffer except those
        > few lines, which are narrowed out (invisible, 4 narrow-buffer used) ?
        >
        > Keep microemacsing!
        > Meino
      • Meino Christian Cramer
        From: Thomas Hundt Subject: Re: [jasspa] Graceful kill Date: Sat, 09 Jul 2005 15:56:09 -0700 Hi Thomas, This was my first try also.... But
        Message 3 of 6 , Jul 9, 2005
        • 0 Attachment
          From: Thomas Hundt <thundt@...>
          Subject: Re: [jasspa] Graceful kill
          Date: Sat, 09 Jul 2005 15:56:09 -0700

          Hi Thomas,

          This was my first try also....
          But it kills the narrowed parts also.

          I am trying to get this two working (first works in the meanwhile...)


          ;------------------------------------------------------------
          ; delete-matching-lines
          ;
          ;------------------------------------------------------------
          define-macro delete-matching-lines
          !force search-forward @mna
          !while $status
          beginning-of-line
          kill-line
          !force hunt-forward
          !done
          !emacro

          ;------------------------------------------------------------
          ; delete-not-matching-lines
          ;
          ;------------------------------------------------------------
          define-macro delete-non-matching-lines
          ;; set-variable $debug 1
          !force search-forward @mna
          !if $status
          set-variable #l1 1
          !else
          set-variable #l1 0
          !endif
          !while $status
          beginning-of-line
          set-mark
          forward-line
          4 narrow-buffer
          !force hunt-forward
          !done
          !if #l1
          beginning-of-buffer
          set-mark
          end-of-buffer
          kill-region
          0 narrow-buffer
          !endif
          ;; set-variable $debug 0
          !emacro


          Have a nice weekend and keep microemacsing! ;)
          Meino






          > The obvious thing to try is
          >
          > beginning-of-buffer
          > set-mark
          > end-of-buffer
          > kill-region
          >
          > Did you try this? It seems pretty "quick" to me.
          >
          > Another obvious way is to copy the part you've narrowed to somewhere
          > else, and kill the buffer.
          >
          >
          >
          >
          >
          > Meino Christian Cramer wrote:
          > > Hi,
          > >
          > > is there a way to quickly kill the contents of a buffer except those
          > > few lines, which are narrowed out (invisible, 4 narrow-buffer used) ?
          > >
          > > Keep microemacsing!
          > > Meino
          >
          >
          > __________________________________________________________________________
          >
          > 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
          >
          >
          >
          >
          >
          >
        • Phillips, Steven
          Without knowing where the narrow(s) are then its not trivial - see below, if you did then Thomas suggestion to kill the required text first and then empty the
          Message 4 of 6 , Jul 10, 2005
          • 0 Attachment
            Without knowing where the narrow(s) are then its not trivial - see
            below, if you did then Thomas' suggestion to kill the required text
            first and then empty the buffer is a good solution.

            The best way I can to think of to implement the general case (i.e. where
            there may be zero or more narrows and you don't know where) is to use
            $line-scheme.

            1) Create a new color scheme which is used only for this operation
            (%kill-scheme say) - done once.

            2) In the buffer set every visible line's $line-scheme to %kill-scheme.

            3) Remove all narrows.

            4) Kill every line whose $line-scheme is %kill-scheme.

            Job done.

            > -----Original Message-----
            > From: jasspa@yahoogroups.com [mailto:jasspa@yahoogroups.com] On Behalf
            Of
            > Meino Christian Cramer
            > Sent: Saturday, July 09, 2005 8:29 PM
            > To: jasspa@yahoogroups.com
            > Subject: [jasspa] Graceful kill
            >
            >
            > Hi,
            >
            > is there a way to quickly kill the contents of a buffer except those
            > few lines, which are narrowed out (invisible, 4 narrow-buffer used) ?
            >
            > Keep microemacsing!
            > Meino
            >
            >
            >
            ________________________________________________________________________
            __
            >
            > 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
            >
            >
            >
            >
          • Phillips, Steven
            One thing both macros may be missing is a beginning-of-buffer to start with. The second macro is very inefficient, I suggest you change this one completely.
            Message 5 of 6 , Jul 11, 2005
            • 0 Attachment
              One thing both macros may be missing is a beginning-of-buffer to start
              with.

              The second macro is very inefficient, I suggest you change this one
              completely. You do not need to use narrows to achieve this, you just
              need to kill all but matching lines:

              define-macro delete-non-matching-lines
              set-variable #l1 @ml05 "delete-non-matching-lines"
              beginning-of-buffer
              set-mark
              !repeat
              !force search-forward #l1
              !if $status
              beginning-of-line
              -1 kill-region
              forward-line
              set-mark
              !endif
              !until ¬ $status
              end-of-buffer
              -1 kill-region
              beginning-of-buffer
              !emacro

              Not tested this thoroughly but first indications are promising. The
              version will not handle search strings that span multiple lines. It may
              also fail to handle regex "^..." (start of line) searches correctly, you
              should test this thoroughly before you rely on this working correctly.

              Steve

              > -----Original Message-----
              > From: jasspa@yahoogroups.com [mailto:jasspa@yahoogroups.com] On Behalf
              Of
              > Meino Christian Cramer
              > Sent: Sunday, July 10, 2005 5:51 AM
              > To: jasspa@yahoogroups.com; thundt@...
              > Subject: Re: [jasspa] Graceful kill
              >
              > From: Thomas Hundt <thundt@...>
              > Subject: Re: [jasspa] Graceful kill
              > Date: Sat, 09 Jul 2005 15:56:09 -0700
              >
              > Hi Thomas,
              >
              > This was my first try also....
              > But it kills the narrowed parts also.
              >
              > I am trying to get this two working (first works in the meanwhile...)
              >
              >
              > ;------------------------------------------------------------
              > ; delete-matching-lines
              > ;
              > ;------------------------------------------------------------
              > define-macro delete-matching-lines
              > !force search-forward @mna
              > !while $status
              > beginning-of-line
              > kill-line
              > !force hunt-forward
              > !done
              > !emacro
              >
              > ;------------------------------------------------------------
              > ; delete-not-matching-lines
              > ;
              > ;------------------------------------------------------------
              > define-macro delete-non-matching-lines
              > ;; set-variable $debug 1
              > !force search-forward @mna
              > !if $status
              > set-variable #l1 1
              > !else
              > set-variable #l1 0
              > !endif
              > !while $status
              > beginning-of-line
              > set-mark
              > forward-line
              > 4 narrow-buffer
              > !force hunt-forward
              > !done
              > !if #l1
              > beginning-of-buffer
              > set-mark
              > end-of-buffer
              > kill-region
              > 0 narrow-buffer
              > !endif
              > ;; set-variable $debug 0
              > !emacro
              >
              >
              > Have a nice weekend and keep microemacsing! ;)
              > Meino
              >
              >
              >
              >
              >
              >
              > > The obvious thing to try is
              > >
              > > beginning-of-buffer
              > > set-mark
              > > end-of-buffer
              > > kill-region
              > >
              > > Did you try this? It seems pretty "quick" to me.
              > >
              > > Another obvious way is to copy the part you've narrowed to somewhere
              > > else, and kill the buffer.
              > >
              > >
              > >
              > >
              > >
              > > Meino Christian Cramer wrote:
              > > > Hi,
              > > >
              > > > is there a way to quickly kill the contents of a buffer except
              those
              > > > few lines, which are narrowed out (invisible, 4 narrow-buffer
              used) ?
              > > >
              > > > Keep microemacsing!
              > > > Meino
              > >
              > >
              > >
              >
              ________________________________________________________________________
              __
              > >
              > > 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
              > >
              > >
              > >
              > >
              > >
              > >
              >
              >
              >
              ________________________________________________________________________
              __
              >
              > 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
              >
              >
              >
              >
            • Meino Christian Cramer
              From: Phillips, Steven Subject: RE: [jasspa] Graceful kill Date: Mon, 11 Jul 2005 03:08:43 -0400 Hi STeven, thank you very much for
              Message 6 of 6 , Jul 11, 2005
              • 0 Attachment
                From: "Phillips, Steven" <sphillips@...>
                Subject: RE: [jasspa] Graceful kill
                Date: Mon, 11 Jul 2005 03:08:43 -0400

                Hi STeven,

                thank you very much for helping me with the macro !!! :)

                I missed out the "beginning-of-buffer" intentionally, just to give
                the user the possibily to decide by her/himself, from where to delete
                all (non) matching lines.

                Your solution is by far more elegant than mine ! :)

                I will check it.

                Thanks a lot!

                Keep microemacsing!
                Meino


                > One thing both macros may be missing is a beginning-of-buffer to start
                > with.
                >
                > The second macro is very inefficient, I suggest you change this one
                > completely. You do not need to use narrows to achieve this, you just
                > need to kill all but matching lines:
                >
                > define-macro delete-non-matching-lines
                > set-variable #l1 @ml05 "delete-non-matching-lines"
                > beginning-of-buffer
                > set-mark
                > !repeat
                > !force search-forward #l1
                > !if $status
                > beginning-of-line
                > -1 kill-region
                > forward-line
                > set-mark
                > !endif
                > !until ¬ $status
                > end-of-buffer
                > -1 kill-region
                > beginning-of-buffer
                > !emacro
                >
                > Not tested this thoroughly but first indications are promising. The
                > version will not handle search strings that span multiple lines. It may
                > also fail to handle regex "^..." (start of line) searches correctly, you
                > should test this thoroughly before you rely on this working correctly.
                >
                > Steve
                >
                > > -----Original Message-----
                > > From: jasspa@yahoogroups.com [mailto:jasspa@yahoogroups.com] On Behalf
                > Of
                > > Meino Christian Cramer
                > > Sent: Sunday, July 10, 2005 5:51 AM
                > > To: jasspa@yahoogroups.com; thundt@...
                > > Subject: Re: [jasspa] Graceful kill
                > >
                > > From: Thomas Hundt <thundt@...>
                > > Subject: Re: [jasspa] Graceful kill
                > > Date: Sat, 09 Jul 2005 15:56:09 -0700
                > >
                > > Hi Thomas,
                > >
                > > This was my first try also....
                > > But it kills the narrowed parts also.
                > >
                > > I am trying to get this two working (first works in the meanwhile...)
                > >
                > >
                > > ;------------------------------------------------------------
                > > ; delete-matching-lines
                > > ;
                > > ;------------------------------------------------------------
                > > define-macro delete-matching-lines
                > > !force search-forward @mna
                > > !while $status
                > > beginning-of-line
                > > kill-line
                > > !force hunt-forward
                > > !done
                > > !emacro
                > >
                > > ;------------------------------------------------------------
                > > ; delete-not-matching-lines
                > > ;
                > > ;------------------------------------------------------------
                > > define-macro delete-non-matching-lines
                > > ;; set-variable $debug 1
                > > !force search-forward @mna
                > > !if $status
                > > set-variable #l1 1
                > > !else
                > > set-variable #l1 0
                > > !endif
                > > !while $status
                > > beginning-of-line
                > > set-mark
                > > forward-line
                > > 4 narrow-buffer
                > > !force hunt-forward
                > > !done
                > > !if #l1
                > > beginning-of-buffer
                > > set-mark
                > > end-of-buffer
                > > kill-region
                > > 0 narrow-buffer
                > > !endif
                > > ;; set-variable $debug 0
                > > !emacro
                > >
                > >
                > > Have a nice weekend and keep microemacsing! ;)
                > > Meino
                > >
                > >
                > >
                > >
                > >
                > >
                > > > The obvious thing to try is
                > > >
                > > > beginning-of-buffer
                > > > set-mark
                > > > end-of-buffer
                > > > kill-region
                > > >
                > > > Did you try this? It seems pretty "quick" to me.
                > > >
                > > > Another obvious way is to copy the part you've narrowed to somewhere
                > > > else, and kill the buffer.
                > > >
                > > >
                > > >
                > > >
                > > >
                > > > Meino Christian Cramer wrote:
                > > > > Hi,
                > > > >
                > > > > is there a way to quickly kill the contents of a buffer except
                > those
                > > > > few lines, which are narrowed out (invisible, 4 narrow-buffer
                > used) ?
                > > > >
                > > > > Keep microemacsing!
                > > > > Meino
                > > >
                > > >
                > > >
                > >
                > ________________________________________________________________________
                > __
                > > >
                > > > 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
                > > >
                > > >
                > > >
                > > >
                > > >
                > > >
                > >
                > >
                > >
                > ________________________________________________________________________
                > __
                > >
                > > 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
                > >
                > >
                > >
                > >
                >
                >
                > __________________________________________________________________________
                >
                > 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.