소스 검색

babel: New function to mark the body of a src block.

    * ob.el (org-babel-mark-block): New function to mark the body
    of a src block in the style of `mark-defun'.

    * ob-keys.el (org-babel-key-bindings): Bind
    `org-babel-mark-block' to C-c C-v C-M-h
Dan Davison 15 년 전
부모
커밋
a6d30d3b9b
2개의 변경된 파일14개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      lisp/ob-keys.el
  2. 12 0
      lisp/ob.el

+ 2 - 1
lisp/ob-keys.el

@@ -83,7 +83,8 @@ functions which are assigned key bindings, and see
     ("a" . org-babel-sha1-hash)
     ("a" . org-babel-sha1-hash)
     ("h" . org-babel-describe-bindings)
     ("h" . org-babel-describe-bindings)
     ("\C-x" . org-babel-do-key-sequence-in-edit-buffer)
     ("\C-x" . org-babel-do-key-sequence-in-edit-buffer)
-    ("x" . org-babel-do-key-sequence-in-edit-buffer))
+    ("x" . org-babel-do-key-sequence-in-edit-buffer)
+    ("\C-\M-h" . org-babel-mark-block))
   "Alist of key bindings and interactive Babel functions.
   "Alist of key bindings and interactive Babel functions.
 This list associates interactive Babel functions
 This list associates interactive Babel functions
 with keys.  Each element of this list will add an entry to the
 with keys.  Each element of this list will add an entry to the

+ 12 - 0
lisp/ob.el

@@ -1114,6 +1114,18 @@ With optional prefix argument ARG, jump backward ARG many source blocks."
 (defvar org-babel-load-languages)
 (defvar org-babel-load-languages)
 
 
 ;;;###autoload
 ;;;###autoload
+(defun org-babel-mark-block ()
+  "Mark current src block"
+  (interactive)
+  ((lambda (head)
+     (when head
+       (save-excursion
+	 (goto-char head)
+	 (looking-at org-babel-src-block-regexp))
+       (push-mark (match-end 5) nil t)
+       (goto-char (match-beginning 5))))
+   (org-babel-where-is-src-block-head)))
+
 (defun org-babel-demarcate-block (&optional arg)
 (defun org-babel-demarcate-block (&optional arg)
   "Wrap or split the code in the region or on the point.
   "Wrap or split the code in the region or on the point.
 When called from inside of a code block the current block is
 When called from inside of a code block the current block is