all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
@ 2022-01-09  5:22 Vikas Kumar
  2022-01-09  8:42 ` Vikas Kumar
  0 siblings, 1 reply; 8+ messages in thread
From: Vikas Kumar @ 2022-01-09  5:22 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello,

When I use ':results value list' in an emacs-lisp source block it looks
like Babel does
not indent list items correctly when one of the items is a multi-line text.

To reproduce evaluate the following code block:

#+begin_src emacs-lisp :results value list
  '("Foo1\nBar1" "Foo2\n\nBar2")
#+end_src


It outputs:

#+RESULTS:
- Foo1
Bar1
- Foo2


Bar2


Expected output:

#+RESULTS:
- Foo1
  Bar1
- Foo2


  Bar2


Since the second line of the first item is out of indentation, this makes
the output list actually
finish after the first line of the first item. Re-evaluating the block then
only removes the first line
of the previous output.

My Emacs and Org mode version:
Emacs  : GNU Emacs 27.2 (build 1, x86_64-apple-darwin20.6.0, Carbon Version
164 AppKit 2022.6)
 of 2021-11-16
Package: Org mode version 9.4.4 (release_9.4.4 @
/Applications/Emacs.app/Contents/Resources/lisp/org/)

-- 
Thanks,
VIkas

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

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

* Re: Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-01-09  5:22 Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)] Vikas Kumar
@ 2022-01-09  8:42 ` Vikas Kumar
  2022-01-11 18:55   ` Vikas Kumar
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vikas Kumar @ 2022-01-09  8:42 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1122 bytes --]

Here is a patch with the fix.

-- 
Thanks,
Vikas

On Sat, Jan 8, 2022 at 9:22 PM Vikas Kumar <kr.vikas@gmail.com> wrote:

> Hello,
>
> When I use ':results value list' in an emacs-lisp source block it looks
> like Babel does
> not indent list items correctly when one of the items is a multi-line text.
>
> To reproduce evaluate the following code block:
>
> #+begin_src emacs-lisp :results value list
>   '("Foo1\nBar1" "Foo2\n\nBar2")
> #+end_src
>
>
> It outputs:
>
> #+RESULTS:
> - Foo1
> Bar1
> - Foo2
>
>
> Bar2
>
>
> Expected output:
>
> #+RESULTS:
> - Foo1
>   Bar1
> - Foo2
>
>
>   Bar2
>
>
> Since the second line of the first item is out of indentation, this makes
> the output list actually
> finish after the first line of the first item. Re-evaluating the block
> then only removes the first line
> of the previous output.
>
> My Emacs and Org mode version:
> Emacs  : GNU Emacs 27.2 (build 1, x86_64-apple-darwin20.6.0, Carbon
> Version 164 AppKit 2022.6)
>  of 2021-11-16
> Package: Org mode version 9.4.4 (release_9.4.4 @
> /Applications/Emacs.app/Contents/Resources/lisp/org/)
>
> --
> Thanks,
> VIkas
>

[-- Attachment #1.2: Type: text/html, Size: 2843 bytes --]

[-- Attachment #2: 0001-ob-core.el-Fix-indentation-of-multiline-text-in-list.patch --]
[-- Type: application/octet-stream, Size: 1195 bytes --]

From cb35cebb4164f85f7c3c1edd313c3555708b3388 Mon Sep 17 00:00:00 2001
From: Vikas Kumar <kr.vikas@gmail.com>
Date: Sun, 9 Jan 2022 00:12:48 -0800
Subject: [PATCH] ob-core.el: Fix indentation of multiline text in list output

* lisp/ob-core.el (org-babel-format-result): Use `org-list-to-org'
instead of `org-list-to-generic' to format result in Org list.

The problem was in formatting a multiline text result into an Org
list.  Additional lines of a list item should be indented with the
first line of the item.  The method used for this
formatting (`org-list-to-generic') does not add the extra indentation
to additional lines of an item.  Using `org-list-to-org' instead fixes
the problem.

TINYCHANGE
---
 lisp/ob-core.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 239a57f96..7d17762bd 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2393,7 +2393,7 @@ INFO may provide the values of these header arguments (in the
 		   ((member "list" result-params)
 		    (insert
 		     (org-trim
-		      (org-list-to-generic
+		      (org-list-to-org
 		       (cons 'unordered
 			     (mapcar
 			      (lambda (e)
-- 
2.34.1


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

* Re: Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-01-09  8:42 ` Vikas Kumar
@ 2022-01-11 18:55   ` Vikas Kumar
  2022-01-11 20:05   ` [PATCH] " Sébastien Miquel
  2022-10-21  6:37   ` Ihor Radchenko
  2 siblings, 0 replies; 8+ messages in thread
From: Vikas Kumar @ 2022-01-11 18:55 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello, can anyone take a look at this problem and the patch?

-- 
Thanks,
Vikas

On Sun, Jan 9, 2022 at 12:42 AM Vikas Kumar <kr.vikas@gmail.com> wrote:

> Here is a patch with the fix.
>
> --
> Thanks,
> Vikas
>
> On Sat, Jan 8, 2022 at 9:22 PM Vikas Kumar <kr.vikas@gmail.com> wrote:
>
>> Hello,
>>
>> When I use ':results value list' in an emacs-lisp source block it looks
>> like Babel does
>> not indent list items correctly when one of the items is a multi-line
>> text.
>>
>> To reproduce evaluate the following code block:
>>
>> #+begin_src emacs-lisp :results value list
>>   '("Foo1\nBar1" "Foo2\n\nBar2")
>> #+end_src
>>
>>
>> It outputs:
>>
>> #+RESULTS:
>> - Foo1
>> Bar1
>> - Foo2
>>
>>
>> Bar2
>>
>>
>> Expected output:
>>
>> #+RESULTS:
>> - Foo1
>>   Bar1
>> - Foo2
>>
>>
>>   Bar2
>>
>>
>> Since the second line of the first item is out of indentation, this makes
>> the output list actually
>> finish after the first line of the first item. Re-evaluating the block
>> then only removes the first line
>> of the previous output.
>>
>> My Emacs and Org mode version:
>> Emacs  : GNU Emacs 27.2 (build 1, x86_64-apple-darwin20.6.0, Carbon
>> Version 164 AppKit 2022.6)
>>  of 2021-11-16
>> Package: Org mode version 9.4.4 (release_9.4.4 @
>> /Applications/Emacs.app/Contents/Resources/lisp/org/)
>>
>> --
>> Thanks,
>> VIkas
>>
>

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

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

* Re: [PATCH] Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-01-09  8:42 ` Vikas Kumar
  2022-01-11 18:55   ` Vikas Kumar
@ 2022-01-11 20:05   ` Sébastien Miquel
  2022-01-11 20:40     ` Vikas Kumar
  2022-10-21  6:37   ` Ihor Radchenko
  2 siblings, 1 reply; 8+ messages in thread
From: Sébastien Miquel @ 2022-01-11 20:05 UTC (permalink / raw)
  To: Vikas Kumar, emacs-orgmode

Hi,

Vikas Kumar writes:
> Here is a patch with the fix.
Thank you for the patch.

I'm just adding the [PATCH] cookie, so that this shows up on 
https://updates.orgmode.org/.

A maintainer will eventually get back to you, but it may take a while 
(couple of months at most).

Regards,

-- 
Sébastien Miquel



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

* Re: [PATCH] Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-01-11 20:05   ` [PATCH] " Sébastien Miquel
@ 2022-01-11 20:40     ` Vikas Kumar
  0 siblings, 0 replies; 8+ messages in thread
From: Vikas Kumar @ 2022-01-11 20:40 UTC (permalink / raw)
  To: sebastien.miquel; +Cc: emacs-orgmode

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

Thanks Sébastien

On Tue, Jan 11, 2022 at 12:05 PM Sébastien Miquel <
sebastien.miquel@posteo.eu> wrote:

> Hi,
>
> Vikas Kumar writes:
> > Here is a patch with the fix.
> Thank you for the patch.
>
> I'm just adding the [PATCH] cookie, so that this shows up on
> https://updates.orgmode.org/.
>
> A maintainer will eventually get back to you, but it may take a while
> (couple of months at most).
>
> Regards,
>
> --
> Sébastien Miquel
>
>

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

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

* Re: Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-01-09  8:42 ` Vikas Kumar
  2022-01-11 18:55   ` Vikas Kumar
  2022-01-11 20:05   ` [PATCH] " Sébastien Miquel
@ 2022-10-21  6:37   ` Ihor Radchenko
  2022-10-21 14:42     ` [PATCH] " Rudolf Adamkovič
  2 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-10-21  6:37 UTC (permalink / raw)
  To: Vikas Kumar; +Cc: emacs-orgmode

Vikas Kumar <kr.vikas@gmail.com> writes:

> Here is a patch with the fix.

Thanks, and sorry for the late reply.
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e7005787993f521f76e99f00e8a04d87703c493f

You are now listed as an Org contributor
https://git.sr.ht/~bzg/worg/commit/d0d3287e851a7365069b9dd8970ae5756e20240d

-- 
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] 8+ messages in thread

* [PATCH] Re: Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-10-21  6:37   ` Ihor Radchenko
@ 2022-10-21 14:42     ` Rudolf Adamkovič
  2022-10-22  4:33       ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Rudolf Adamkovič @ 2022-10-21 14:42 UTC (permalink / raw)
  To: Ihor Radchenko, Vikas Kumar; +Cc: emacs-orgmode

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

Ihor Radchenko <yantar92@posteo.net> writes:

> Applied onto main.

I wrote a regression test, so that we do not need to fix this problem
again next time.  Please see the attached patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-test-ob-Test-indentation-of-multiline-text-in-list-o.patch --]
[-- Type: text/x-patch, Size: 1551 bytes --]

From 9cb3c86abcc1fe983b5e6d2ff7a80c1d714fb126 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Fri, 21 Oct 2022 16:26:33 +0200
Subject: [PATCH] test-ob: Test indentation of multiline text in list output

* testing/lisp/test-ob.el (test-ob/org-babel-results-indented-list):
Add a regression test for the recent change to ob-core list formatting
in e7005787993f521f76e99f00e8a04d87703c493f.
---
 testing/lisp/test-ob.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 4ac278faf..4beaecf7b 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -1175,6 +1175,29 @@ trying to find the :END: marker."
     (org-babel-execute-src-block)
     (org-babel-execute-src-block)))
 
+(ert-deftest test-ob/org-babel-results-indented-list ()
+  "Test that :results value list indents multi-line items correctly."
+  (should
+   (string= "- Foo1
+  Bar1
+- Foo2
+
+  Bar2
+"
+            (org-test-with-temp-text
+                "#+begin_src emacs-lisp :results value list
+'(\"Foo1
+Bar1\"
+  \"Foo2
+
+Bar2\")
+#+end_src"
+              (org-babel-execute-src-block)
+              (org-forward-element)
+              (org-narrow-to-element)
+              (delete-trailing-whitespace)
+              (buffer-string)))))
+
 (ert-deftest test-ob/file-desc-header-argument ()
   "Test that the :file-desc header argument is used."
   (org-test-with-temp-text "#+begin_src emacs-lisp :results file :file-desc bar
-- 
2.38.0


[-- Attachment #3: Type: text/plain, Size: 216 bytes --]


Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia

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

* Re: [PATCH] Re: Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2022-10-21 14:42     ` [PATCH] " Rudolf Adamkovič
@ 2022-10-22  4:33       ` Ihor Radchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-10-22  4:33 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: Vikas Kumar, emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> I wrote a regression test, so that we do not need to fix this problem
> again next time.  Please see the attached patch.

Thanks!
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=524e0e0b7b5eb4c02f3da5eaf59eb1df82d1c1cc

-- 
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] 8+ messages in thread

end of thread, other threads:[~2022-10-22  4:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-09  5:22 Bug: Incorrect indentation in Org Babel list output with multiline text [9.4.4 (release_9.4.4 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)] Vikas Kumar
2022-01-09  8:42 ` Vikas Kumar
2022-01-11 18:55   ` Vikas Kumar
2022-01-11 20:05   ` [PATCH] " Sébastien Miquel
2022-01-11 20:40     ` Vikas Kumar
2022-10-21  6:37   ` Ihor Radchenko
2022-10-21 14:42     ` [PATCH] " Rudolf Adamkovič
2022-10-22  4:33       ` Ihor Radchenko

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.