all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Jumping between source blocks in a file
@ 2015-11-27 13:59 Andrew Kirkpatrick
  2015-12-02  6:50 ` Martin Yrjölä
  2016-06-25  7:34 ` Xebar Saram
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Kirkpatrick @ 2015-11-27 13:59 UTC (permalink / raw)
  To: emacs-orgmode

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))

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-11-27 13:59 Jumping between source blocks in a file Andrew Kirkpatrick
@ 2015-12-02  6:50 ` Martin Yrjölä
  2015-12-02  9:07   ` Andreas Leha
  2016-06-25  7:34 ` Xebar Saram
  1 sibling, 1 reply; 8+ messages in thread
From: Martin Yrjölä @ 2015-12-02  6:50 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Andrew Kirkpatrick


Hi Andrew!

Andrew Kirkpatrick writes:

> If this is deemed useful, I'm happy to make changes suitable for
> inclusion in the project.

Thanks for sharing! I would certainly want these functions included in
org-mode by default. They streamline at least my literate programming
workflow substantially.

Cheers,
Martin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-12-02  6:50 ` Martin Yrjölä
@ 2015-12-02  9:07   ` Andreas Leha
  2015-12-02  9:38     ` Rainer M Krug
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Leha @ 2015-12-02  9:07 UTC (permalink / raw)
  To: emacs-orgmode

Hi Andrew,

Martin Yrjölä <martin.yrjola@gmail.com> writes:
> Hi Andrew!
>
> Andrew Kirkpatrick writes:
>
>> If this is deemed useful, I'm happy to make changes suitable for
>> inclusion in the project.
>
> Thanks for sharing! I would certainly want these functions included in
> org-mode by default. They streamline at least my literate programming
> workflow substantially.
>

Sorry for joining late.  I too find these useful.

(Also useful would be the possibility to jump to noweb references
directly from the src buffer...)

Regards,
Andreas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-12-02  9:07   ` Andreas Leha
@ 2015-12-02  9:38     ` Rainer M Krug
  2015-12-02  9:40       ` Rainer M Krug
  0 siblings, 1 reply; 8+ messages in thread
From: Rainer M Krug @ 2015-12-02  9:38 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1423 bytes --]

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi Andrew,
>
> Martin Yrjölä <martin.yrjola@gmail.com> writes:
>> Hi Andrew!
>>
>> Andrew Kirkpatrick writes:
>>
>>> If this is deemed useful, I'm happy to make changes suitable for
>>> inclusion in the project.
>>
>> Thanks for sharing! I would certainly want these functions included in
>> org-mode by default. They streamline at least my literate programming
>> workflow substantially.
>>
>
> Sorry for joining late.  I too find these useful.

Absolutely - very useful. Please include!
>
> (Also useful would be the possibility to jump to noweb references
> directly from the src buffer...)

Very nice idea indeed - or possibly even expand them when executing? But
I think this would be a job for the mode in the source buffer...

At the moment, these noweb references are very nice, but not so nice when
debugging a source block where they are used.

Cheers,

Rainer

>
> Regards,
> Andreas
>
>
>

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug

PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-12-02  9:38     ` Rainer M Krug
@ 2015-12-02  9:40       ` Rainer M Krug
  2015-12-02  9:49         ` Andreas Leha
  0 siblings, 1 reply; 8+ messages in thread
From: Rainer M Krug @ 2015-12-02  9:40 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1620 bytes --]

Rainer M Krug <Rainer@krugs.de> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Andrew,
>>
>> Martin Yrjölä <martin.yrjola@gmail.com> writes:
>>> Hi Andrew!
>>>
>>> Andrew Kirkpatrick writes:
>>>
>>>> If this is deemed useful, I'm happy to make changes suitable for
>>>> inclusion in the project.
>>>
>>> Thanks for sharing! I would certainly want these functions included in
>>> org-mode by default. They streamline at least my literate programming
>>> workflow substantially.
>>>
>>
>> Sorry for joining late.  I too find these useful.
>
> Absolutely - very useful. Please include!
>>
>> (Also useful would be the possibility to jump to noweb references
>> directly from the src buffer...)
>
> Very nice idea indeed - or possibly even expand them when executing? But
> I think this would be a job for the mode in the source buffer...

Actually, expand them when opening the Source Buffer (C-c ') and
possibly update them when closing?

>
> At the moment, these noweb references are very nice, but not so nice when
> debugging a source block where they are used.
>
> Cheers,
>
> Rainer
>
>>
>> Regards,
>> Andreas
>>
>>
>>

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug

PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-12-02  9:40       ` Rainer M Krug
@ 2015-12-02  9:49         ` Andreas Leha
  2015-12-02 10:33           ` Rainer M Krug
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Leha @ 2015-12-02  9:49 UTC (permalink / raw)
  To: emacs-orgmode

Rainer M Krug <Rainer@krugs.de> writes:
> Rainer M Krug <Rainer@krugs.de> writes:
>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi Andrew,
>>>
>>> Martin Yrjölä <martin.yrjola@gmail.com> writes:
>>>> Hi Andrew!
>>>>
>>>> Andrew Kirkpatrick writes:
>>>>
>>>>> If this is deemed useful, I'm happy to make changes suitable for
>>>>> inclusion in the project.
>>>>
>>>> Thanks for sharing! I would certainly want these functions included in
>>>> org-mode by default. They streamline at least my literate programming
>>>> workflow substantially.
>>>>
>>>
>>> Sorry for joining late.  I too find these useful.
>>
>> Absolutely - very useful. Please include!
>>>
>>> (Also useful would be the possibility to jump to noweb references
>>> directly from the src buffer...)
>>
>> Very nice idea indeed - or possibly even expand them when executing? But
>> I think this would be a job for the mode in the source buffer...
>
> Actually, expand them when opening the Source Buffer (C-c ') and
> possibly update them when closing?
>

This might conflict with open Source Buffers for the referenced code
block.

>>
>> At the moment, these noweb references are very nice, but not so nice when
>> debugging a source block where they are used.

Exactly.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-12-02  9:49         ` Andreas Leha
@ 2015-12-02 10:33           ` Rainer M Krug
  0 siblings, 0 replies; 8+ messages in thread
From: Rainer M Krug @ 2015-12-02 10:33 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2497 bytes --]

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Rainer M Krug <Rainer@krugs.de> writes:
>> Rainer M Krug <Rainer@krugs.de> writes:
>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi Andrew,
>>>>
>>>> Martin Yrjölä <martin.yrjola@gmail.com> writes:
>>>>> Hi Andrew!
>>>>>
>>>>> Andrew Kirkpatrick writes:
>>>>>
>>>>>> If this is deemed useful, I'm happy to make changes suitable for
>>>>>> inclusion in the project.
>>>>>
>>>>> Thanks for sharing! I would certainly want these functions included in
>>>>> org-mode by default. They streamline at least my literate programming
>>>>> workflow substantially.
>>>>>
>>>>
>>>> Sorry for joining late.  I too find these useful.
>>>
>>> Absolutely - very useful. Please include!
>>>>
>>>> (Also useful would be the possibility to jump to noweb references
>>>> directly from the src buffer...)
>>>
>>> Very nice idea indeed - or possibly even expand them when executing? But
>>> I think this would be a job for the mode in the source buffer...
>>
>> Actually, expand them when opening the Source Buffer (C-c ') and
>> possibly update them when closing?
>>
>
> This might conflict with open Source Buffers for the referenced code
> block.

True - than simply deliminate them with something like

## <<REF>> BEGIN
...
## <<REF>> END

and *don't* update them at the end?

Probably better: language specific - for R one could write the block to
a temporary file and then insert a =source()= to execute it:


## DO NOT EDIT - AUTO INSERTED - BEGIN
source("<<REF>>.R")
## DO NOT EDIT - AUTO INSERTED - END

Would make debugging much easier, if they would be in the source block
where they are used.

And if no language specific behavior is supplied, use the present
behavior.

>
>>>
>>> At the moment, these noweb references are very nice, but not so nice when
>>> debugging a source block where they are used.
>
> Exactly.

Let's do some brainstorming how this could be solved.

Cheers,

Rainer

>
> Regards,
> Andreas
>
>

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug

PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Jumping between source blocks in a file
  2015-11-27 13:59 Jumping between source blocks in a file Andrew Kirkpatrick
  2015-12-02  6:50 ` Martin Yrjölä
@ 2016-06-25  7:34 ` Xebar Saram
  1 sibling, 0 replies; 8+ messages in thread
From: Xebar Saram @ 2016-06-25  7:34 UTC (permalink / raw)
  To: Andrew Kirkpatrick; +Cc: org mode

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

thx alot Andrew!

Just discovered this and its so useful. it would be great if in the future
this could be integrated into org mode

best

Z

[-- Attachment #2: Type: text/html, Size: 394 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-25  7:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-27 13:59 Jumping between source blocks in a file Andrew Kirkpatrick
2015-12-02  6:50 ` Martin Yrjölä
2015-12-02  9:07   ` Andreas Leha
2015-12-02  9:38     ` Rainer M Krug
2015-12-02  9:40       ` Rainer M Krug
2015-12-02  9:49         ` Andreas Leha
2015-12-02 10:33           ` Rainer M Krug
2016-06-25  7:34 ` Xebar Saram

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.