emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add repeat-map for navigation commands
Date: Mon, 16 Sep 2024 17:59:57 +0530	[thread overview]
Message-ID: <87r09jwzlm.fsf@gmail.com> (raw)
In-Reply-To: <87cyl53vzx.fsf@localhost> (Ihor Radchenko's message of "Sun, 15 Sep 2024 13:08:18 +0000")

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

[ஞாயிறு செப்டம்பர் 15, 2024] Ihor Radchenko wrote:

> Visuwesh <visuweshm@gmail.com> writes:
>
>> BTW, should we add C-n and friends to org-navigation-repeat-map or just
>> have n, p, etc.?  I personally find C-n in the repeat-map disruptive
>> since I usually want to move the cursor after jumping to a specific
>> heading, in which case C-n not being next-line is annoying.
>
> +1 for less disruptive :)

Please find attached.  I tried my best to write the manual entry but it
still reads awkward.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-repeat-mode-keymap-for-navigation-commands.patch --]
[-- Type: text/x-diff, Size: 5105 bytes --]

From c66ff969e23d0d29746941383e5afa54d0e9e060 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Mon, 9 Sep 2024 19:46:47 +0530
Subject: [PATCH] Add repeat-mode keymap for navigation commands

* lisp/org-keys.el (org-up-heading): Add new alias for
outline-up-heading.
(org-mode-map): Remap outline-up-heading to the new alias.
(org-navigation-repeat-map, org-link-navigation-repeat-map)
(org-block-navigation-repeat-map): Add new repeat-maps to make
navigation easier.
* doc/org-manual.org (Repeating commands): Document the new feature in the manual.
* etc/ORG-NEWS (Some navigation commands can now be repeated): Announce it.
---
 doc/org-manual.org | 14 ++++++++++++++
 etc/ORG-NEWS       |  6 ++++++
 lisp/org-keys.el   | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 9365c66b1..254764c31 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -21657,6 +21657,20 @@ of ~org-yank-dnd-method~.  Image files pasted this way also respect
 the value of ~org-yank-image-save-method~ when the action to perform
 is =attach=.
 
+** Repeating commands
+:PROPERTIES:
+:DESCRIPTION: Repeating navigation commands
+:END:
+
+#+cindex: repeat-mode, org-mode
+#+cindex: repeating navigation commands
+When ~repeat-mode~ is turned on, headline motion commands, link and
+block navigation commands by only pressing a single key.  For example,
+when navigation to the next headline using {{{kbd(C-c C-n)}}}, a
+repeat map is activated that lets you quickly execute headline motion
+commands.  When a key not in the map is pressed, it exits ~repeat-mode~
+and the command corresponding to the key is executed.
+
 * Hacking
 :PROPERTIES:
 :DESCRIPTION: How to hack your way around.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 392788055..8acc2f6b4 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -77,6 +77,12 @@ You can now create links to =shortdoc= documentation groups for Emacs
 Lisp functions (see =M-x shortdoc-display-group=).  Requires Emacs 28
 or newer.
 
+*** Some navigation commands can now be repeated
+
+When ~repeat-mode~ is turned on, certain navigation can be repeated.
+These include the headline navigation commands, ~org-next-link~ and
+~org-previous-link~, and ~org-next-block~ and ~org-previous-block~.
+
 ** New and changed options
 
 # Chanes deadling with changing default values of customizations,
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 1daedaae8..f6de753af 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -232,6 +232,7 @@ (declare-function org-up-element "org" ())
 (declare-function org-update-statistics-cookies "org" (all))
 (declare-function org-yank "org" (&optional arg))
 (declare-function orgtbl-ascii-plot "org-table" (&optional ask))
+(declare-function outline-up-heading "outline" (arg &optional invisible-ok))
 
 
 \f
@@ -409,6 +410,8 @@ (define-key org-mode-map [remap outline-next-visible-heading]
 (define-key org-mode-map [remap outline-previous-visible-heading]
   #'org-previous-visible-heading)
 (define-key org-mode-map [remap outline-show-children] #'org-fold-show-children)
+(defalias 'org-up-heading #'outline-up-heading)
+(define-key org-mode-map [remap outline-up-heading] #'org-up-heading)
 
 ;;;; Make `C-c C-x' a prefix key
 (org-defkey org-mode-map (kbd "C-c C-x") (make-sparse-keymap))
@@ -462,6 +465,37 @@ (org-defkey org-mode-map (kbd "C-S-<left>") #'org-shiftcontrolleft)
 (org-defkey org-mode-map (kbd "C-S-<up>") #'org-shiftcontrolup)
 (org-defkey org-mode-map (kbd "C-S-<down>") #'org-shiftcontroldown)
 
+;;; Repeat-mode map.
+(defvar org-navigation-repeat-map (make-sparse-keymap)
+  "Repeat keymap for navigation commands.")
+(org-defkey org-navigation-repeat-map (kbd "b") #'org-backward-heading-same-level)
+(org-defkey org-navigation-repeat-map (kbd "f") #'org-forward-heading-same-level)
+(org-defkey org-navigation-repeat-map (kbd "n") #'org-next-visible-heading)
+(org-defkey org-navigation-repeat-map (kbd "p") #'org-previous-visible-heading)
+(org-defkey org-navigation-repeat-map (kbd "u") #'org-up-heading)
+(map-keymap
+ (lambda (_key cmd)
+   (put cmd 'repeat-map 'org-navigation-repeat-map))
+ org-navigation-repeat-map)
+
+(defvar org-link-navigation-repeat-map (make-sparse-keymap)
+  "Repeat keymap for link navigation commands.")
+(org-defkey org-link-navigation-repeat-map (kbd "n") #'org-next-link)
+(org-defkey org-link-navigation-repeat-map (kbd "p") #'org-previous-link)
+(map-keymap
+ (lambda (_ cmd)
+   (put cmd 'repeat-map 'org-link-navigation-repeat-map))
+ org-link-navigation-repeat-map)
+
+(defvar org-block-navigation-repeat-map (make-sparse-keymap)
+  "Repeat keymap for block navigation commands.")
+(org-defkey org-block-navigation-repeat-map (kbd "f") #'org-next-block)
+(org-defkey org-block-navigation-repeat-map (kbd "b") #'org-previous-block)
+(map-keymap
+ (lambda (_ cmd)
+   (put cmd 'repeat-map 'org-block-navigation-repeat-map))
+ org-block-navigation-repeat-map)
+
 ;;;; Extra keys for TTY access.
 
 ;;  We only set them when really needed because otherwise the
-- 
2.45.2


      reply	other threads:[~2024-09-16 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09 14:21 [PATCH] Add repeat-map for navigation commands Visuwesh
2024-09-09 16:53 ` Ihor Radchenko
2024-09-10  1:36   ` Karthik Chikmagalur
2024-09-15 12:54     ` Ihor Radchenko
2024-09-10  5:11   ` Visuwesh
2024-09-15 13:08     ` Ihor Radchenko
2024-09-16 12:29       ` Visuwesh [this message]

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=87r09jwzlm.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /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).