emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: brian powell <briangpowellms@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>,
	Brian Powell <briangpowellms@gmail.com>
Cc: emacs-orgmode@gnu.org, Rainer Stengele <rainer.stengele@diplan.de>
Subject: Re: how to reverse a region of outline items
Date: Tue, 12 Oct 2010 10:57:08 -0400	[thread overview]
Message-ID: <AANLkTikyzd+jOrknnK=Kwo0pvJ6=pn14oNbE_JCGH-Le@mail.gmail.com> (raw)
In-Reply-To: <87d3rjffuc.wl%n.goaziou@gmail.com>


[-- 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

      reply	other threads:[~2010-10-12 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTikyzd+jOrknnK=Kwo0pvJ6=pn14oNbE_JCGH-Le@mail.gmail.com' \
    --to=briangpowellms@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    --cc=rainer.stengele@diplan.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).