From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Kirkpatrick Subject: Jumping between source blocks in a file Date: Sat, 28 Nov 2015 00:29:36 +1030 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2JYo-0007am-Ol for emacs-orgmode@gnu.org; Fri, 27 Nov 2015 08:59:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a2JYn-0002Rz-Tm for emacs-orgmode@gnu.org; Fri, 27 Nov 2015 08:59:38 -0500 Received: from mail-ig0-x22d.google.com ([2607:f8b0:4001:c05::22d]:37228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2JYn-0002Qz-OL for emacs-orgmode@gnu.org; Fri, 27 Nov 2015 08:59:37 -0500 Received: by igcto18 with SMTP id to18so30582579igc.0 for ; Fri, 27 Nov 2015 05:59:36 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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))