all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Jumping between source blocks in a file
@ 2015-11-27 13:59 Andrew Kirkpatrick
  2015-12-02  6:50 ` Martin Yrjölä
  2016-06-25  7:34 ` Xebar Saram
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Kirkpatrick @ 2015-11-27 13:59 UTC (permalink / raw)
  To: emacs-orgmode

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

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

end of thread, other threads:[~2016-06-25  7:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-27 13:59 Jumping between source blocks in a file Andrew Kirkpatrick
2015-12-02  6:50 ` 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

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.