From mboxrd@z Thu Jan 1 00:00:00 1970 From: brian powell Subject: Re: how to reverse a region of outline items Date: Tue, 12 Oct 2010 10:57:08 -0400 Message-ID: References: <87d3rjffuc.wl%n.goaziou@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1399157651==" Return-path: Received: from [140.186.70.92] (port=54735 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5gHx-0005p8-DL for emacs-orgmode@gnu.org; Tue, 12 Oct 2010 10:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5gHw-0000Cj-4T for emacs-orgmode@gnu.org; Tue, 12 Oct 2010 10:57:13 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]:35680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5gHv-0000CQ-S6 for emacs-orgmode@gnu.org; Tue, 12 Oct 2010 10:57:12 -0400 Received: by fxm2 with SMTP id 2so968145fxm.0 for ; Tue, 12 Oct 2010 07:57:10 -0700 (PDT) In-Reply-To: <87d3rjffuc.wl%n.goaziou@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou , Brian Powell Cc: emacs-orgmode@gnu.org, Rainer Stengele --===============1399157651== Content-Type: multipart/alternative; boundary=001485f7d7e2de881d04926cb085 --001485f7d7e2de881d04926cb085 Content-Type: text/plain; charset=ISO-8859-1 * A macro would definitely do this--a "keyboard macro" solution is simple: To create a keyboard macro do something like this: Cx ( ....etc. Cx ) ; Mx name-last-keyboard-macro....etc. To me, Cx (.....Cx )...--creating a "keyboard macro" seems to be the most useful thing one can use Editor MACroS/Emacs for! ;-) ** The solution is simple because of the features of OrgMode--the function of folding tree-nodes, makes it more simple than you might think: *** Have the macro do something like this: 1. Fold everything up to just the major headings. 2. Go to just below "* A" and put a string like "jjj"--and/or Mx set-mark--on its own line 3. Go down one row and do Ck. 4. MS< == EscapeShiftLessThanSign ---i.e. have macro repeatedly go to the top. 5. Cy 6. Cs jjj 7. Repeat 3->7. (Make 2 macros: The first does steps 1 and 2 and then does Cu 10000 macro-that-you-make-that-does-Ck-on-next-line-and-go-to-the-top ---i.e. steps 3-6. This way you have 1 macro call the other macro 10000 times or until you run out of lines/major sections whichever happens first.) You can make a macro that does the above--or just the second part and do: Cu 10000 Mx blah-new-macro-that-reverses-the-section-headings --then it would process a 10k major-headings-long-document or halt and "ring the bell" when you run out of major headings to process--DownArrow will hit the EndOfFile. Then you have a reusable macro that does what you want--with all the subtrees/subsections just where they started--untouched. I agree with Nicolas below, and his solution is generally what one might seek; but, a "keyboard macro" here allows you to do what you described without sorting or alphabetizing, etc.---the last major heading becomes the first and the first major heading becomes the last, regardless of the contents. Once keyboard macros are named and placed in .emacs, they are reusable. Good luck. On Sat, Oct 9, 2010 at 1:14 PM, Nicolas Goaziou wrote: > Hello, > > C-c ^ A will sort the list alphabetically, in reversed order. > > If you do not really have A, B, etc. you can, well, add "marks" > (numbers) to items with the help of `org-apply-on-list', sort the list > numerically (in reversed order, with C-c ^ N), then remove the marks. > > Here is an example sexp to mark list: > > (org-apply-on-list > '(lambda (c) > (org-get-bullet) > (goto-char (match-end 0)) > (insert (format " %s" c)) > (1+ c)) > 0) > > Regards, > > -- Nicolas > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > --001485f7d7e2de881d04926cb085 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable * A macro would definitely do this--a "keyboard macro" solution i= s simple:=A0

To create a keyboard macro do something lik= e this:=A0
Cx ( ....etc. Cx ) ; =A0Mx name-last-keyboard-macro...= .etc.

To me, Cx (.....Cx )...--creating a "keyboard macro&quo= t; seems to be the most useful thing one can use Editor MACroS/Emacs for!

;-)

** The solution is sim= ple because of the features of OrgMode--the function of folding tree-nodes,= makes it more simple than you might think:

*** Have the macro do something like this:
1.= Fold everything up to just the major headings.
2. Go to just bel= ow "* A" and put a string like "jjj"--and/or Mx set-mar= k--on its own line
3. Go down one row and do Ck.
4. MS< =A0=3D=3D =A0EscapeS= hiftLessThanSign =A0---i.e. have macro repeatedly go to the top.
= 5. Cy
6. Cs jjj=A0
7. Repeat 3->7.

(Make 2 macros: The first does steps 1 and 2 and then does Cu 10000 macro-t= hat-you-make-that-does-Ck-on-next-line-and-go-to-the-top ---i.e. steps 3-6.=
This way you have 1 macro call the other macro 10000 times or un= til you run out of lines/major sections whichever happens first.)

You can make a macro that does the above--or just the s= econd part and do:
=A0Cu 10000 Mx blah-new-macro-that-reverses-th= e-section-headings
--then it would process a 10k major-headings-l= ong-document or halt and "ring the bell" when you run out of majo= r headings to process--DownArrow will hit the EndOfFile. =A0Then you have a= reusable macro that does what you want--with all the subtrees/subsections = just where they started--untouched.

I agree with=A0Nicolas below, and his solution is gener= ally what one might seek; but, a "keyboard macro" here allows you= to do what you described without sorting or alphabetizing, etc.---the last= major heading becomes the first and the first major heading becomes the la= st, regardless of the contents. =A0Once keyboard macros are named and place= d in .emacs, they are reusable.

Good luck. =A0


=

On Sat, Oct 9, 2010 at 1:14 PM, Nicolas= Goaziou <n.goa= ziou@gmail.com> wrote:
Hello,

C-c ^ A will sort the list alphabetically, in reversed order.

If you do not really have A, B, etc. you can, well, add "marks" (numbers) to items with the help of `org-apply-on-list', sort the list<= br> numerically (in reversed order, with C-c ^ N), then remove the marks.

Here is an example sexp to mark list:

(org-apply-on-list
=A0'(lambda (c)
=A0 =A0(org-get-bullet)
=A0 =A0(goto-char (match-end 0))
=A0 =A0(insert (format " %s" c))
=A0 =A0(1+ c))
=A00)

Regards,

-- Nicolas

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

--001485f7d7e2de881d04926cb085-- --===============1399157651== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1399157651==--