emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] contrib/org-toc.el: add forward and back commands
Date: Tue, 26 Feb 2013 14:45:09 -0500	[thread overview]
Message-ID: <1361907909-32271-1-git-send-email-aaronecay@gmail.com> (raw)

These commands navigate among siblings in the outline, and are bound to
the ‘f’ and ‘b’ keys.  Move the function for toggling toc-follow to ‘F’.
---

Bastien's comment about org-toc prompted me to send in this patch,
which I've been sitting on for a while.

 contrib/lisp/org-toc.el | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/contrib/lisp/org-toc.el b/contrib/lisp/org-toc.el
index 83f7c29..7302a61 100644
--- a/contrib/lisp/org-toc.el
+++ b/contrib/lisp/org-toc.el
@@ -110,7 +110,7 @@ echo-area. The COLUMNS property is always exluded."
   (setq major-mode 'org-toc-mode))

 ;; toggle modes
-(define-key org-toc-mode-map "f" 'org-toc-follow-mode)
+(define-key org-toc-mode-map "F" 'org-toc-follow-mode)
 (define-key org-toc-mode-map "S" 'org-toc-show-subtree-mode)
 (define-key org-toc-mode-map "s" 'org-toc-store-config)
 (define-key org-toc-mode-map "g" 'org-toc-restore-config)
@@ -120,8 +120,10 @@ echo-area. The COLUMNS property is always exluded."
 ;; navigation keys
 (define-key org-toc-mode-map "p" 'org-toc-previous)
 (define-key org-toc-mode-map "n" 'org-toc-next)
-(define-key org-toc-mode-map [(left)] 'org-toc-previous)
-(define-key org-toc-mode-map [(right)] 'org-toc-next)
+(define-key org-toc-mode-map "f" 'org-toc-forward)
+(define-key org-toc-mode-map "b" 'org-toc-back)
+(define-key org-toc-mode-map [(left)] 'org-toc-back)
+(define-key org-toc-mode-map [(right)] 'org-toc-forward)
 (define-key org-toc-mode-map [(up)] 'org-toc-previous)
 (define-key org-toc-mode-map [(down)] 'org-toc-next)
 (define-key org-toc-mode-map "1" (lambda() (interactive) (org-toc-show 1 (point))))
@@ -332,6 +334,24 @@ If DELETE is non-nil, delete other windows when in the Org buffer."
   (if org-toc-info-mode (org-toc-info))
   (if org-toc-follow-mode (org-toc-goto)))

+(defun org-toc-forward ()
+  "Go to the next headline at the same level in the TOC."
+  (interactive)
+  (condition-case nil
+      (outline-forward-same-level 1)
+    (error (message "No next headline at this level.")))
+  (if org-toc-info-mode (org-toc-info))
+  (if org-toc-follow-mode (org-toc-goto)))
+
+(defun org-toc-back ()
+  "Go to the previous headline at the same level in the TOC."
+  (interactive)
+  (condition-case nil
+      (outline-backward-same-level 1)
+    (error (message "No previous headline at this level.")))
+  (if org-toc-info-mode (org-toc-info))
+  (if org-toc-follow-mode (org-toc-goto)))
+
 (defun org-toc-quit ()
   "Quit the current Org TOC buffer."
   (interactive)
@@ -462,12 +482,13 @@ status."
   (let ((st-start 0)
 	(help-message
 	 "\[space\]   show heading                     \[1-4\] hide headlines below this level
-\[TAB\]     jump to heading                  \[f\]   toggle follow mode (currently %s)
+\[TAB\]     jump to heading                  \[F\]   toggle follow mode (currently %s)
 \[return\]  jump and delete others windows   \[i\]   toggle info mode (currently %s)
 \[S-TAB\]   cycle subtree (in Org)           \[S\]   toggle show subtree mode (currently %s)
 \[C-S-TAB\] global cycle (in Org)            \[r\]   toggle recenter mode (currently %s)
 \[:\]       cycle subtree (in TOC)           \[c\]   toggle column view (currently %s)
 \[n/p\]     next/previous heading            \[s\]   save TOC configuration
+\[f/b\]     next/previous heading of same level
 \[q\]       quit the TOC                     \[g\]   restore last TOC configuration"))
     (while (string-match "\\[[^]]+\\]" help-message st-start)
       (add-text-properties (match-beginning 0)
--
1.8.1.4

             reply	other threads:[~2013-02-26 20:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 19:45 Aaron Ecay [this message]
2013-02-26 22:18 ` [PATCH] contrib/org-toc.el: add forward and back commands Bastien

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=1361907909-32271-1-git-send-email-aaronecay@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).