* how to reverse a region of outline items
@ 2010-10-08 13:12 Rainer Stengele
2010-10-09 17:14 ` Nicolas Goaziou
0 siblings, 1 reply; 3+ messages in thread
From: Rainer Stengele @ 2010-10-08 13:12 UTC (permalink / raw)
To: emacs-orgmode
hi all!
I have a region of outline items with subitems like
- A
* text below A
* ...
- B
* text below B
- C
- D
* text below D ...
- E
- ..
I want to reverse the list to:
- ..
- E
- D
* text below D ...
- C
- B
* text below B
- A
* text below A
* ...
without loosing the connection to the subitems,
therefore the "reverse-region" command will not work.
Has anybody an idea?
Rainer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to reverse a region of outline items
2010-10-08 13:12 how to reverse a region of outline items Rainer Stengele
@ 2010-10-09 17:14 ` Nicolas Goaziou
2010-10-12 14:57 ` brian powell
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2010-10-09 17:14 UTC (permalink / raw)
To: Rainer Stengele; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to reverse a region of outline items
2010-10-09 17:14 ` Nicolas Goaziou
@ 2010-10-12 14:57 ` brian powell
0 siblings, 0 replies; 3+ messages in thread
From: brian powell @ 2010-10-12 14:57 UTC (permalink / raw)
To: Nicolas Goaziou, Brian Powell; +Cc: emacs-orgmode, Rainer Stengele
[-- Attachment #1.1: Type: text/plain, Size: 2683 bytes --]
* 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 <n.goaziou@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
> 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
>
[-- Attachment #1.2: Type: text/html, Size: 3693 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-12 14:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-08 13:12 how to reverse a region of outline items Rainer Stengele
2010-10-09 17:14 ` Nicolas Goaziou
2010-10-12 14:57 ` brian powell
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).