emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-sort random
@ 2021-11-22  2:10 Vikas Rawal
  2021-11-22  3:12 ` Kyle Meyer
  0 siblings, 1 reply; 6+ messages in thread
From: Vikas Rawal @ 2021-11-22  2:10 UTC (permalink / raw)
  To: orgmode

I am trying to sort a sub-tree of headings randomly. But `C-c ^ f random RET` asks for a "function for comparing keys". What am I supposed to do?

Reference: https://lists.gnu.org/archive/html/emacs-orgmode/2011-02/msg00089.html

I have also tried the custom function proposed in the previous mail in
this thread (which was also proposed on another thread) but I face the
same problem with this as well.

Thanks for help.

Vikas


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

* Re: org-sort random
  2021-11-22  2:10 org-sort random Vikas Rawal
@ 2021-11-22  3:12 ` Kyle Meyer
       [not found]   ` <CAFVt51+4Y9njvdS-UZFVWXjr=M933QpUpDrGhD0GcHMmpQYhPw@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle Meyer @ 2021-11-22  3:12 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: orgmode

On 11/22/21 07:40:35 +0530, Vikas Rawal wrote:
> I am trying to sort a sub-tree of headings randomly. But `C-c ^ f
> random RET` asks for a "function for comparing keys". What am I
> supposed to do?

Here's the prompt:

  Function for comparing keys (empty for default `sort-subr' predicate):

And here's what sort-subr's docstring says about the behavior of the
default predicate:

  If PREDICATE is nil, comparison is done with ‘<’ if
  the keys are numbers, with ‘compare-buffer-substrings’ if the
  keys are cons cells (the car and cdr of each cons cell are taken
  as start and end positions), and with ‘string<’ otherwise.

That sounds like that should handle random's return value fine, so try
entering an empty string at that prompt.


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

* Re: org-sort random
       [not found]   ` <CAFVt51+4Y9njvdS-UZFVWXjr=M933QpUpDrGhD0GcHMmpQYhPw@mail.gmail.com>
@ 2021-11-23  5:08     ` Kyle Meyer
  2021-11-23 15:14       ` Vikas Rawal
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle Meyer @ 2021-11-23  5:08 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: orgmode

(Please don't drop the list.)

Vikas Rawal writes:

> That is, just press RET?

I think that depends on the completion framework.  With the default
completion, yes, I think RET should do it.  With ivy, it's instead
ivy-immediate-done (C-M-j).  I'm not sure offhand about other
frameworks.

> If I do that, it just reverses the existing order. No randomisation
> happens.

Dunno.  Seems to work on my end (release_9.5.1-188-g27f26f782).

    * h
    ** a
    ** b
    ** c
    ** d
    ** e
    ** f
    ** g
    ** h
    ** i
    ** j
    ** k
    ** l

With point on h and vanilla Emacs:

- C-c ^ f
- random
- RET

    * h
    ** f
    ** e
    ** h
    ** i
    ** g
    ** j
    ** k
    ** b
    ** c
    ** d
    ** a
    ** l


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

* Re: org-sort random
  2021-11-23  5:08     ` Kyle Meyer
@ 2021-11-23 15:14       ` Vikas Rawal
  2021-11-24  1:52         ` Samuel Wales
  0 siblings, 1 reply; 6+ messages in thread
From: Vikas Rawal @ 2021-11-23 15:14 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: orgmode

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

>
>
> I think that depends on the completion framework.  With the default
> completion, yes, I think RET should do it.  With ivy, it's instead
> ivy-immediate-done (C-M-j).  I'm not sure offhand about other
> frameworks.
>
>
That's what it needed. Thanks.

I wonder if there would be a better way to document this somewhere so that
people using different completion frameworks could figure out how to do it.
It seems to be something that would be useful to others.

Thanks again

Vikas

[-- Attachment #2: Type: text/html, Size: 826 bytes --]

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

* Re: org-sort random
  2021-11-23 15:14       ` Vikas Rawal
@ 2021-11-24  1:52         ` Samuel Wales
  2021-11-24  1:55           ` Samuel Wales
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Wales @ 2021-11-24  1:52 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: Kyle Meyer, orgmode

if random sorting of siblings is useful, another entry in the sorting
menu, dedicated to it, would eliminate any issues with completion.

it is a clever idea to feed random to sort by function.  maybe some
won't catch the connection.  just a possibility.  not trying to bloat.

On 11/23/21, Vikas Rawal <vikaslists@agrarianresearch.org> wrote:
>>
>>
>> I think that depends on the completion framework.  With the default
>> completion, yes, I think RET should do it.  With ivy, it's instead
>> ivy-immediate-done (C-M-j).  I'm not sure offhand about other
>> frameworks.
>>
>>
> That's what it needed. Thanks.
>
> I wonder if there would be a better way to document this somewhere so that
> people using different completion frameworks could figure out how to do it.
> It seems to be something that would be useful to others.
>
> Thanks again
>
> Vikas
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: org-sort random
  2021-11-24  1:52         ` Samuel Wales
@ 2021-11-24  1:55           ` Samuel Wales
  0 siblings, 0 replies; 6+ messages in thread
From: Samuel Wales @ 2021-11-24  1:55 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: Kyle Meyer, orgmode

i have found or would find random line within buffer or region to be
useful, and also random entry in org agenda files.

i'd find this useful too, but i think i'd find it more useful to keep
the ordering the same but instead go to a random entry within region.

On 11/23/21, Samuel Wales <samologist@gmail.com> wrote:
> if random sorting of siblings is useful, another entry in the sorting
> menu, dedicated to it, would eliminate any issues with completion.
>
> it is a clever idea to feed random to sort by function.  maybe some
> won't catch the connection.  just a possibility.  not trying to bloat.
>
> On 11/23/21, Vikas Rawal <vikaslists@agrarianresearch.org> wrote:
>>>
>>>
>>> I think that depends on the completion framework.  With the default
>>> completion, yes, I think RET should do it.  With ivy, it's instead
>>> ivy-immediate-done (C-M-j).  I'm not sure offhand about other
>>> frameworks.
>>>
>>>
>> That's what it needed. Thanks.
>>
>> I wonder if there would be a better way to document this somewhere so
>> that
>> people using different completion frameworks could figure out how to do
>> it.
>> It seems to be something that would be useful to others.
>>
>> Thanks again
>>
>> Vikas
>>
>
>
> --
> The Kafka Pandemic
>
> Please learn what misopathy is.
> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

end of thread, other threads:[~2021-11-24  2:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  2:10 org-sort random Vikas Rawal
2021-11-22  3:12 ` Kyle Meyer
     [not found]   ` <CAFVt51+4Y9njvdS-UZFVWXjr=M933QpUpDrGhD0GcHMmpQYhPw@mail.gmail.com>
2021-11-23  5:08     ` Kyle Meyer
2021-11-23 15:14       ` Vikas Rawal
2021-11-24  1:52         ` Samuel Wales
2021-11-24  1:55           ` Samuel Wales

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