From: Gez <suleika@gmail.com>
To: mail@christianmoe.com
Cc: emacs-orgmode@gnu.org
Subject: Re: Idea: insert "current sort order" property
Date: Wed, 12 Oct 2011 12:35:21 +0100 [thread overview]
Message-ID: <CAPQe_Uog=+rKqRtF_YgB3xAvWgfLau5vWFM4TvwdVwrxnd8VXg@mail.gmail.com> (raw)
In-Reply-To: <4E949D13.6060505@christianmoe.com>
[-- Attachment #1: Type: text/plain, Size: 2234 bytes --]
Thanks, Christian. Please forgive my ignorance but what should I do with
the code? I've not done anything more advanced than org-customize before.
Gez
On 11 October 2011 20:46, Christian Moe <mail@christianmoe.com> wrote:
> Hi, Gez,
>
>
> On 10/7/11 5:02 PM, Gez wrote:
>
>> What I'm imagining is a command executed on a headline to insert a
>> property into each of its children "fixing" the current order;
>> something like ":sorted:01", ":sorted:02" etc.
>>
>
> I think this is a neat idea, and can see some uses for it for my own stuff.
> I've made a first pass below. Please test it and let me know how it works
> for you (and please *don't* test it on anything valuable without backing up
> first!).
>
> <snip>
>
> Code follows.
Yours,
> Christian
>
> #+begin_src emacs-lisp
> (defun cm/org-store-outline-order (arg prop)
> "Store the outline of the subtree of the entry at point by
> setting the property PROP of each direct child entry to its
> current position in the tree. With prefix ARG, store the position
> of the whole subtree. The tree can be restored to the stored
> outline by sorting on the property with `C-c ^ r'. Note that this
> will only work properly on the order of each subtree; if headings
> are demoted, promoted, or moved into different subtrees, the
> result may or may not be nonsense, but it will be impossible to
> restore the original order by sorting."
> (interactive "P\nsProperty key (default OutlineIndex): ")
> (if (string= prop "") (setq prop "OutlineIndex"))
> (if (or (not (org-map-entries t (concat prop "={.}") 'tree))
> (y-or-n-p "Property exists; overwrite? "))
> (let* ((match (format "LEVEL%s%s"
> (if arg ">=" "=")
> (1+ (org-current-level))))
> (counter 1)
> (width (1+ (floor (log10 (length (org-map-entries t match
> 'tree))))))
> (fstr (concat "%0" (number-to-string width) "d")))
> (org-map-entries
> '(progn
> (org-set-property prop
> (format fstr counter))
> (setq counter (1+ counter)))
> match 'tree)
> (message ""))))
> #+end_src
>
[-- Attachment #2: Type: text/html, Size: 3289 bytes --]
next prev parent reply other threads:[~2011-10-12 11:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-07 15:02 Idea: insert "current sort order" property Gez
2011-10-11 19:46 ` Christian Moe
2011-10-12 11:35 ` Gez [this message]
2011-10-12 12:16 ` Christian Moe
2011-10-12 15:59 ` Gez
2011-10-12 19:51 ` Christian Moe
2011-10-13 11:40 ` Gez
2011-10-13 12:39 ` Christian Moe
2011-10-13 18:34 ` Gez
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='CAPQe_Uog=+rKqRtF_YgB3xAvWgfLau5vWFM4TvwdVwrxnd8VXg@mail.gmail.com' \
--to=suleika@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=mail@christianmoe.com \
/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).