emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Jumping between source blocks in a file


From: Andrew Kirkpatrick
Subject: [O] Jumping between source blocks in a file
Date: Sat, 28 Nov 2015 00:29:36 +1030

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 via email to

[Prev in Thread] Current Thread [Next in Thread]