emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andrew Kirkpatrick <ubermonk@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Jumping between source blocks in a file
Date: Sat, 28 Nov 2015 00:29:36 +1030	[thread overview]
Message-ID: <CAHo11d5aOTLAbR1gy9+9=h_zBgTREpg7HLfLTDuhUYyBwgFDKA@mail.gmail.com> (raw)

On the emacs subreddit, someone recently asked if there was a command
to jump between babel source blocks while editing them. I couldn't
find such a command but liked the idea so I implemented it. My
implementation can be invoked from org-mode or org-src-mode. If a C-u
prefix is supplied, the edit is aborted rather than exited retaining
edits.

If this is deemed useful, I'm happy to make changes suitable for
inclusion in the project.

Cheers

(defun my-babel-src-jump (arg jump-fn)
  (let* ((minor-modes (cl-remove-if-not (lambda (x)
                                          (and (boundp x) (symbol-value x)))
                                        minor-mode-list)))
    (when (member 'org-src-mode minor-modes)
      (if (equal arg '(4))
          (org-edit-src-abort)
        (org-edit-src-exit)))
    (when (eq major-mode 'org-mode)
      (funcall jump-fn)
      (org-edit-src-code))))

(defun my-babel-edit-next (arg)
  (interactive "P")
  (my-babel-src-jump arg #'org-babel-next-src-block))

(defun my-babel-edit-previous (arg)
  (interactive "P")
  (my-babel-src-jump arg #'org-babel-previous-src-block))

             reply	other threads:[~2015-11-27 13:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27 13:59 Andrew Kirkpatrick [this message]
2015-12-02  6:50 ` Jumping between source blocks in a file Martin Yrjölä
2015-12-02  9:07   ` Andreas Leha
2015-12-02  9:38     ` Rainer M Krug
2015-12-02  9:40       ` Rainer M Krug
2015-12-02  9:49         ` Andreas Leha
2015-12-02 10:33           ` Rainer M Krug
2016-06-25  7:34 ` Xebar Saram

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='CAHo11d5aOTLAbR1gy9+9=h_zBgTREpg7HLfLTDuhUYyBwgFDKA@mail.gmail.com' \
    --to=ubermonk@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).