Permalink
Browse files

org-mode: expand to code blocks

  • Loading branch information...
1 parent 6481a36 commit 8c8e13c047716e3345d0ce19413baa3315c23588 @magnars committed Feb 23, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 org-mode-expansions.el
View
@@ -47,11 +47,23 @@
(exchange-point-and-mark)
(skip-chars-forward er--space-str))
+(defun er/mark-org-code-block ()
+ "Marks an org-code-block."
+ (interactive)
+ (let ((case-fold-search t)
+ (re "#\\+begin_\\(\\sw+\\)"))
+ (unless (looking-at re)
+ (search-backward-regexp re))
+ (set-mark (point))
+ (search-forward (concat "#+end_" (match-string 1)))
+ (exchange-point-and-mark)))
+
(defun er/add-org-mode-expansions ()
"Adds org-specific expansions for buffers in org-mode"
(set (make-local-variable 'er/try-expand-list) (append
er/try-expand-list
'(org-mark-subtree
+ er/mark-org-code-block
er/mark-sentence
er/mark-paragraph))))

0 comments on commit 8c8e13c

Please sign in to comment.