all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [RFC] Repeat Heading movement commands
@ 2015-03-29 19:11 Jacob Gerlach
  2015-03-29 20:05 ` Kyle Meyer
  0 siblings, 1 reply; 8+ messages in thread
From: Jacob Gerlach @ 2015-03-29 19:11 UTC (permalink / raw)
  To: Org-mode

Hi List,

I often find myself wanting to move up by several headings:

C-c C-p, C-c C-p, C-c C-p...
(I don't usually know ahead of time how many I want to move, so I
can't use a numeric prefix arg)

I like how `set-mark-command' works with non-nil `set-mark-repeat-pop'
to avoid the need to repeat a prefix key and wanted to try something
similar for C-p. I came up with the following:

(define-key org-mode-map
 (kbd "C-p")
 (lambda (arg)
   (interactive "p")
   (if (not (eq last-command 'org-previous-visible-heading))
       (previous-line arg)
     (org-previous-visible-heading arg)
     (setq this-command 'org-previous-visible-heading))))

So now I can do:
C-c C-p, C-p, C-p...
And repeatedly move by headlines.

This (with a similar definition for C-n) is working well for me. If I
fleshed this out into a patch with a defcustom to control the
behavior, might it be applied? Or is this too far in the weeds of
individual user preference to warrant modifying org.el?

Thanks for any comments.

Regards,
Jake

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 19:11 [RFC] Repeat Heading movement commands Jacob Gerlach
@ 2015-03-29 20:05 ` Kyle Meyer
  2015-03-29 20:09   ` John Kitchin
  0 siblings, 1 reply; 8+ messages in thread
From: Kyle Meyer @ 2015-03-29 20:05 UTC (permalink / raw)
  To: Jacob Gerlach; +Cc: Org-mode

Jacob Gerlach <jacobgerlach@gmail.com> wrote:
> Hi List,
>
> I often find myself wanting to move up by several headings:
>
> C-c C-p, C-c C-p, C-c C-p...
> (I don't usually know ahead of time how many I want to move, so I
> can't use a numeric prefix arg)
>
> I like how `set-mark-command' works with non-nil `set-mark-repeat-pop'
> to avoid the need to repeat a prefix key and wanted to try something
> similar for C-p. I came up with the following:
>
> (define-key org-mode-map
>  (kbd "C-p")
>  (lambda (arg)
>    (interactive "p")
>    (if (not (eq last-command 'org-previous-visible-heading))
>        (previous-line arg)
>      (org-previous-visible-heading arg)
>      (setq this-command 'org-previous-visible-heading))))
>
> So now I can do:
> C-c C-p, C-p, C-p...
> And repeatedly move by headlines.

With org-use-speed-commands set to t, this could be "C-c C-p p p".

--
Kyle

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 20:05 ` Kyle Meyer
@ 2015-03-29 20:09   ` John Kitchin
  2015-03-29 20:35     ` Kyle Meyer
  2015-03-29 21:43     ` Xavier Maillard
  0 siblings, 2 replies; 8+ messages in thread
From: John Kitchin @ 2015-03-29 20:09 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Org-mode, Jacob Gerlach

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

This kind of repeated command seems to be a good application for hydra.

On Sunday, March 29, 2015, Kyle Meyer <kyle@kyleam.com> wrote:

> Jacob Gerlach <jacobgerlach@gmail.com <javascript:;>> wrote:
> > Hi List,
> >
> > I often find myself wanting to move up by several headings:
> >
> > C-c C-p, C-c C-p, C-c C-p...
> > (I don't usually know ahead of time how many I want to move, so I
> > can't use a numeric prefix arg)
> >
> > I like how `set-mark-command' works with non-nil `set-mark-repeat-pop'
> > to avoid the need to repeat a prefix key and wanted to try something
> > similar for C-p. I came up with the following:
> >
> > (define-key org-mode-map
> >  (kbd "C-p")
> >  (lambda (arg)
> >    (interactive "p")
> >    (if (not (eq last-command 'org-previous-visible-heading))
> >        (previous-line arg)
> >      (org-previous-visible-heading arg)
> >      (setq this-command 'org-previous-visible-heading))))
> >
> > So now I can do:
> > C-c C-p, C-p, C-p...
> > And repeatedly move by headlines.
>
> With org-use-speed-commands set to t, this could be "C-c C-p p p".
>
> --
> Kyle
>
>

-- 
John

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

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

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 20:09   ` John Kitchin
@ 2015-03-29 20:35     ` Kyle Meyer
  2015-03-29 21:43     ` Xavier Maillard
  1 sibling, 0 replies; 8+ messages in thread
From: Kyle Meyer @ 2015-03-29 20:35 UTC (permalink / raw)
  To: John Kitchin; +Cc: Jacob Gerlach, Org-mode

John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> This kind of repeated command seems to be a good application for
> hydra.

True.  Basic navigation could be set up with something like this:

#+begin_src elisp
  (defhydra hydra-org-navigation ()
    "Org navigation"
    ("p" org-previous-visible-heading "previous heading")
    ("n" org-next-visible-heading "next heading")
    ("f" org-forward-heading-same-level "forward heading")
    ("b" org-backward-heading-same-level "backward heading")
    ("u" outline-up-heading "up heading")
    ("q" nil "cancel"))
#+end_src

-- 
Kyle

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 20:09   ` John Kitchin
  2015-03-29 20:35     ` Kyle Meyer
@ 2015-03-29 21:43     ` Xavier Maillard
  2015-03-29 22:10       ` Suvayu Ali
  2015-03-29 22:15       ` Kyle Meyer
  1 sibling, 2 replies; 8+ messages in thread
From: Xavier Maillard @ 2015-03-29 21:43 UTC (permalink / raw)
  To: John Kitchin; +Cc: Jacob Gerlach, Kyle Meyer, Org-mode


John Kitchin <jkitchin@andrew.cmu.edu> writes:

> This kind of repeated command seems to be a good application for hydra.

Excuse me if this is a FAQ but: what's hydra ?

-- Xavier.

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 21:43     ` Xavier Maillard
@ 2015-03-29 22:10       ` Suvayu Ali
  2015-03-30  0:33         ` Jacob Gerlach
  2015-03-29 22:15       ` Kyle Meyer
  1 sibling, 1 reply; 8+ messages in thread
From: Suvayu Ali @ 2015-03-29 22:10 UTC (permalink / raw)
  To: Xavier Maillard; +Cc: Org-mode, Kyle Meyer, Jacob Gerlach, John Kitchin

On 29 March 2015 at 23:43, Xavier Maillard <xavier@maillard.im> wrote:
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> This kind of repeated command seems to be a good application for hydra.
>
> Excuse me if this is a FAQ but: what's hydra ?

https://github.com/abo-abo/hydra/

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 21:43     ` Xavier Maillard
  2015-03-29 22:10       ` Suvayu Ali
@ 2015-03-29 22:15       ` Kyle Meyer
  1 sibling, 0 replies; 8+ messages in thread
From: Kyle Meyer @ 2015-03-29 22:15 UTC (permalink / raw)
  To: Xavier Maillard; +Cc: Jacob Gerlach, Org-mode, John Kitchin

Xavier Maillard <xavier@maillard.im> wrote:
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> This kind of repeated command seems to be a good application for hydra.
>
> Excuse me if this is a FAQ but: what's hydra ?

Hydra [1] is a really nice package for creating keymaps that are similar
to keymaps under a prefix key.  Hydra has lots of little features, but
two main advantages of using a hydra over a standard prefix key are that
commands are repeatable with a single key and that a menu displays the
key/command information.  Have a look at hydra-examples.el [2] for some
use cases.

[1] https://github.com/abo-abo/hydra
[2] https://github.com/abo-abo/hydra/blob/master/hydra-examples.el

--
Kyle

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

* Re: [RFC] Repeat Heading movement commands
  2015-03-29 22:10       ` Suvayu Ali
@ 2015-03-30  0:33         ` Jacob Gerlach
  0 siblings, 0 replies; 8+ messages in thread
From: Jacob Gerlach @ 2015-03-30  0:33 UTC (permalink / raw)
  To: Org-mode

On Sun, Mar 29, 2015 at 4:05 PM, Kyle Meyer <kyle@kyleam.com> wrote:
> With org-use-speed-commands set to t, this could be "C-c C-p p p".

Well, this is much better. Should have thought to check the info, of
course there's already something like this built in...

On Sun, Mar 29, 2015 at 4:09 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> This kind of repeated command seems to be a good application for hydra.

I suppose I'll stick with speed commands for org-mode, but hydra looks
interesting.

Thanks for the tips.

Regards,
Jake

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

end of thread, other threads:[~2015-03-30  0:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 19:11 [RFC] Repeat Heading movement commands Jacob Gerlach
2015-03-29 20:05 ` Kyle Meyer
2015-03-29 20:09   ` John Kitchin
2015-03-29 20:35     ` Kyle Meyer
2015-03-29 21:43     ` Xavier Maillard
2015-03-29 22:10       ` Suvayu Ali
2015-03-30  0:33         ` Jacob Gerlach
2015-03-29 22:15       ` Kyle Meyer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.