emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] how to reverse a region of outline items


From: brian powell
Subject: Re: [Orgmode] how to reverse a region of outline items
Date: Tue, 12 Oct 2010 10:57:08 -0400

* 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 <address@hidden> 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.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


reply via email to

[Prev in Thread] Current Thread [Next in Thread]