* org-babel - utility to ease chopping src chunks into smaller org entries
@ 2010-09-19 1:48 Richard Riley
2010-09-19 18:21 ` Eric Schulte
2010-09-19 21:24 ` Sébastien Vauban
0 siblings, 2 replies; 36+ messages in thread
From: Richard Riley @ 2010-09-19 1:48 UTC (permalink / raw)
To: emacs-orgmode
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.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
2010-09-19 22:03 ` Richard Riley
2010-09-19 21:24 ` Sébastien Vauban
1 sibling, 1 reply; 36+ messages in thread
From: Eric Schulte @ 2010-09-19 18:21 UTC (permalink / raw)
To: Richard Riley; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
@ 2010-09-19 21:24 ` Sébastien Vauban
2010-09-19 21:44 ` Richard Riley
1 sibling, 1 reply; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-19 21:24 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Richard,
Richard Riley wrote:
> 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
That seems very interesting... and promising. It's the sort of thing I often
need to do as well, though maybe with slight differences from your code.
> Its currently hardcoded for emacs-lisp but it might be useful nonetheless.
Just a question (that could, maybe, make this limitation disappear): did you
try using Yasnippet (with its =yas/selected-text= possibilities) for this job?
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-19 21:24 ` Sébastien Vauban
@ 2010-09-19 21:44 ` Richard Riley
2010-09-19 21:52 ` Sébastien Vauban
0 siblings, 1 reply; 36+ messages in thread
From: Richard Riley @ 2010-09-19 21:44 UTC (permalink / raw)
To: emacs-orgmode
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>
writes:
> Hi Richard,
>
> Richard Riley wrote:
>> 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
>
> That seems very interesting... and promising. It's the sort of thing I often
> need to do as well, though maybe with slight differences from your code.
>
>> Its currently hardcoded for emacs-lisp but it might be useful nonetheless.
>
> Just a question (that could, maybe, make this limitation disappear): did you
> try using Yasnippet (with its =yas/selected-text= possibilities) for this job?
>
> Best regards,
> Seb
Nope. I never once managed to get yasnippet working in any way that
didnt conflict with tabbing for indentation or somehow start inserting
templates where I didnt want them. But I must admit I didn't try very
hard ;) If you want to share you yasnippet setup I will try it.
--
☘ http://www.shamrockirishbar.com, http://splash-of-open-sauce.blogspot.com/ http://www.richardriley.net
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-19 21:44 ` Richard Riley
@ 2010-09-19 21:52 ` Sébastien Vauban
0 siblings, 0 replies; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-19 21:52 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Richard,
Richard Riley wrote:
>> Just a question (that could, maybe, make this limitation disappear): did
>> you try using Yasnippet (with its =yas/selected-text= possibilities) for
>> this job?
>
> Nope. I never once managed to get yasnippet working in any way that didnt
> conflict with tabbing for indentation or somehow start inserting templates
> where I didnt want them. But I must admit I didn't try very hard ;) If you
> want to share you yasnippet setup I will try it.
I never went far neither. I just am aware of the existence of the above
function for a couple of weeks, and getting more out of it is on my TODO list.
Just wanted to share the knowledge, but I don't have more yet to share.
Coming soon?...
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-19 18:21 ` Eric Schulte
@ 2010-09-19 22:03 ` Richard Riley
2010-09-19 23:20 ` Richard Riley
0 siblings, 1 reply; 36+ messages in thread
From: Richard Riley @ 2010-09-19 22:03 UTC (permalink / raw)
To: emacs-orgmode
"Eric Schulte" <schulte.eric@gmail.com> writes:
>
> Let me know what you think. I notice your implementation uses
> regions,
It puts the begin/src markers around the region if selected or current word.
> 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.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-19 22:03 ` Richard Riley
@ 2010-09-19 23:20 ` Richard Riley
2010-09-20 3:41 ` Eric Schulte
0 siblings, 1 reply; 36+ messages in thread
From: Richard Riley @ 2010-09-19 23:20 UTC (permalink / raw)
To: emacs-orgmode
Richard Riley <rileyrg@gmail.com> writes:
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>>
>> Let me know what you think. I notice your implementation uses
>> regions,
>
> It puts the begin/src markers around the region if selected or current word.
>
>> 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.
>
> _______________________________________________
> 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
>
using your lang selection example
If not in a source block then just surround current region with
#+begin/end_src. If no region just put in markers around empty
area. Dont create new org items since probably just including src code
in an existing org item.
If in a source block with region create new region with current
region. If no region just create new empty block. previous src blocks
delimited and marked as org items at current level (because almost
certainly splitting the code to maintain it in discreate titled blocks.
--8<---------------cut here---------------start------------->8---
(define-key org-mode-map (kbd "C-c C-b") 'rgr/org-split-src)
(defun rgr/org-split-src(&optional arg)
(interactive "P")
(beginning-of-line)
(save-excursion((lambda(info)
(if info
(let ((lang (nth 0 info))
(stars (make-string (org-current-level) ?*)))
(insert
(format
"%s\n%s\n#+begin_src %s\n%s#+end_src\n%s\n#+begin_src %s\n"
"#+end_src"
stars
lang
(if (region-active-p)
(delete-and-extract-region (region-beginning) (region-end)) "\n")
stars
lang)))
(insert
(format
"\n#+begin_src\n%s\n#+end_src\n"
(if (region-active-p)
(delete-and-extract-region (region-beginning) (region-end)) "")))))
(org-babel-get-src-block-info))))
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-19 23:20 ` Richard Riley
@ 2010-09-20 3:41 ` Eric Schulte
2010-09-20 5:18 ` Richard Riley
2010-09-21 6:33 ` org-babel - utility to ease chopping src chunks into smaller org entries Achim Gratz
0 siblings, 2 replies; 36+ messages in thread
From: Eric Schulte @ 2010-09-20 3:41 UTC (permalink / raw)
To: Richard Riley; +Cc: emacs-orgmode
Hi Richard,
Richard Riley <rileyrg@gmail.com> writes:
> Richard Riley <rileyrg@gmail.com> writes:
>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>>>
>>> Let me know what you think. I notice your implementation uses
>>> regions,
>>
>> It puts the begin/src markers around the region if selected or current word.
>>
>>> 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.
>
> using your lang selection example
>
> If not in a source block then just surround current region with
> #+begin/end_src. If no region just put in markers around empty
> area. Dont create new org items since probably just including src code
> in an existing org item.
>
> If in a source block with region create new region with current
> region. If no region just create new empty block. previous src blocks
> delimited and marked as org items at current level (because almost
> certainly splitting the code to maintain it in discreate titled blocks.
>
>
I was just pulling up my email to share my next iteration when I saw
your next iteration. They look very similar. If my version covers all
of your use cases, then I'd like to add it to the Babel key map,
probably under "d" for demarcate or delimit, unless you can think of a
better mnemonic.
--8<---------------cut here---------------start------------->8---
(defun org-babel-demarcate-block (&optional arg)
"Wrap or split the code in the region or on the point."
(interactive "P")
(let ((info (org-babel-get-src-block-info)))
(if info
(mapc
(lambda (place)
(save-excursion
(goto-char place)
(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)))))
(sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
(insert (concat (if (looking-at "^") "" "\n")
(if arg (concat stars "\n") "")
"#+begin_src " (read-from-minibuffer "Lang: ") "\n"
(delete-and-extract-region (or (mark) (point)) (point))
"\n#+end_src"))
(previous-line) (move-end-of-line 1))))
--8<---------------cut here---------------end--------------->8---
Cheers -- Eric
>
>
> (define-key org-mode-map (kbd "C-c C-b") 'rgr/org-split-src)
>
> (defun rgr/org-split-src(&optional arg)
> (interactive "P")
> (beginning-of-line)
> (save-excursion((lambda(info)
> (if info
> (let ((lang (nth 0 info))
> (stars (make-string (org-current-level) ?*)))
> (insert
> (format
> "%s\n%s\n#+begin_src %s\n%s#+end_src\n%s\n#+begin_src %s\n"
> "#+end_src"
> stars
> lang
> (if (region-active-p)
> (delete-and-extract-region (region-beginning) (region-end)) "\n")
> stars
> lang)))
> (insert
> (format
> "\n#+begin_src\n%s\n#+end_src\n"
> (if (region-active-p)
> (delete-and-extract-region (region-beginning) (region-end)) "")))))
> (org-babel-get-src-block-info))))
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-20 3:41 ` Eric Schulte
@ 2010-09-20 5:18 ` Richard Riley
2010-09-20 14:30 ` Eric Schulte
2010-09-21 6:33 ` org-babel - utility to ease chopping src chunks into smaller org entries Achim Gratz
1 sibling, 1 reply; 36+ messages in thread
From: Richard Riley @ 2010-09-20 5:18 UTC (permalink / raw)
To: emacs-orgmode
"Eric Schulte" <schulte.eric@gmail.com> writes:
> Hi Richard,
>
> Richard Riley <rileyrg@gmail.com> writes:
>
>> Richard Riley <rileyrg@gmail.com> writes:
>>
>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>
>>>>
>>>> Let me know what you think. I notice your implementation uses
>>>> regions,
>>>
>>> It puts the begin/src markers around the region if selected or current word.
>>>
>>>> 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.
>>
>> using your lang selection example
>>
>> If not in a source block then just surround current region with
>> #+begin/end_src. If no region just put in markers around empty
>> area. Dont create new org items since probably just including src code
>> in an existing org item.
>>
>> If in a source block with region create new region with current
>> region. If no region just create new empty block. previous src blocks
>> delimited and marked as org items at current level (because almost
>> certainly splitting the code to maintain it in discreate titled blocks.
>>
>>
>
> I was just pulling up my email to share my next iteration when I saw
> your next iteration. They look very similar. If my version covers all
> of your use cases, then I'd like to add it to the Babel key map,
> probably under "d" for demarcate or delimit, unless you can think of a
> better mnemonic.
Not in the babel key map - in the org key map (I use it most in normal
non src org entries to mark a block of elisp as src for samples/examples).
But,yes I suspect your code is better ;) Note my func works in two
fundamentally different ways - in a babel src block where it creates new org
items and also in normal (non src) modes where it just creates a src block.
>
>
>
>
> --8<---------------cut here---------------start------------->8---
> (defun org-babel-demarcate-block (&optional arg)
> "Wrap or split the code in the region or on the point."
> (interactive "P")
> (let ((info (org-babel-get-src-block-info)))
> (if info
> (mapc
> (lambda (place)
> (save-excursion
> (goto-char place)
> (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)))))
> (sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
> (insert (concat (if (looking-at "^") "" "\n")
> (if arg (concat stars "\n") "")
> "#+begin_src " (read-from-minibuffer "Lang: ") "\n"
> (delete-and-extract-region (or (mark) (point)) (point))
> "\n#+end_src"))
> (previous-line) (move-end-of-line 1))))
> --8<---------------cut here---------------end--------------->8---
>
>
>
> Cheers -- Eric
>
>>
>>
>> (define-key org-mode-map (kbd "C-c C-b") 'rgr/org-split-src)
>>
>> (defun rgr/org-split-src(&optional arg)
>> (interactive "P")
>> (beginning-of-line)
>> (save-excursion((lambda(info)
>> (if info
>> (let ((lang (nth 0 info))
>> (stars (make-string (org-current-level) ?*)))
>> (insert
>> (format
>> "%s\n%s\n#+begin_src %s\n%s#+end_src\n%s\n#+begin_src %s\n"
>> "#+end_src"
>> stars
>> lang
>> (if (region-active-p)
>> (delete-and-extract-region (region-beginning) (region-end)) "\n")
>> stars
>> lang)))
>> (insert
>> (format
>> "\n#+begin_src\n%s\n#+end_src\n"
>> (if (region-active-p)
>> (delete-and-extract-region (region-beginning) (region-end)) "")))))
>> (org-babel-get-src-block-info))))
>>
>
> _______________________________________________
> 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
>
>
--
☘ http://www.shamrockirishbar.com, http://splash-of-open-sauce.blogspot.com/ http://www.richardriley.net
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
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 20:09 ` Dan Davison
0 siblings, 2 replies; 36+ messages in thread
From: Eric Schulte @ 2010-09-20 14:30 UTC (permalink / raw)
To: Richard Riley; +Cc: emacs-orgmode
Richard Riley <rileyrg@gmail.com> writes:
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Hi Richard,
>>
>> Richard Riley <rileyrg@gmail.com> writes:
>>
>>> Richard Riley <rileyrg@gmail.com> writes:
>>>
>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>>
>>>>>
>>>>> Let me know what you think. I notice your implementation uses
>>>>> regions,
>>>>
>>>> It puts the begin/src markers around the region if selected or current word.
>>>>
>>>>> 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.
>>>
>>> using your lang selection example
>>>
>>> If not in a source block then just surround current region with
>>> #+begin/end_src. If no region just put in markers around empty
>>> area. Dont create new org items since probably just including src code
>>> in an existing org item.
>>>
>>> If in a source block with region create new region with current
>>> region. If no region just create new empty block. previous src blocks
>>> delimited and marked as org items at current level (because almost
>>> certainly splitting the code to maintain it in discreate titled blocks.
>>>
>>>
>>
>> I was just pulling up my email to share my next iteration when I saw
>> your next iteration. They look very similar. If my version covers all
>> of your use cases, then I'd like to add it to the Babel key map,
>> probably under "d" for demarcate or delimit, unless you can think of a
>> better mnemonic.
>
>
I've just added this to the org-mode repo.
>
> Not in the babel key map - in the org key map (I use it most in normal
> non src org entries to mark a block of elisp as src for samples/examples).
For now it still lives in the babel keymap behind (C-c C-v d) since it
is fundamentally code-block related, however it can be called from
anywhere in an org-mode file, and could of course be bound to any other
key sequence in a personal config.
>
> But,yes I suspect your code is better ;) Note my func works in two
> fundamentally different ways - in a babel src block where it creates
> new org items and also in normal (non src) modes where it just creates
> a src block.
>
I believe both of those use cases are supported by the current version
of the function.
Thanks -- Eric
>
>>
>>
>>
>>
>> --8<---------------cut here---------------start------------->8---
>> (defun org-babel-demarcate-block (&optional arg)
>> "Wrap or split the code in the region or on the point."
>> (interactive "P")
>> (let ((info (org-babel-get-src-block-info)))
>> (if info
>> (mapc
>> (lambda (place)
>> (save-excursion
>> (goto-char place)
>> (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)))))
>> (sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
>> (insert (concat (if (looking-at "^") "" "\n")
>> (if arg (concat stars "\n") "")
>> "#+begin_src " (read-from-minibuffer "Lang: ") "\n"
>> (delete-and-extract-region (or (mark) (point)) (point))
>> "\n#+end_src"))
>> (previous-line) (move-end-of-line 1))))
>> --8<---------------cut here---------------end--------------->8---
>>
>>
>>
>> Cheers -- Eric
>>
>>>
>>>
>>> (define-key org-mode-map (kbd "C-c C-b") 'rgr/org-split-src)
>>>
>>> (defun rgr/org-split-src(&optional arg)
>>> (interactive "P")
>>> (beginning-of-line)
>>> (save-excursion((lambda(info)
>>> (if info
>>> (let ((lang (nth 0 info))
>>> (stars (make-string (org-current-level) ?*)))
>>> (insert
>>> (format
>>> "%s\n%s\n#+begin_src %s\n%s#+end_src\n%s\n#+begin_src %s\n"
>>> "#+end_src"
>>> stars
>>> lang
>>> (if (region-active-p)
>>> (delete-and-extract-region (region-beginning) (region-end)) "\n")
>>> stars
>>> lang)))
>>> (insert
>>> (format
>>> "\n#+begin_src\n%s\n#+end_src\n"
>>> (if (region-active-p)
>>> (delete-and-extract-region (region-beginning) (region-end)) "")))))
>>> (org-babel-get-src-block-info))))
>>>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
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:44 ` Eric Schulte
2010-09-20 20:09 ` Dan Davison
1 sibling, 2 replies; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-20 15:15 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
"Eric Schulte" wrote:
> I've just added [org-babel-demarcate-block] to the org-mode repo.
A comment. Consider the following, with a region beginning at =cmd1= and
ending after =cmd3= (in other words, a full block of 3 lines):
--8<---------------cut here---------------start------------->8---
Text before
cmd1
cmd2
cmd3
Text after
--8<---------------cut here---------------end--------------->8---
After invoking your function, I get this:
--8<---------------cut here---------------start------------->8---
Text before
#+begin_src sh
cmd1
cmd2
cmd3
#+end_src
Text after
--8<---------------cut here---------------end--------------->8---
Very good, except that I would expect the space line out of the code block, as
it was not in my selected text:
--8<---------------cut here---------------start------------->8---
Text before
#+begin_src sh
cmd1
cmd2
cmd3
#+end_src
Text after
--8<---------------cut here---------------end--------------->8---
Is this possible?
> For now it still lives in the babel keymap behind (C-c C-v d) since it
> is fundamentally code-block related, however it can be called from
> anywhere in an org-mode file, and could of course be bound to any other
> key sequence in a personal config.
I don't see any key binding (yet), after org-reload.
Thanks for this...
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-20 14:30 ` Eric Schulte
2010-09-20 15:15 ` Sébastien Vauban
@ 2010-09-20 20:09 ` Dan Davison
2010-09-21 7:58 ` Christian Moe
1 sibling, 1 reply; 36+ messages in thread
From: Dan Davison @ 2010-09-20 20:09 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Richard Riley
[...]
>>> I was just pulling up my email to share my next iteration when I saw
>>> your next iteration. They look very similar. If my version covers all
>>> of your use cases, then I'd like to add it to the Babel key map,
>>> probably under "d" for demarcate or delimit, unless you can think of a
>>> better mnemonic.
>
> I've just added this to the org-mode repo.
>
>> Not in the babel key map - in the org key map (I use it most in normal
>> non src org entries to mark a block of elisp as src for samples/examples).
>
> For now it still lives in the babel keymap behind (C-c C-v d) since it
> is fundamentally code-block related,
For me, "fundamentally code-block related", in the absence of
execution-related functionality, points to org-src.el rather than
org-babel, so I suggest naming this function
org-src-demarcate-block. The babel keymap is still a good place for a
binding -- I think it's reasonable for the babel keymap to accomodate
pure code block stuff in addition to execution/tangling stuff.
Dan
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
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 12:44 ` Eric Schulte
1 sibling, 1 reply; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-20 22:21 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
Sébastien Vauban wrote:
> "Eric Schulte" wrote:
>> I've just added [org-babel-demarcate-block] to the org-mode repo.
>
>> For now it still lives in the babel keymap behind (C-c C-v d) since it is
>> fundamentally code-block related, however it can be called from anywhere in
>> an org-mode file, and could of course be bound to any other key sequence in
>> a personal config.
>
> I don't see any key binding (yet), after org-reload.
Just on that one point of my posting: I know have the binding available at my
finger tips, after a shutdown and an Emacs restart.
Is it possible that =org-reload= did not reload the key maps?
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-20 3:41 ` Eric Schulte
2010-09-20 5:18 ` Richard Riley
@ 2010-09-21 6:33 ` Achim Gratz
2010-09-21 13:01 ` Eric Schulte
1 sibling, 1 reply; 36+ messages in thread
From: Achim Gratz @ 2010-09-21 6:33 UTC (permalink / raw)
To: emacs-orgmode
Hi Eric,
your commit 88b8b839 raises the following warnings during compile on
EMACS 23.1:
In org-babel-demarcate-block:
ob.el:1157:27:Warning: `previous-line' used from Lisp code
That command is designed for interactive use only
ob.el:1155:78:Warning: reference to free variable `stars'
ob.el:1159:55:Warning: `previous-line' used from Lisp code
That command is designed for interactive use only
In end of data:
ob.el:1826:1:Warning: the function `org-current-level' is not known to be
defined.
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
0 siblings, 2 replies; 36+ messages in thread
From: Christian Moe @ 2010-09-21 7:58 UTC (permalink / raw)
To: Dan Davison; +Cc: Richard Riley, emacs-orgmode
Hi,
I'm late to this discussion, but just a lateral thought:
Would you consider rewriting this as `org-demarcate-block' or similar,
to operate on all #+begin_...end blocks, not just src?
If generalized this function could be equally useful for non-src
blocks as well. Example blocks come immediately to mind, but there are
non-coding applications too.
For instance, I store many notes with quotes from various texts,
sometimes in fairly long =#+begin_quote= blocks, which I then need to
split up when I want to write an extended discussion of a passage,
quoting a few lines at a time.
For those who use verse blocks (I all too seldom have the need...), it
may be even more useful.
For personal use, I already have a little org-insert-block utility
function to insert/wrap [q]uote, [s]rc, e[x]ample, [v]erse or [o]ther
blocks at a keystroke. This works for me since I use at least the
first two more or less equally often. A generalized demarcate-block
function would be a nice complement.
Yours,
CM
>> I've just added this to the org-mode repo.
>>
>>> Not in the babel key map - in the org key map (I use it most in normal
>>> non src org entries to mark a block of elisp as src for samples/examples).
>>
>> For now it still lives in the babel keymap behind (C-c C-v d) since it
>> is fundamentally code-block related,
>
> For me, "fundamentally code-block related", in the absence of
> execution-related functionality, points to org-src.el rather than
> org-babel, so I suggest naming this function
> org-src-demarcate-block. The babel keymap is still a good place for a
> binding -- I think it's reasonable for the babel keymap to accomodate
> pure code block stuff in addition to execution/tangling stuff.
>
> Dan
>
> _______________________________________________
> 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
>
--
Christian Moe
E-mail: mail@christianmoe.com
Website: http://christianmoe.com
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 7:58 ` Christian Moe
@ 2010-09-21 11:17 ` Richard Riley
2010-09-21 13:04 ` Eric Schulte
1 sibling, 0 replies; 36+ messages in thread
From: Richard Riley @ 2010-09-21 11:17 UTC (permalink / raw)
To: emacs-orgmode
Christian Moe <mail@christianmoe.com> writes:
> Hi,
>
> I'm late to this discussion, but just a lateral thought:
>
> Would you consider rewriting this as `org-demarcate-block' or similar,
> to operate on all #+begin_...end blocks, not just src?
>
> If generalized this function could be equally useful for non-src
> blocks as well. Example blocks come immediately to mind, but there are
> non-coding applications too.
>
> For instance, I store many notes with quotes from various texts,
> sometimes in fairly long =#+begin_quote= blocks, which I then need to
> split up when I want to write an extended discussion of a passage,
> quoting a few lines at a time.
>
> For those who use verse blocks (I all too seldom have the need...), it
> may be even more useful.
I think thats a great idea.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-20 15:15 ` Sébastien Vauban
2010-09-20 22:21 ` Sébastien Vauban
@ 2010-09-21 12:44 ` Eric Schulte
2010-09-21 15:19 ` Sébastien Vauban
1 sibling, 1 reply; 36+ messages in thread
From: Eric Schulte @ 2010-09-21 12:44 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
Hi Seb,
Thanks for pointing this out, I've pushed up a fix to this spacing
issue.
Best -- Eric
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Hi Eric,
>
> "Eric Schulte" wrote:
>> I've just added [org-babel-demarcate-block] to the org-mode repo.
>
> A comment. Consider the following, with a region beginning at =cmd1= and
> ending after =cmd3= (in other words, a full block of 3 lines):
>
> Text before
>
> cmd1
> cmd2
> cmd3
>
> Text after
>
> After invoking your function, I get this:
>
> Text before
>
> #+begin_src sh
> cmd1
> cmd2
> cmd3
>
> #+end_src
> Text after
>
> Very good, except that I would expect the space line out of the code block, as
> it was not in my selected text:
>
> Text before
>
> #+begin_src sh
> cmd1
> cmd2
> cmd3
> #+end_src
>
> Text after
>
> Is this possible?
>
>
>> For now it still lives in the babel keymap behind (C-c C-v d) since it
>> is fundamentally code-block related, however it can be called from
>> anywhere in an org-mode file, and could of course be bound to any other
>> key sequence in a personal config.
>
> I don't see any key binding (yet), after org-reload.
>
> Thanks for this...
>
> Best regards,
> Seb
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
0 siblings, 2 replies; 36+ messages in thread
From: Eric Schulte @ 2010-09-21 12:46 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Hi Eric,
>
> Sébastien Vauban wrote:
>> "Eric Schulte" wrote:
>>> I've just added [org-babel-demarcate-block] to the org-mode repo.
>>
>>> For now it still lives in the babel keymap behind (C-c C-v d) since it is
>>> fundamentally code-block related, however it can be called from anywhere in
>>> an org-mode file, and could of course be bound to any other key sequence in
>>> a personal config.
>>
>> I don't see any key binding (yet), after org-reload.
>
> Just on that one point of my posting: I know have the binding available at my
> finger tips, after a shutdown and an Emacs restart.
>
> Is it possible that =org-reload= did not reload the key maps?
>
Hi Seb,
I suppose so, did you close and then re-open the org-mode buffer after
calling =org-reload=? I believe keymaps might be assigned only when a
buffer is first opened, so that could also be the culprit.
Best -- Eric
>
> Best regards,
> Seb
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
0 siblings, 1 reply; 36+ messages in thread
From: Eric Schulte @ 2010-09-21 13:01 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-orgmode
Hi Achim,
Thanks for pointing these warnings out, they are now fixed.
Achim Gratz <Stromeko@nexgo.de> writes:
> Hi Eric,
>
> your commit 88b8b839 raises the following warnings during compile on
> EMACS 23.1:
>
> In org-babel-demarcate-block:
> ob.el:1157:27:Warning: `previous-line' used from Lisp code
> That command is designed for interactive use only
> ob.el:1155:78:Warning: reference to free variable `stars'
> ob.el:1159:55:Warning: `previous-line' used from Lisp code
> That command is designed for interactive use only
>
> In end of data:
> ob.el:1826:1:Warning: the function `org-current-level' is not known to be
> defined.
>
>
> Achim.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
1 sibling, 1 reply; 36+ messages in thread
From: Eric Schulte @ 2010-09-21 13:04 UTC (permalink / raw)
To: mail; +Cc: Dan Davison, Richard Riley, emacs-orgmode
Hi Christian,
I agree generalizing this function over all block types would be very
useful. When I find the time I will make this change.
Thanks -- Eric
Christian Moe <mail@christianmoe.com> writes:
> Hi,
>
> I'm late to this discussion, but just a lateral thought:
>
> Would you consider rewriting this as `org-demarcate-block' or similar,
> to operate on all #+begin_...end blocks, not just src?
>
> If generalized this function could be equally useful for non-src
> blocks as well. Example blocks come immediately to mind, but there are
> non-coding applications too.
>
> For instance, I store many notes with quotes from various texts,
> sometimes in fairly long =#+begin_quote= blocks, which I then need to
> split up when I want to write an extended discussion of a passage,
> quoting a few lines at a time.
>
> For those who use verse blocks (I all too seldom have the need...), it
> may be even more useful.
>
> For personal use, I already have a little org-insert-block utility
> function to insert/wrap [q]uote, [s]rc, e[x]ample, [v]erse or [o]ther
> blocks at a keystroke. This works for me since I use at least the
> first two more or less equally often. A generalized demarcate-block
> function would be a nice complement.
>
> Yours,
> CM
>
>
>
>
>>> I've just added this to the org-mode repo.
>>>
>>>> Not in the babel key map - in the org key map (I use it most in normal
>>>> non src org entries to mark a block of elisp as src for samples/examples).
>>>
>>> For now it still lives in the babel keymap behind (C-c C-v d) since it
>>> is fundamentally code-block related,
>>
>> For me, "fundamentally code-block related", in the absence of
>> execution-related functionality, points to org-src.el rather than
>> org-babel, so I suggest naming this function
>> org-src-demarcate-block. The babel keymap is still a good place for a
>> binding -- I think it's reasonable for the babel keymap to accomodate
>> pure code block stuff in addition to execution/tangling stuff.
>>
>> Dan
>>
>> _______________________________________________
>> 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
>>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 12:46 ` Eric Schulte
@ 2010-09-21 13:49 ` Dan Davison
2010-09-21 14:37 ` Sébastien Vauban
1 sibling, 0 replies; 36+ messages in thread
From: Dan Davison @ 2010-09-21 13:49 UTC (permalink / raw)
To: Eric Schulte; +Cc: Sébastien Vauban, emacs-orgmode
"Eric Schulte" <schulte.eric@gmail.com> writes:
> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
>
>> Hi Eric,
>>
>> Sébastien Vauban wrote:
>>> "Eric Schulte" wrote:
>>>> I've just added [org-babel-demarcate-block] to the org-mode repo.
>>>
>>>> For now it still lives in the babel keymap behind (C-c C-v d) since it is
>>>> fundamentally code-block related, however it can be called from anywhere in
>>>> an org-mode file, and could of course be bound to any other key sequence in
>>>> a personal config.
>>>
>>> I don't see any key binding (yet), after org-reload.
>>
>> Just on that one point of my posting: I know have the binding available at my
>> finger tips, after a shutdown and an Emacs restart.
>>
>> Is it possible that =org-reload= did not reload the key maps?
On a related note, is there a reasonable way to get defvars, defcustoms
etc to respond to a change in their default value? Org-reload
(i.e. `load') does not deal with them which makes me slightly
distrustful of using it.
Dan
>>
>
> Hi Seb,
>
> I suppose so, did you close and then re-open the org-mode buffer after
> calling =org-reload=? I believe keymaps might be assigned only when a
> buffer is first opened, so that could also be the culprit.
>
> Best -- Eric
>
>>
>> Best regards,
>> Seb
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 13:04 ` Eric Schulte
@ 2010-09-21 14:35 ` Christian Moe
2010-09-21 14:50 ` Dan Davison
0 siblings, 1 reply; 36+ messages in thread
From: Christian Moe @ 2010-09-21 14:35 UTC (permalink / raw)
To: Eric Schulte; +Cc: Dan Davison, Richard Riley, emacs-orgmode
Hi Eric,
Great, thanks.
Christian
On 9/21/10 3:04 PM, Eric Schulte wrote:
> Hi Christian,
>
> I agree generalizing this function over all block types would be very
> useful. When I find the time I will make this change.
>
> Thanks -- Eric
>
> Christian Moe<mail@christianmoe.com> writes:
>
>> Hi,
>>
>> I'm late to this discussion, but just a lateral thought:
>>
>> Would you consider rewriting this as `org-demarcate-block' or similar,
>> to operate on all #+begin_...end blocks, not just src?
>>
>> If generalized this function could be equally useful for non-src
>> blocks as well. Example blocks come immediately to mind, but there are
>> non-coding applications too.
>>
>> For instance, I store many notes with quotes from various texts,
>> sometimes in fairly long =#+begin_quote= blocks, which I then need to
>> split up when I want to write an extended discussion of a passage,
>> quoting a few lines at a time.
>>
>> For those who use verse blocks (I all too seldom have the need...), it
>> may be even more useful.
>>
>> For personal use, I already have a little org-insert-block utility
>> function to insert/wrap [q]uote, [s]rc, e[x]ample, [v]erse or [o]ther
>> blocks at a keystroke. This works for me since I use at least the
>> first two more or less equally often. A generalized demarcate-block
>> function would be a nice complement.
>>
>> Yours,
>> CM
>>
>>
>>
>>
>>>> I've just added this to the org-mode repo.
>>>>
>>>>> Not in the babel key map - in the org key map (I use it most in normal
>>>>> non src org entries to mark a block of elisp as src for samples/examples).
>>>>
>>>> For now it still lives in the babel keymap behind (C-c C-v d) since it
>>>> is fundamentally code-block related,
>>>
>>> For me, "fundamentally code-block related", in the absence of
>>> execution-related functionality, points to org-src.el rather than
>>> org-babel, so I suggest naming this function
>>> org-src-demarcate-block. The babel keymap is still a good place for a
>>> binding -- I think it's reasonable for the babel keymap to accomodate
>>> pure code block stuff in addition to execution/tangling stuff.
>>>
>>> Dan
>>>
>>> _______________________________________________
>>> 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
>>>
>
--
Christian Moe
E-mail: mail@christianmoe.com
Website: http://christianmoe.com
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 12:46 ` Eric Schulte
2010-09-21 13:49 ` Dan Davison
@ 2010-09-21 14:37 ` Sébastien Vauban
1 sibling, 0 replies; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-21 14:37 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
"Eric Schulte" wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> Sébastien Vauban wrote:
>>> "Eric Schulte" wrote:
>>>> I've just added [org-babel-demarcate-block] to the org-mode repo.
>>>
>>> I don't see any key binding (yet), after org-reload.
>>
>> Just on that one point of my posting: I know have the binding available at
>> my finger tips, after a shutdown and an Emacs restart.
>>
>> Is it possible that =org-reload= did not reload the key maps?
>
> I suppose so, did you close and then re-open the org-mode buffer after
> calling =org-reload=?
Dunno anymore, but most probably not... Almost sure.
> I believe keymaps might be assigned only when a buffer is first opened, so
> that could also be the culprit.
That would be it, then. Thanks.
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 14:35 ` Christian Moe
@ 2010-09-21 14:50 ` Dan Davison
2010-09-21 15:35 ` Eric Schulte
0 siblings, 1 reply; 36+ messages in thread
From: Dan Davison @ 2010-09-21 14:50 UTC (permalink / raw)
To: mail; +Cc: Richard Riley, emacs-orgmode
Christian -- thanks, I think your suggestion is better than mine.
Eric -- here's a small change that allows it to work before the first
headline. (protected from patchwork I hope)
Dan
--8<---------------cut here---------------start------------->8---
X diff --git a/lisp/ob.el b/lisp/ob.el
X index e3f9fc7..655a79d 100644
X --- a/lisp/ob.el
X +++ b/lisp/ob.el
X @@ -1146,7 +1146,8 @@ region is not active then the point is demarcated."
X (goto-char place)
X (let ((lang (nth 0 info))
X (indent (make-string (nth 6 info) ? ))
X - (stars (concat (make-string (org-current-level) ?*) " ")))
X + (stars
X + (concat (make-string (or (org-current-level) 0) ?*) " ")))
X (when (string-match "^[[:space:]]*$"
X (buffer-substring (point-at-bol)
X (point-at-eol)))
X @@ -1161,7 +1162,7 @@ region is not active then the point is demarcated."
X (let ((start (point))
X (body (delete-and-extract-region
X (if (region-active-p) (mark) (point)) (point)))
X - (stars (concat (make-string (org-current-level) ?*) " ")))
X + (stars (concat (make-string (or (org-current-level) 0) ?*) " ")))
X (insert (concat (if (looking-at "^") "" "\n")
X (if arg (concat stars "\n") "")
X "#+begin_src " (read-from-minibuffer "Lang: ") "\n"
X
--8<---------------cut here---------------end--------------->8---
Christian Moe <mail@christianmoe.com> writes:
> Hi Eric,
>
> Great, thanks.
>
> Christian
>
> On 9/21/10 3:04 PM, Eric Schulte wrote:
>> Hi Christian,
>>
>> I agree generalizing this function over all block types would be very
>> useful. When I find the time I will make this change.
>>
>> Thanks -- Eric
>>
>> Christian Moe<mail@christianmoe.com> writes:
>>
>>> Hi,
>>>
>>> I'm late to this discussion, but just a lateral thought:
>>>
>>> Would you consider rewriting this as `org-demarcate-block' or similar,
>>> to operate on all #+begin_...end blocks, not just src?
>>>
>>> If generalized this function could be equally useful for non-src
>>> blocks as well. Example blocks come immediately to mind, but there are
>>> non-coding applications too.
>>>
>>> For instance, I store many notes with quotes from various texts,
>>> sometimes in fairly long =#+begin_quote= blocks, which I then need to
>>> split up when I want to write an extended discussion of a passage,
>>> quoting a few lines at a time.
>>>
>>> For those who use verse blocks (I all too seldom have the need...), it
>>> may be even more useful.
>>>
>>> For personal use, I already have a little org-insert-block utility
>>> function to insert/wrap [q]uote, [s]rc, e[x]ample, [v]erse or [o]ther
>>> blocks at a keystroke. This works for me since I use at least the
>>> first two more or less equally often. A generalized demarcate-block
>>> function would be a nice complement.
>>>
>>> Yours,
>>> CM
>>>
>>>
>>>
>>>
>>>>> I've just added this to the org-mode repo.
>>>>>
>>>>>> Not in the babel key map - in the org key map (I use it most in normal
>>>>>> non src org entries to mark a block of elisp as src for samples/examples).
>>>>>
>>>>> For now it still lives in the babel keymap behind (C-c C-v d) since it
>>>>> is fundamentally code-block related,
>>>>
>>>> For me, "fundamentally code-block related", in the absence of
>>>> execution-related functionality, points to org-src.el rather than
>>>> org-babel, so I suggest naming this function
>>>> org-src-demarcate-block. The babel keymap is still a good place for a
>>>> binding -- I think it's reasonable for the babel keymap to accomodate
>>>> pure code block stuff in addition to execution/tangling stuff.
>>>>
>>>> Dan
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 12:44 ` Eric Schulte
@ 2010-09-21 15:19 ` Sébastien Vauban
0 siblings, 0 replies; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-21 15:19 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
"Eric Schulte" wrote:
> Thanks for pointing this out, I've pushed up a fix to this spacing issue.
Perfect. Fix tested. Confirmed OK. Thanks.
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: org-babel - utility to ease chopping src chunks into smaller org entries
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
0 siblings, 1 reply; 36+ messages in thread
From: Eric Schulte @ 2010-09-21 15:35 UTC (permalink / raw)
To: Dan Davison; +Cc: Richard Riley, emacs-orgmode, mail
Applied, Thanks
Dan Davison <davison@stats.ox.ac.uk> writes:
> Christian -- thanks, I think your suggestion is better than mine.
>
> Eric -- here's a small change that allows it to work before the first
> headline. (protected from patchwork I hope)
>
> Dan
>
> X diff --git a/lisp/ob.el b/lisp/ob.el
> X index e3f9fc7..655a79d 100644
> X --- a/lisp/ob.el
> X +++ b/lisp/ob.el
> X @@ -1146,7 +1146,8 @@ region is not active then the point is demarcated."
> X (goto-char place)
> X (let ((lang (nth 0 info))
> X (indent (make-string (nth 6 info) ? ))
> X - (stars (concat (make-string (org-current-level) ?*) " ")))
> X + (stars
> X + (concat (make-string (or (org-current-level) 0) ?*) " ")))
> X (when (string-match "^[[:space:]]*$"
> X (buffer-substring (point-at-bol)
> X (point-at-eol)))
> X @@ -1161,7 +1162,7 @@ region is not active then the point is demarcated."
> X (let ((start (point))
> X (body (delete-and-extract-region
> X (if (region-active-p) (mark) (point)) (point)))
> X - (stars (concat (make-string (org-current-level) ?*) " ")))
> X + (stars (concat (make-string (or (org-current-level) 0) ?*) " ")))
> X (insert (concat (if (looking-at "^") "" "\n")
> X (if arg (concat stars "\n") "")
> X "#+begin_src " (read-from-minibuffer "Lang: ") "\n"
> X
>
>
> Christian Moe <mail@christianmoe.com> writes:
>
>> Hi Eric,
>>
>> Great, thanks.
>>
>> Christian
>>
>> On 9/21/10 3:04 PM, Eric Schulte wrote:
>>> Hi Christian,
>>>
>>> I agree generalizing this function over all block types would be very
>>> useful. When I find the time I will make this change.
>>>
>>> Thanks -- Eric
>>>
>>> Christian Moe<mail@christianmoe.com> writes:
>>>
>>>> Hi,
>>>>
>>>> I'm late to this discussion, but just a lateral thought:
>>>>
>>>> Would you consider rewriting this as `org-demarcate-block' or similar,
>>>> to operate on all #+begin_...end blocks, not just src?
>>>>
>>>> If generalized this function could be equally useful for non-src
>>>> blocks as well. Example blocks come immediately to mind, but there are
>>>> non-coding applications too.
>>>>
>>>> For instance, I store many notes with quotes from various texts,
>>>> sometimes in fairly long =#+begin_quote= blocks, which I then need to
>>>> split up when I want to write an extended discussion of a passage,
>>>> quoting a few lines at a time.
>>>>
>>>> For those who use verse blocks (I all too seldom have the need...), it
>>>> may be even more useful.
>>>>
>>>> For personal use, I already have a little org-insert-block utility
>>>> function to insert/wrap [q]uote, [s]rc, e[x]ample, [v]erse or [o]ther
>>>> blocks at a keystroke. This works for me since I use at least the
>>>> first two more or less equally often. A generalized demarcate-block
>>>> function would be a nice complement.
>>>>
>>>> Yours,
>>>> CM
>>>>
>>>>
>>>>
>>>>
>>>>>> I've just added this to the org-mode repo.
>>>>>>
>>>>>>> Not in the babel key map - in the org key map (I use it most in normal
>>>>>>> non src org entries to mark a block of elisp as src for samples/examples).
>>>>>>
>>>>>> For now it still lives in the babel keymap behind (C-c C-v d) since it
>>>>>> is fundamentally code-block related,
>>>>>
>>>>> For me, "fundamentally code-block related", in the absence of
>>>>> execution-related functionality, points to org-src.el rather than
>>>>> org-babel, so I suggest naming this function
>>>>> org-src-demarcate-block. The babel keymap is still a good place for a
>>>>> binding -- I think it's reasonable for the babel keymap to accomodate
>>>>> pure code block stuff in addition to execution/tangling stuff.
>>>>>
>>>>> Dan
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>>
>>>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: org-babel - utility to ease chopping src chunks into smaller org entries
2010-09-21 13:01 ` Eric Schulte
@ 2010-09-21 17:03 ` Achim Gratz
0 siblings, 0 replies; 36+ messages in thread
From: Achim Gratz @ 2010-09-21 17:03 UTC (permalink / raw)
To: emacs-orgmode
Fix confirmed.
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
DIY Stuff:
http://Synth.Stromeko.net/DIY.html
^ permalink raw reply [flat|nested] 36+ messages in thread
* Requests about the code demarcation
2010-09-21 15:35 ` Eric Schulte
@ 2010-09-24 13:24 ` Sébastien Vauban
2010-09-27 13:18 ` Eric Schulte
0 siblings, 1 reply; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-24 13:24 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric and Richard,
"Eric Schulte" wrote:
> Applied, Thanks
Two comments about that great function:
- Would it be possible to leave the code where it is, and have it selected (in
a region), when the question about the language is asked?
Currently, it seems to be temporarily "cut", and I sometimes hesitate about
which language I wanna choose (moreover, when the right language does not
exist, such as for demarcating an extract of config file). Would the code
chunk stay visible, it'd be easier...
- Is it possible to envision completion of the language name? Writing
=emacs-lisp= could become easier...
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Requests about the code demarcation
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-30 18:17 ` Achim Gratz
0 siblings, 2 replies; 36+ messages in thread
From: Eric Schulte @ 2010-09-27 13:18 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
Hi Seb,
Thanks for the suggestions, I've just implemented them.
Best -- Eric
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Hi Eric and Richard,
>
> "Eric Schulte" wrote:
>> Applied, Thanks
>
> Two comments about that great function:
>
> - Would it be possible to leave the code where it is, and have it selected (in
> a region), when the question about the language is asked?
>
> Currently, it seems to be temporarily "cut", and I sometimes hesitate about
> which language I wanna choose (moreover, when the right language does not
> exist, such as for demarcating an extract of config file). Would the code
> chunk stay visible, it'd be easier...
>
> - Is it possible to envision completion of the language name? Writing
> =emacs-lisp= could become easier...
>
> Best regards,
> Seb
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Requests about the code demarcation
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-30 18:17 ` Achim Gratz
1 sibling, 1 reply; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-27 13:47 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
"Eric Schulte" wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> Two comments about that great function:
>>
>> - Would it be possible to leave the code where it is, and have it selected
>> (in a region), when the question about the language is asked?
>>
>> Currently, it seems to be temporarily "cut", and I sometimes hesitate
>> about which language I wanna choose (moreover, when the right language
>> does not exist, such as for demarcating an extract of config file). Would
>> the code chunk stay visible, it'd be easier...
>>
>> - Is it possible to envision completion of the language name? Writing
>> =emacs-lisp= could become easier...
>
> Thanks for the suggestions, I've just implemented them.
Tested. Simply fan-tas-tic!
Thanks a lot...
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Requests about the code demarcation
2010-09-27 13:47 ` Sébastien Vauban
@ 2010-09-27 14:36 ` Sébastien Vauban
2010-09-27 14:58 ` Eric Schulte
0 siblings, 1 reply; 36+ messages in thread
From: Sébastien Vauban @ 2010-09-27 14:36 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
Sébastien Vauban wrote:
> "Eric Schulte" wrote:
>> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw-XMD5yJDbdMRG2NFembrH+g@public.gmane.orgorg> writes:
>>> Is it possible to envision completion of the language name? Writing
>>> =emacs-lisp= could become easier...
>>
>> Thanks for the suggestions, I've just implemented them.
>
> Tested. Simply fan-tas-tic!
Just one question: about =quote= and such environments, I don't remember if it
already is supported by the code demarcation, or has just been discussed so
far.
- In the first case, it would be missing from the list of "languages".
- In the second case, I'm not in a hurry -- I really don't use such
environments yet!
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: Requests about the code demarcation
2010-09-27 14:36 ` Sébastien Vauban
@ 2010-09-27 14:58 ` Eric Schulte
0 siblings, 0 replies; 36+ messages in thread
From: Eric Schulte @ 2010-09-27 14:58 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: emacs-orgmode
Hi Seb,
I plan to extend the block demarcation function to all block types, but
haven't yet found the time.
Best -- Eric
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Hi Eric,
>
> Sébastien Vauban wrote:
>> "Eric Schulte" wrote:
>>> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>>>> Is it possible to envision completion of the language name? Writing
>>>> =emacs-lisp= could become easier...
>>>
>>> Thanks for the suggestions, I've just implemented them.
>>
>> Tested. Simply fan-tas-tic!
>
> Just one question: about =quote= and such environments, I don't remember if it
> already is supported by the code demarcation, or has just been discussed so
> far.
>
> - In the first case, it would be missing from the list of "languages".
> - In the second case, I'm not in a hurry -- I really don't use such
> environments yet!
>
> Best regards,
> Seb
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Requests about the code demarcation
2010-09-27 13:18 ` Eric Schulte
2010-09-27 13:47 ` Sébastien Vauban
@ 2010-09-30 18:17 ` Achim Gratz
2010-09-30 22:19 ` Eric Schulte
2010-10-17 11:53 ` Richard Riley
1 sibling, 2 replies; 36+ messages in thread
From: Achim Gratz @ 2010-09-30 18:17 UTC (permalink / raw)
To: emacs-orgmode
"Eric Schulte" <schulte.eric@gmail.com> writes:
> Thanks for the suggestions, I've just implemented them.
This likely relates to commit eb0068e9, which raises this warning
In org-babel-demarcate-block:
ob.el:1141:49:Warning: reference to free variable `org-babel-load-languages'
during byte-compile.
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Re: Requests about the code demarcation
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
1 sibling, 1 reply; 36+ messages in thread
From: Eric Schulte @ 2010-09-30 22:19 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-orgmode
Fixed, Thanks -- Eric
Achim Gratz <Stromeko@nexgo.de> writes:
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> Thanks for the suggestions, I've just implemented them.
>
> This likely relates to commit eb0068e9, which raises this warning
>
> In org-babel-demarcate-block:
> ob.el:1141:49:Warning: reference to free variable `org-babel-load-languages'
>
> during byte-compile.
>
>
> Achim.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Requests about the code demarcation
2010-09-30 22:19 ` Eric Schulte
@ 2010-10-01 19:28 ` Achim Gratz
0 siblings, 0 replies; 36+ messages in thread
From: Achim Gratz @ 2010-10-01 19:28 UTC (permalink / raw)
To: emacs-orgmode
"Eric Schulte" <schulte.eric@gmail.com> writes:
> Fixed, Thanks -- Eric
Confirmed.
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Requests about the code demarcation
2010-09-30 18:17 ` Achim Gratz
2010-09-30 22:19 ` Eric Schulte
@ 2010-10-17 11:53 ` Richard Riley
1 sibling, 0 replies; 36+ messages in thread
From: Richard Riley @ 2010-10-17 11:53 UTC (permalink / raw)
To: emacs-orgmode
Achim Gratz <Stromeko@nexgo.de> writes:
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> Thanks for the suggestions, I've just implemented them.
>
> This likely relates to commit eb0068e9, which raises this warning
>
> In org-babel-demarcate-block:
> ob.el:1141:49:Warning: reference to free variable `org-babel-load-languages'
>
> during byte-compile.
>
> Achim.
Just a note on the key bindings for src code splitting/marking - there
is already a very similar function inside Gnus:-
--8<---------------cut here---------------start------------->8---
C-c M-m runs the command message-mark-inserted-region, which is an interactive
compiled Lisp function in `message.el'.
It is bound to C-c M-m, <menu-bar> <Message> <Insert Region Marked>.
(message-mark-inserted-region BEG END &optional VERBATIM)
Mark some region in the current article with enclosing tags.
See `message-mark-insert-begin' and `message-mark-insert-end'.
If VERBATIM, use slrn style verbatim marks ("#v+" and "#v-").
--8<---------------cut here---------------end--------------->8---
Possibly the keybinding to use?
regards
r.
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2010-10-17 11:53 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).