emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Sorting subheaders
@ 2009-08-11 15:29 Scott Novotney
  2009-08-13 15:12 ` Dan Davison
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Novotney @ 2009-08-11 15:29 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 405 bytes --]

Hello,

Does anyone know a way to sort headers or subheaders? I can sort items by
time in the agenda view, but something more powerful, possibly by :TAG: or
just by name would be very useful.

Example:

* Top
** C
** B
** A

-----------------------------------------------------
after some magic key combination
-----------------------------------------------------

* Top
** A
** B
** C

Thanks!

-Scott

[-- Attachment #1.2: Type: text/html, Size: 480 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: 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] 4+ messages in thread

* Re: Sorting subheaders
  2009-08-11 15:29 Sorting subheaders Scott Novotney
@ 2009-08-13 15:12 ` Dan Davison
  2009-08-13 17:15   ` [PATCH] " Dan Davison
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Davison @ 2009-08-13 15:12 UTC (permalink / raw)
  To: Scott Novotney; +Cc: emacs-orgmode

Scott Novotney <snovotney@gmail.com> writes:

> Hello,
>
> Does anyone know a way to sort headers or subheaders? I can sort items by time in the agenda view,
> but something more powerful, possibly by :TAG: or just by name would be very useful.

You want org-sort.

To sort your example by name, put the cursor in the top level heading (*
Top) and then use M-x org-sort, and select 'a' for alphanumeric
sort. org-sort calls org-sort-entries-or-items (unless you're in a
table). Below is the documentation for that (C-h f org-sort-entries-or-items)

[It looks like the main index of the manual needs a n entry under 'sort'
or 'sorting'. Currently there's only one for sorting in the agenda.]

Dan

,----
| org-sort-entries-or-items is an interactive compiled Lisp function in
| `org.el'.
| 
| (org-sort-entries-or-items &optional with-case sorting-type
| getkey-func compare-func property)
| 
| Sort entries on a certain level of an outline tree, or plain list items.
| If there is an active region, the entries in the region are sorted.
| Else, if the cursor is before the first entry, sort the top-level items.
| Else, the children of the entry at point are sorted.
| If the cursor is at the first item in a plain list, the list items will be
| sorted.
| 
| Sorting can be alphabetically, numerically, by date/time as given by
| a time stamp, by a property or by priority.
| 
| The command prompts for the sorting type unless it has been given to the
| function through the sorting-type argument, which needs to a character,
| (?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?r ?R ?f ?F).  Here is the
| precise meaning of each character:
| 
| n   Numerically, by converting the beginning of the entry/item to a number.
| a   Alphabetically, ignoring the TODO keyword and the priority, if any.
| t   By date/time, either the first active time stamp in the entry, or, if
|     none exist, by the first inactive one.
|     In items, only the first line will be chekced.
| s   By the scheduled date/time.
| d   By deadline date/time.
| c   By creation time, which is assumed to be the first inactive time stamp
|     at the beginning of a line.
| p   By priority according to the cookie.
| r   By the value of a property.
| 
| Capital letters will reverse the sort order.
| 
| If the sorting-type is ?f or ?F, then getkey-func specifies a function to be
| called with point at the beginning of the record.  It must return either
| a string or a number that should serve as the sorting key for that record.
| 
| Comparing entries ignores case by default.  However, with an optional argument
| with-case, the sorting considers case as well.
`----


>
> Example:
>
> * Top
> ** C
> ** B
> ** A
>
> -----------------------------------------------------
> after some magic key combination
> -----------------------------------------------------
>
> * Top
> ** A
> ** B
> ** C
>
> Thanks!
>
> -Scott
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: 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] 4+ messages in thread

* [PATCH] Re: Sorting subheaders
  2009-08-13 15:12 ` Dan Davison
@ 2009-08-13 17:15   ` Dan Davison
  2009-08-14 11:05     ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Davison @ 2009-08-13 17:15 UTC (permalink / raw)
  To: emacs-orgmode

<...>
> [It looks like the main index of the manual needs an entry under 'sort'
> or 'sorting'. Currently there's only one for sorting in the agenda.]

diff --git a/doc/org.texi b/doc/org.texi
index 79dac8e..0cb27da 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -957,6 +957,7 @@ See also the variable @code{org-goto-interface}.
 @cindex pasting, of subtrees
 @cindex cutting, of subtrees
 @cindex copying, of subtrees
+@cindex sorting, of subtrees
 @cindex subtrees, cut and paste
 
 @table @kbd

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: Sorting subheaders
  2009-08-13 17:15   ` [PATCH] " Dan Davison
@ 2009-08-14 11:05     ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2009-08-14 11:05 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Applied, thanks.

Dan Davison <davison@stats.ox.ac.uk> writes:

> <...>
>> [It looks like the main index of the manual needs an entry under 'sort'
>> or 'sorting'. Currently there's only one for sorting in the agenda.]
>
> diff --git a/doc/org.texi b/doc/org.texi
> index 79dac8e..0cb27da 100644
> --- a/doc/org.texi
> +++ b/doc/org.texi
> @@ -957,6 +957,7 @@ See also the variable @code{org-goto-interface}.
>  @cindex pasting, of subtrees
>  @cindex cutting, of subtrees
>  @cindex copying, of subtrees
> +@cindex sorting, of subtrees
>  @cindex subtrees, cut and paste

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-14 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-11 15:29 Sorting subheaders Scott Novotney
2009-08-13 15:12 ` Dan Davison
2009-08-13 17:15   ` [PATCH] " Dan Davison
2009-08-14 11:05     ` Bastien

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).