* org-detangle seems broken
@ 2018-06-01 17:27 Frederick Giasson
2018-06-02 10:17 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Frederick Giasson @ 2018-06-01 17:27 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 778 bytes --]
Hi Everybody,
It appears that org-detangle is broken. I am using spacemacs, but even with
a vanilla Emacs (emacs -Q) it appears to be broken.
When I tangle a file with =:comments link= every things works as expected
and the comments are added in the tangled file.
When I just detangle that tangled file, everything get detangled as
expected.
If I change one or two lines, it normally works as expected.
If I change more than 4 lines, I always get the error message "Not in a
block file".
Some debugging shows that the function =org-element-at-point= sometimes tag
the element as =paragraph= instead of =src-block=, like if it doesn't know
where it is... somehow.
Does anybody use that function without experiencing this (apparent major)
issue?
Thanks,
Take care,
Fred
[-- Attachment #2: Type: text/html, Size: 1069 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-01 17:27 org-detangle seems broken Frederick Giasson
@ 2018-06-02 10:17 ` Nicolas Goaziou
2018-06-04 12:42 ` Frederick Giasson
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-06-02 10:17 UTC (permalink / raw)
To: Frederick Giasson; +Cc: emacs-orgmode
Hello,
Frederick Giasson <fred@curbside.com> writes:
> It appears that org-detangle is broken. I am using spacemacs, but even with
> a vanilla Emacs (emacs -Q) it appears to be broken.
>
> When I tangle a file with =:comments link= every things works as expected
> and the comments are added in the tangled file.
>
> When I just detangle that tangled file, everything get detangled as
> expected.
>
> If I change one or two lines, it normally works as expected.
>
> If I change more than 4 lines, I always get the error message "Not in a
> block file".
>
> Some debugging shows that the function =org-element-at-point= sometimes tag
> the element as =paragraph= instead of =src-block=, like if it doesn't know
> where it is... somehow.
>
> Does anybody use that function without experiencing this (apparent major)
> issue?
Could you provide an ECM demonstrating the issue?
Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-02 10:17 ` Nicolas Goaziou
@ 2018-06-04 12:42 ` Frederick Giasson
2018-06-05 9:59 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Frederick Giasson @ 2018-06-04 12:42 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 1460 bytes --]
Hi Nicolas,
Here it is. If you =detangle= the =broken-detangle--working.el= file, it
will work as expected.
However, if you try to detangle the =broken-detangle--NOT-working.el= file,
you should get a "Not in a source block" error in *message*.
Another thing I noted while creating the ECM is if there is only *one* code
block in the =.org= file, then it throws a =End of Buffer= error.
On Sat, Jun 2, 2018 at 6:17 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Frederick Giasson <fred@curbside.com> writes:
>
> > It appears that org-detangle is broken. I am using spacemacs, but even
> with
> > a vanilla Emacs (emacs -Q) it appears to be broken.
> >
> > When I tangle a file with =:comments link= every things works as expected
> > and the comments are added in the tangled file.
> >
> > When I just detangle that tangled file, everything get detangled as
> > expected.
> >
> > If I change one or two lines, it normally works as expected.
> >
> > If I change more than 4 lines, I always get the error message "Not in a
> > block file".
> >
> > Some debugging shows that the function =org-element-at-point= sometimes
> tag
> > the element as =paragraph= instead of =src-block=, like if it doesn't
> know
> > where it is... somehow.
> >
> > Does anybody use that function without experiencing this (apparent major)
> > issue?
>
> Could you provide an ECM demonstrating the issue?
>
> Thank you.
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #1.2: Type: text/html, Size: 2174 bytes --]
[-- Attachment #2: broken-detangle.org --]
[-- Type: application/octet-stream, Size: 900 bytes --]
* Experience broken detangle
In this example, if we tangle this file and immediately detangle it, everything is working as expected without error messages from Org.
#+BEGIN_SRC elisp :tangle broken-detangle.el :comments link
(defun test
(message "broken detangle"))
#+END_SRC
If I update the *source* file with the following code and that I detangle it, it works as expected:
#+BEGIN_SRC elisp :tangle broken-detangle.el :comments link
(defun test
(message "broken detangle")
(message "test"))
#+END_SRC
However, if I add a line of code like this, then I am currently getting a =Not in a source block".
#+BEGIN_SRC elisp :tangle broken-detangle.el :comments link
(defun test
(message "broken detangle")
(message "test")
(message "test"))
#+END_SRC
Another thing to note, if there is only *one* code block in the Orgmode file, then I am getting a =End of Buffer= instead.
[-- Attachment #3: broken-detangle--NOT-working.el --]
[-- Type: text/x-emacs-lisp, Size: 693 bytes --]
;; [[file:~/Documents/git/broken-detangle.org::*Experience%20broken%20detangle][Experience broken detangle:1]]
(defun test
(message "broken detangle")
(message "test")
(message "test"))
;; Experience broken detangle:1 ends here
;; [[file:~/Documents/git/broken-detangle.org::*Experience%20broken%20detangle][Experience broken detangle:2]]
(defun test
(message "broken detangle")
(message "test"))
;; Experience broken detangle:2 ends here
;; [[file:~/Documents/git/broken-detangle.org::*Experience%20broken%20detangle][Experience broken detangle:3]]
(defun test
(message "broken detangle")
(message "test")
(message "test"))
;; Experience broken detangle:3 ends here
[-- Attachment #4: broken-detangle--working.el --]
[-- Type: text/x-emacs-lisp, Size: 657 bytes --]
;; [[file:~/Documents/git/broken-detangle.org::*Experience%20broken%20detangle][Experience broken detangle:1]]
(defun test
(message "broken detangle"))
;; Experience broken detangle:1 ends here
;; [[file:~/Documents/git/broken-detangle.org::*Experience%20broken%20detangle][Experience broken detangle:2]]
(defun test
(message "broken detangle")
(message "test"))
;; Experience broken detangle:2 ends here
;; [[file:~/Documents/git/broken-detangle.org::*Experience%20broken%20detangle][Experience broken detangle:3]]
(defun test
(message "broken detangle")
(message "test")
(message "test"))
;; Experience broken detangle:3 ends here
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-04 12:42 ` Frederick Giasson
@ 2018-06-05 9:59 ` Nicolas Goaziou
2018-06-05 12:18 ` Frederick Giasson
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-06-05 9:59 UTC (permalink / raw)
To: Frederick Giasson; +Cc: emacs-orgmode
Hello,
Frederick Giasson <fred@curbside.com> writes:
> Here it is. If you =detangle= the =broken-detangle--working.el= file, it
> will work as expected.
>
> However, if you try to detangle the =broken-detangle--NOT-working.el= file,
> you should get a "Not in a source block" error in *message*.
This is fixed in "master".
> Another thing I noted while creating the ECM is if there is only *one* code
> block in the =.org= file, then it throws a =End of Buffer= error.
I couldn't reproduce this. If the fix below doesn't solve it, could you
provide a dedicated ECM?
Thank you.
Regards,
--
Nicolas Goaziou 0x80A93738
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-05 9:59 ` Nicolas Goaziou
@ 2018-06-05 12:18 ` Frederick Giasson
2018-06-05 23:19 ` Grant Rettke
0 siblings, 1 reply; 9+ messages in thread
From: Frederick Giasson @ 2018-06-05 12:18 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1270 bytes --]
Hi Nicolas,
> Here it is. If you =detangle= the =broken-detangle--working.el= file, it
> > will work as expected.
> >
> > However, if you try to detangle the =broken-detangle--NOT-working.el=
> file,
> > you should get a "Not in a source block" error in *message*.
>
> This is fixed in "master".
>
That is great! Working perfectly no, thanks!
> > Another thing I noted while creating the ECM is if there is only *one*
> code
> > block in the =.org= file, then it throws a =End of Buffer= error.
>
> I couldn't reproduce this. If the fix below doesn't solve it, could you
> provide a dedicated ECM?
>
Yes, that fixed it as well.
There is one last thing related to =org-babel-detangle= that seems "broken"
is that as far as I can see, the top =save-excursion= should save the
position of the cursor of the source file and keep the buffer at that
position when we perform a detangling on it, no?
Right now, the behavior is that when we do a detangle from a source file,
the org file get opened in the buffer of the source file.
However, I think that the right behavior is that when we detangle that the
remain at the same position in the source file otherwise this gets
confusing in my opinion.
Is that a bug or the expected behavior?
Thanks!
Take care
Fred
[-- Attachment #2: Type: text/html, Size: 2198 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-05 12:18 ` Frederick Giasson
@ 2018-06-05 23:19 ` Grant Rettke
2018-06-06 12:31 ` Frederick Giasson
0 siblings, 1 reply; 9+ messages in thread
From: Grant Rettke @ 2018-06-05 23:19 UTC (permalink / raw)
To: Frederick Giasson; +Cc: Org-mode, Nicolas Goaziou
On Tue, Jun 5, 2018 at 7:18 AM, Frederick Giasson <fred@curbside.com> wrote:
> There is one last thing related to =org-babel-detangle= that seems "broken"
> is that as far as I can see, the top =save-excursion= should save the
> position of the cursor of the source file and keep the buffer at that
> position when we perform a detangling on it, no?
>
> Right now, the behavior is that when we do a detangle from a source file,
> the org file get opened in the buffer of the source file.
>
> However, I think that the right behavior is that when we detangle that the
> remain at the same position in the source file otherwise this gets confusing
> in my opinion.
>
> Is that a bug or the expected behavior?
I think it is expected. The code looks like this:
(when (setq new-body (org-babel-tangle-jump-to-org))
(org-babel-update-block-body new-body))
The first time I detangled I was surprised, too.
But then it hit me: if you are detangling then you probably might want to
1. See the updated code
2. Commit the updated code
So now I like it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-05 23:19 ` Grant Rettke
@ 2018-06-06 12:31 ` Frederick Giasson
2018-06-06 16:04 ` Grant Rettke
0 siblings, 1 reply; 9+ messages in thread
From: Frederick Giasson @ 2018-06-06 12:31 UTC (permalink / raw)
To: Grant Rettke; +Cc: Org-mode, Nicolas Goaziou
[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]
Hi Grant,
I think it is expected. The code looks like this:
>
> (when (setq new-body (org-babel-tangle-jump-to-org))
> (org-babel-update-block-body new-body))
>
Yeah not sure I fully understand that code. Basically it does this for each
code block that needs to be detangled right? I am just not sure why the
focus doesn't return back to the source at the end of the process.
> The first time I detangled I was surprised, too.
>
> But then it hit me: if you are detangling then you probably might want to
> 1. See the updated code
> 2. Commit the updated code
>
Yes, I agree with you. However on a team that work on a LP project,
different people have different preferences and workflows. Personally I
only code in the Org-file, and toggle a code block to its major mode if I
need something provided by the major mode (coding in Clojure). However,
some people prefer see the full namespace (one namespace per Org file)
directly in Cider (the major mode) and detangle from there (this is why I
got interested in detangling).
In their case, having the buffer switching back to the Org file is a bit
irritating, particularly since there is no (yet) any function that let you
switch to the tangle source file of a code block.
If this is really the behavior, then I think that a new option should be
added to it such that we can choose one behavior or the other. If a
function that jump from a code block to its tangled source is created, then
we could use it with that option in `org-babel-detangle` to switch back to
the source if it is the wish of the user.
Thoughts?
Thanks,
Fred
[-- Attachment #2: Type: text/html, Size: 2304 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-06 12:31 ` Frederick Giasson
@ 2018-06-06 16:04 ` Grant Rettke
2018-06-06 16:18 ` Frederick Giasson
0 siblings, 1 reply; 9+ messages in thread
From: Grant Rettke @ 2018-06-06 16:04 UTC (permalink / raw)
To: Frederick Giasson; +Cc: Org-mode, Nicolas Goaziou
On Wed, Jun 6, 2018 at 7:31 AM, Frederick Giasson <fred@curbside.com> wrote:
> If this is really the behavior, then I think that a new option should be added to it such that we can choose one behavior or the other. If a function that jump from a code
> block to its tangled source is created, then we could use it with that option in `org-babel-detangle` to switch back to the source if it is the wish of the user.
It sounds like org-babel-tangle-jump-to-org is what you want.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-detangle seems broken
2018-06-06 16:04 ` Grant Rettke
@ 2018-06-06 16:18 ` Frederick Giasson
0 siblings, 0 replies; 9+ messages in thread
From: Frederick Giasson @ 2018-06-06 16:18 UTC (permalink / raw)
To: Grant Rettke; +Cc: Org-mode, Nicolas Goaziou
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]
Hi
>
> > block to its tangled source is created, then we could use it with that
> option in `org-babel-detangle` to switch back to the source if it is the
> wish of the user.
>
> It sounds like org-babel-tangle-jump-to-org is what you want.
>
In fact it is its opposite that I need, code block to tangled source file.
Fred
>
[-- Attachment #2: Type: text/html, Size: 777 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-06-06 16:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-01 17:27 org-detangle seems broken Frederick Giasson
2018-06-02 10:17 ` Nicolas Goaziou
2018-06-04 12:42 ` Frederick Giasson
2018-06-05 9:59 ` Nicolas Goaziou
2018-06-05 12:18 ` Frederick Giasson
2018-06-05 23:19 ` Grant Rettke
2018-06-06 12:31 ` Frederick Giasson
2018-06-06 16:04 ` Grant Rettke
2018-06-06 16:18 ` Frederick Giasson
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).