emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Get to next NEXT headline with one key
@ 2014-03-07 12:13 Giacomo M
  2014-03-07 12:37 ` John Kitchin
  0 siblings, 1 reply; 8+ messages in thread
From: Giacomo M @ 2014-03-07 12:13 UTC (permalink / raw)
  To: emacs-orgmode

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

Dear all,
I would like, by pressing the speed command N, to be brought to the next
NEXT headline. I can see that somehow the functions involved could
be org-match-sparse-tree and next-error, but I don't know how to code a
programmatic execution of the two (unfortunately I don't speak elisp very
well) into a function that can then be specified in
the org-speed-commands-user customization.

Is there anybody so kind to guide me to the (probably trivial) solution?

Thanks,

Giacomo

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

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

* Re: Get to next NEXT headline with one key
  2014-03-07 12:13 Get to next NEXT headline with one key Giacomo M
@ 2014-03-07 12:37 ` John Kitchin
  2014-03-07 12:44   ` Giacomo M
  0 siblings, 1 reply; 8+ messages in thread
From: John Kitchin @ 2014-03-07 12:37 UTC (permalink / raw)
  To: Giacomo M; +Cc: emacs-orgmode@gnu.org

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

I do not understand what you are asking for. in my emacs/org pressing n
does go to the next headline. (at least after running (setq
org-use-speed-commands t)) and being at the beginning of a headline.


John

-----------------------------------
John Kitchin
Associate Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu



On Fri, Mar 7, 2014 at 7:13 AM, Giacomo M <jackjackk@gmail.com> wrote:

> Dear all,
> I would like, by pressing the speed command N, to be brought to the next
> NEXT headline. I can see that somehow the functions involved could
> be org-match-sparse-tree and next-error, but I don't know how to code a
> programmatic execution of the two (unfortunately I don't speak elisp very
> well) into a function that can then be specified in
> the org-speed-commands-user customization.
>
> Is there anybody so kind to guide me to the (probably trivial) solution?
>
> Thanks,
>
> Giacomo
>

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

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

* Re: Get to next NEXT headline with one key
  2014-03-07 12:37 ` John Kitchin
@ 2014-03-07 12:44   ` Giacomo M
  2014-03-07 13:54     ` Matt Lundin
  2014-03-07 14:44     ` Oleh
  0 siblings, 2 replies; 8+ messages in thread
From: Giacomo M @ 2014-03-07 12:44 UTC (permalink / raw)
  To: John Kitchin; +Cc: emacs-orgmode

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

Sorry for having been ambiguous, I meant the next headline with a "NEXT"
todo keyword.
Thanks
Il 07/mar/2014 13:37 "John Kitchin" <jkitchin@andrew.cmu.edu> ha scritto:

> I do not understand what you are asking for. in my emacs/org pressing n
> does go to the next headline. (at least after running (setq
> org-use-speed-commands t)) and being at the beginning of a headline.
>
>
> John
>
> -----------------------------------
> John Kitchin
> Associate Professor
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Fri, Mar 7, 2014 at 7:13 AM, Giacomo M <jackjackk@gmail.com> wrote:
>
>> Dear all,
>> I would like, by pressing the speed command N, to be brought to the next
>> NEXT headline. I can see that somehow the functions involved could
>> be org-match-sparse-tree and next-error, but I don't know how to code a
>> programmatic execution of the two (unfortunately I don't speak elisp very
>> well) into a function that can then be specified in
>> the org-speed-commands-user customization.
>>
>> Is there anybody so kind to guide me to the (probably trivial) solution?
>>
>> Thanks,
>>
>> Giacomo
>>
>
>

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

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

* Re: Get to next NEXT headline with one key
  2014-03-07 12:44   ` Giacomo M
@ 2014-03-07 13:54     ` Matt Lundin
  2014-03-07 14:28       ` Giacomo M
  2014-03-07 14:44     ` Oleh
  1 sibling, 1 reply; 8+ messages in thread
From: Matt Lundin @ 2014-03-07 13:54 UTC (permalink / raw)
  To: Giacomo M; +Cc: emacs-orgmode, John Kitchin

>     On Fri, Mar 7, 2014 at 7:13 AM, Giacomo M <jackjackk@gmail.com>
>     wrote:
>    
>         Dear all,
>         I would like, by pressing the speed command N, to be brought to
>         the next NEXT headline. I can see that somehow the functions
>         involved could be org-match-sparse-tree and next-error, but I
>         don't know how to code a programmatic execution of the two
>         (unfortunately I don't speak elisp very well) into a function
>         that can then be specified in the org-speed-commands-user
>         customization.
>        
>         Is there anybody so kind to guide me to the (probably trivial)
>         solution?
>        

Giacomo M <jackjackk@gmail.com> writes:

> Sorry for having been ambiguous, I meant the next headline with a
> "NEXT" todo keyword.
> Thanks

Here's a very quick hack/proof of concept. There's very likely a better
way to do it. This is simply to illustrate the general idea.

--8<---------------cut here---------------start------------->8---
(defun my-org-next-next ()
  (interactive)
  (forward-word)
  (when (re-search-forward "\\*+\\s-+NEXT" nil t)
    (org-reveal t))
  (org-back-to-heading))
    
(add-to-list 'org-speed-commands-user '("N" . (org-speed-move-safe 'my-org-next-next)))
--8<---------------cut here---------------end--------------->8---

Best,
Matt

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

* Re: Get to next NEXT headline with one key
  2014-03-07 13:54     ` Matt Lundin
@ 2014-03-07 14:28       ` Giacomo M
  0 siblings, 0 replies; 8+ messages in thread
From: Giacomo M @ 2014-03-07 14:28 UTC (permalink / raw)
  To: emacs-orgmode

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

Thank you very much Matt, it was exactly what I was looking for! And thanks
to Matt for his prompt reply.
Just wondering, so there is (no way of | no point in) trying to execute the
org-match-sparse-tree programmatically, right?

This community rocks



On Fri, Mar 7, 2014 at 2:54 PM, Matt Lundin <mdl@imapmail.org> wrote:

> >     On Fri, Mar 7, 2014 at 7:13 AM, Giacomo M <jackjackk@gmail.com>
> >     wrote:
> >
> >         Dear all,
> >         I would like, by pressing the speed command N, to be brought to
> >         the next NEXT headline. I can see that somehow the functions
> >         involved could be org-match-sparse-tree and next-error, but I
> >         don't know how to code a programmatic execution of the two
> >         (unfortunately I don't speak elisp very well) into a function
> >         that can then be specified in the org-speed-commands-user
> >         customization.
> >
> >         Is there anybody so kind to guide me to the (probably trivial)
> >         solution?
> >
>
> Giacomo M <jackjackk@gmail.com> writes:
>
> > Sorry for having been ambiguous, I meant the next headline with a
> > "NEXT" todo keyword.
> > Thanks
>
> Here's a very quick hack/proof of concept. There's very likely a better
> way to do it. This is simply to illustrate the general idea.
>
> --8<---------------cut here---------------start------------->8---
> (defun my-org-next-next ()
>   (interactive)
>   (forward-word)
>   (when (re-search-forward "\\*+\\s-+NEXT" nil t)
>     (org-reveal t))
>   (org-back-to-heading))
>
> (add-to-list 'org-speed-commands-user '("N" . (org-speed-move-safe
> 'my-org-next-next)))
> --8<---------------cut here---------------end--------------->8---
>
> Best,
> Matt
>

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

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

* Re: Get to next NEXT headline with one key
  2014-03-07 12:44   ` Giacomo M
  2014-03-07 13:54     ` Matt Lundin
@ 2014-03-07 14:44     ` Oleh
  2014-03-07 16:23       ` Giacomo M
  1 sibling, 1 reply; 8+ messages in thread
From: Oleh @ 2014-03-07 14:44 UTC (permalink / raw)
  To: Giacomo M; +Cc: emacs-orgmode

Hi Giacomo,

> Sorry for having been ambiguous, I meant the next headline with a "NEXT"
> todo keyword.

If you're feeling adventurous, you can try my new minor mode:
https://github.com/abo-abo/worf.

It's basically the same thing as speed commands, except it's got
different keys and different commands.
And commands work from start of #+... as well.

Here's how I've implemented the functionality that you want:

"j"/"k" are bound move down/up just like in vim, but they move by
headings or #+ markers.
But "K" can change their behavior temporarily: it will prompt you for
a char that corresponds to a keyword:
t - TODO
d - DONE
n - NEXT
c - CANCELLED

After a keyword is set, "j"/"k" will move by this keyword instead,
until any command other than "j"/"k" is issued (for instance "m",
which reveals heading). After that "j"/"k" will return to their
regular behavior.

As an example:

    So to move to the next NEXT, you can issue "Knj".
    One NEXT down after this: "j".
    Five NEXTs down: "5j".
    Back to the first NEXT: "6k".

Same thing, but with DONE:

    So to move to the next DONE, you can issue "Kdj".
    One DONE down after this: "j".
    Five NEXTs down: "5j".
    Back to the first DONE: "6k".

And if you're trying out the mode, make sure to try "g" and "h" - those
are my two favorites. `helm` and `ace-jump-mode` respectively are required
in order for these commands to work. I'm planning to add the package to MELPA,
so the dependencies would be downloaded automatically, but I don't want to add
it until I've assigned all the alphanumeric keys:)

regards,
Oleh

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

* Re: Get to next NEXT headline with one key
  2014-03-07 14:44     ` Oleh
@ 2014-03-07 16:23       ` Giacomo M
  2014-03-09 12:39         ` Oleh
  0 siblings, 1 reply; 8+ messages in thread
From: Giacomo M @ 2014-03-07 16:23 UTC (permalink / raw)
  To: emacs-orgmode

(typo in my previous email: s/to Matt/to John/)

Il 07/03/2014 15:44, Oleh ha scritto:
> If you're feeling adventurous, you can try my new minor mode:
> https://github.com/abo-abo/worf.

Thank you, Oleh!
Just tried it, and I think it has several convenient features.

> And commands work from start of #+... as well.

Like this one.

> Here's how I've implemented the functionality that you want:
>
> "j"/"k" are bound move down/up just like in vim, but they move by
> headings or #+ markers.
> But "K" can change their behavior temporarily: it will prompt you for
> a char that corresponds to a keyword:
> t - TODO
> d - DONE
> n - NEXT
> c - CANCELLED
>
> After a keyword is set, "j"/"k" will move by this keyword instead,
> until any command other than "j"/"k" is issued (for instance "m",
> which reveals heading). After that "j"/"k" will return to their
> regular behavior.
>

Question: is there a particular reason for restricting keyword j/k 
movement only to
- headlines at lower/equal levels (I get stuck in the subtree with the 
first NEXT)?
- visible headlines (I miss folded NEXT entries)?
Still eventually I would like to pack those "Knjm" keys into just one 
key to replicate what is done by Matt my-org-next-next() function.

> And if you're trying out the mode, make sure to try "g" and "h" - those
> are my two favorites. `helm` and `ace-jump-mode` respectively are required
> in order for these commands to work. I'm planning to add the package to MELPA,
> so the dependencies would be downloaded automatically, but I don't want to add
> it until I've assigned all the alphanumeric keys:)

I didn't know ace-jump-base... it really made my day! And yes, g and h 
can be quite useful.
Do you think that the selection procedure of *helm* could be compatible 
with sth like ace-jump-line-mode? The problem then will be to find a 
good keyword also for activating the ace commands.

I think this is a good step towards the ultimate keystroke-minimizing 
editing environment... it's just a thousand key-bindings-to-memorize 
away, but I can see it!

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

* Re: Get to next NEXT headline with one key
  2014-03-07 16:23       ` Giacomo M
@ 2014-03-09 12:39         ` Oleh
  0 siblings, 0 replies; 8+ messages in thread
From: Oleh @ 2014-03-09 12:39 UTC (permalink / raw)
  To: Giacomo M; +Cc: emacs-orgmode

>> And commands work from start of #+... as well.
>
>
> Like this one.

Note that you have to use "f" to get to the first #+ that belongs to a heading.

>> Here's how I've implemented the functionality that you want:
>>
>> "j"/"k" are bound move down/up just like in vim, but they move by
>> headings or #+ markers.
>> But "K" can change their behavior temporarily: it will prompt you for
>> a char that corresponds to a keyword:
>> t - TODO
>> d - DONE
>> n - NEXT
>> c - CANCELLED
>>
>> After a keyword is set, "j"/"k" will move by this keyword instead,
>> until any command other than "j"/"k" is issued (for instance "m",
>> which reveals heading). After that "j"/"k" will return to their
>> regular behavior.
>>
>
> Question: is there a particular reason for restricting keyword j/k movement
> only to
> - headlines at lower/equal levels (I get stuck in the subtree with the first
> NEXT)?
> - visible headlines (I miss folded NEXT entries)?

Restriction lifted.

> Still eventually I would like to pack those "Knjm" keys into just one key to
> replicate what is done by Matt my-org-next-next() function.

Doable by defining these functions on your own:

    (defun set-keyword-next ()
      (interactive)
      (worf-keyword "NEXT"))

    (defun set-keyword-done ()
      (interactive)
      (worf-keyword "DONE"))

After a call to `set-keyword-next`, "j"/"k" will move by "NEXT"
keyword until any other command is called.

> Do you think that the selection procedure of *helm* could be compatible with
> sth like ace-jump-line-mode? The problem then will be to find a good keyword
> also for activating the ace commands.

I think I see what you mean, but `helm` is already good enough in my
opinion.

I have mixed opinion of `ace-jump-mode`: on one hand it's fast, on the
other - it always requires you to focus and read: it can never become
muscle memory.

`helm`, on the other hand, is very nice in this respect: if you want
to go to a heading related to "ice cream", you just

1. Press "g" for go.
2. Type "ice".

    This will usually give you just one candidate to you can "C-m"
    right away.

    If you're an ice enthusiast and there are many
    matches (from 2 to 10), use "C-n"/"C-p" to select.

    If you're obsessed with ice and there are more than 10 matches,
    press space to narrow the candidates and type in something else:
    "ice age" will match not only the movie, but "Aged rice" as well.
    This should bring you to less than 10 matches.

This also works nicely with org mode: "todo coffee :office" will match
a TODO related to coffee with tag :OFFICE:.

> I think this is a good step towards the ultimate keystroke-minimizing
> editing environment... it's just a thousand key-bindings-to-memorize away,
> but I can see it!

Hopefully it's not a thousand.  Actually the whole "Knj" thing was my
attempt at minimizing the amount that you have to remember. I don't
know much about vim, but I've glimpsed its notion of verb-modifier-object,
at least the modifier-verb part: "Kn" is the modifier
(keyword-next) and "j" is the verb (down).  Or "4" is the modifier (4
times) and "j" is the verb etc.

You don't have to remember each combination together, you just have to
remember the components and combine them as you like. So my suggestion
for you is consider not defining `set-keyword-next` and binding it to
some random free key binding, but using "Kn" for a while, maybe it'll
grow on you.
I can think of one more use for "Kn": "Kn+" could add a heading with
keyword "NEXT" ("+" is the verb to add an empty heading).

regards,
Oleh

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

end of thread, other threads:[~2014-03-09 12:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 12:13 Get to next NEXT headline with one key Giacomo M
2014-03-07 12:37 ` John Kitchin
2014-03-07 12:44   ` Giacomo M
2014-03-07 13:54     ` Matt Lundin
2014-03-07 14:28       ` Giacomo M
2014-03-07 14:44     ` Oleh
2014-03-07 16:23       ` Giacomo M
2014-03-09 12:39         ` Oleh

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