emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)]
@ 2023-06-21 19:45 Nick Dokos
  2023-06-22  9:55 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2023-06-21 19:45 UTC (permalink / raw)
  To: emacs-orgmode



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

Here's an ECM:

--8<---------------cut here---------------start------------->8---
* Function heading

  #+begin_src elisp :tangle "file.el" :comments org
    (message "FOO")
  #+end_src
--8<---------------cut here---------------end--------------->8---

Tangling it with `C-c C-v C-t' produces the following:

--8<---------------cut here---------------start------------->8---
(message "FOO")
--8<---------------cut here---------------end--------------->8---

with no comment added.

In 9.5.5, the output is correct:

--8<---------------cut here---------------start------------->8---
;; Function heading


(message "FOO")
--8<---------------cut here---------------end--------------->8---

I narrowed it down to this snippet of code in `org-babel-tangle-single-block':

,----
| 	    ;; From the previous heading or code-block end
| 	    (funcall
| 	     org-babel-process-comment-text
| 	     (buffer-substring
| 	      (max (condition-case nil
| 		       (save-excursion
| 			 (org-back-to-heading t) ; Sets match data
| 			 (match-end 0))
| 		     (error (point-min)))
| 		   (save-excursion
| 		     (if (re-search-backward
| 			  org-babel-src-block-regexp nil t)
| 			 (match-end 0)
| 		       (point-min))))
| 	      (point)))))
`----

and bisecting fingered this commit:

--8<---------------cut here---------------start------------->8---
2737128aa778297f41971cc93c464faf17718e34 is the first bad commit
commit 2737128aa778297f41971cc93c464faf17718e34
Author: Ihor Radchenko <yantar92@gmail.com>
Date:   Tue Sep 13 20:59:13 2022 +0800

    org-back-to-heading: Use cache
    
    * lisp/org.el (org-back-to-heading): Use element cache when cache is
    active.

 lisp/org.el | 63 ++++++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 41 insertions(+), 22 deletions(-)
--8<---------------cut here---------------end--------------->8---

Apparently, `org-back-to-heading' sets match data differently now: `(match-end 0)' gets the end of the line,
Before the patch, it got the beginning of the line.

Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.17.6)
 of 2023-06-21
Package: Org mode version 9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)
-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler



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

* Re: [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)]
  2023-06-21 19:45 [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)] Nick Dokos
@ 2023-06-22  9:55 ` Ihor Radchenko
  2023-06-24  3:19   ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-06-22  9:55 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Nick Dokos <ndokos@redhat.com> writes:

> Here's an ECM:
> ...
> I narrowed it down to this snippet of code in `org-babel-tangle-single-block':
> ...
> and bisecting fingered this commit:
> ...
> Apparently, `org-back-to-heading' sets match data differently now: `(match-end 0)' gets the end of the line,
> Before the patch, it got the beginning of the line.

Thanks for the report and for the detailed analysis!
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=79ec91584

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)]
  2023-06-22  9:55 ` Ihor Radchenko
@ 2023-06-24  3:19   ` Nick Dokos
  2023-06-24 12:37     ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2023-06-24  3:19 UTC (permalink / raw)
  To: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Nick Dokos <ndokos@redhat.com> writes:
>
>> Here's an ECM:
>> ...
>> I narrowed it down to this snippet of code in `org-babel-tangle-single-block':
>> ...
>> and bisecting fingered this commit:
>> ...
>> Apparently, `org-back-to-heading' sets match data differently now: `(match-end 0)' gets the end of the line,
>> Before the patch, it got the beginning of the line.
>
> Thanks for the report and for the detailed analysis!
> Fixed, on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=79ec91584

Thanks!

A couple of nits: maybe the comment that `org-back-to-heading' sets match
data should be deleted?  And there is a typo in the initial comment of
the test you added (thanks for adding it!): `:commends org' should be
`:comments org'.

Also, I found a couple of places in the code where `org-back-to-heading' is called
and then match data are used. I don't know if there is a problem or not, but it might
be worth double checking to make sure that the usage makes sense:

- org.el: l.20792 in `org-forward-heading-same-level'
- org-mouse.el: l.976 in `org-mouse-transform-to-outline'

I'll try to test these cases and report back but I can't promise when.
-- 
Nick



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

* Re: [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)]
  2023-06-24  3:19   ` Nick Dokos
@ 2023-06-24 12:37     ` Ihor Radchenko
  2023-06-27  3:25       ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-06-24 12:37 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> A couple of nits: maybe the comment that `org-back-to-heading' sets match
> data should be deleted?  And there is a typo in the initial comment of
> the test you added (thanks for adding it!): `:commends org' should be
> `:comments org'.

Thanks!
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f56ca5009

> Also, I found a couple of places in the code where `org-back-to-heading' is called
> and then match data are used. I don't know if there is a problem or not, but it might
> be worth double checking to make sure that the usage makes sense:
>
> - org.el: l.20792 in `org-forward-heading-same-level'
> - org-mouse.el: l.976 in `org-mouse-transform-to-outline'

Right.
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=57bb9cada
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0a842cc94

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)]
  2023-06-24 12:37     ` Ihor Radchenko
@ 2023-06-27  3:25       ` Nick Dokos
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Dokos @ 2023-06-27  3:25 UTC (permalink / raw)
  To: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Nick Dokos <ndokos@gmail.com> writes:
>
>> A couple of nits: maybe the comment that `org-back-to-heading' sets match
>> data should be deleted?  And there is a typo in the initial comment of
>> the test you added (thanks for adding it!): `:commends org' should be
>> `:comments org'.
>
> Thanks!
> Fixed, on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f56ca5009
>
>> Also, I found a couple of places in the code where `org-back-to-heading' is called
>> and then match data are used. I don't know if there is a problem or not, but it might
>> be worth double checking to make sure that the usage makes sense:
>>
>> - org.el: l.20792 in `org-forward-heading-same-level'
>> - org-mouse.el: l.976 in `org-mouse-transform-to-outline'
>
> Right.
> Fixed, on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=57bb9cada
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0a842cc94

Thank you!

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler



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

end of thread, other threads:[~2023-06-27  3:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 19:45 [BUG] org-babel-tangle: Header arg `:comments org' produces no comment in the output [9.7-pre (release_9.6.6-418-g294a4d @ /home/nick/src/emacs/org/org-mode/lisp/)] Nick Dokos
2023-06-22  9:55 ` Ihor Radchenko
2023-06-24  3:19   ` Nick Dokos
2023-06-24 12:37     ` Ihor Radchenko
2023-06-27  3:25       ` Nick Dokos

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