From: "Eric Schulte" <schulte.eric@gmail.com>
To: Richard Riley <rileyrg@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-babel - utility to ease chopping src chunks into smaller org entries
Date: Sun, 19 Sep 2010 12:21:37 -0600 [thread overview]
Message-ID: <878w2xfllt.fsf@gmail.com> (raw)
In-Reply-To: i73q4m$hgi$1@dough.gmane.org
Hi Richard,
This is a good idea, I too frequently find myself splitting code blocks.
How about this following alternative implementation which should be
smart enough to notice if it is inside of a code block, and should work
across any code block type.
--8<---------------cut here---------------start------------->8---
(defun org-babel-split-block-maybe (&optional arg)
"Split the current source code block on the cursor."
(interactive "P")
((lambda (info)
(if info
(let ((lang (nth 0 info))
(indent (make-string (nth 6 info) ? ))
(stars (concat (make-string (org-current-level) ?*) " ")))
(insert (concat (if (looking-at "^") "" "\n")
indent "#+end_src\n"
(if arg stars indent) "\n"
indent "#+begin_src " lang
(if (looking-at "[\n\r]") "" "\n ")))
(when arg (previous-line) (move-end-of-line 1)))
(message "Not in src block.")))
(org-babel-get-src-block-info)))
--8<---------------cut here---------------end--------------->8---
Let me know what you think. I notice your implementation uses regions,
where as this one does not, so it's possible I left out some
functionality. I'd like to include some version of this functionality
into Org-mode core.
Best -- Eric
Richard Riley <rileyrg@gmail.com> writes:
> I often find myself chopping a large source code block into smaller
> entities with their own notes, tags and comments etc. This small utility
> facilitates that by wrapping the current region with org entry markers
> and src code delimiters. It assumes you are in a currently src block.
>
> http://splash-of-open-sauce.blogspot.com/2010/09/mark-region-as-src-code-if-prefix-used.html
>
> Its currently hardcoded for emacs-lisp but it might be useful nonetheless.
>
> (Anyone know how to make blogspot line wrap?)
>
>
> r.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-09-19 21:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-19 1:48 org-babel - utility to ease chopping src chunks into smaller org entries Richard Riley
2010-09-19 18:21 ` Eric Schulte [this message]
2010-09-19 22:03 ` Richard Riley
2010-09-19 23:20 ` Richard Riley
2010-09-20 3:41 ` Eric Schulte
2010-09-20 5:18 ` Richard Riley
2010-09-20 14:30 ` Eric Schulte
2010-09-20 15:15 ` Sébastien Vauban
2010-09-20 22:21 ` Sébastien Vauban
2010-09-21 12:46 ` Eric Schulte
2010-09-21 13:49 ` Dan Davison
2010-09-21 14:37 ` Sébastien Vauban
2010-09-21 12:44 ` Eric Schulte
2010-09-21 15:19 ` Sébastien Vauban
2010-09-20 20:09 ` Dan Davison
2010-09-21 7:58 ` Christian Moe
2010-09-21 11:17 ` Richard Riley
2010-09-21 13:04 ` Eric Schulte
2010-09-21 14:35 ` Christian Moe
2010-09-21 14:50 ` Dan Davison
2010-09-21 15:35 ` Eric Schulte
2010-09-24 13:24 ` Requests about the code demarcation Sébastien Vauban
2010-09-27 13:18 ` Eric Schulte
2010-09-27 13:47 ` Sébastien Vauban
2010-09-27 14:36 ` Sébastien Vauban
2010-09-27 14:58 ` Eric Schulte
2010-09-30 18:17 ` Achim Gratz
2010-09-30 22:19 ` Eric Schulte
2010-10-01 19:28 ` Achim Gratz
2010-10-17 11:53 ` Richard Riley
2010-09-21 6:33 ` org-babel - utility to ease chopping src chunks into smaller org entries Achim Gratz
2010-09-21 13:01 ` Eric Schulte
2010-09-21 17:03 ` Achim Gratz
2010-09-19 21:24 ` Sébastien Vauban
2010-09-19 21:44 ` Richard Riley
2010-09-19 21:52 ` Sébastien Vauban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878w2xfllt.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=rileyrg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.