emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add yank-media handler for LibreOffice Calc tables


From: Visuwesh
Subject: Re: [PATCH] Add yank-media handler for LibreOffice Calc tables
Date: Tue, 15 Oct 2024 11:27:51 +0530
User-agent: Gnus/5.13 (Gnus v5.13)

[திங்கள் அக்டோபர் 14, 2024] Ihor Radchenko wrote:

> Visuwesh <visuweshm@gmail.com> writes:
>
>> Attached patch adds support for yanking LibreOffice Calc tables as Org
>> tables.  Tables from docx files (or LO's equivalent) cannot be yanked
>> though since the mimetype for them are richtext or HTML.
>
> Thanks!
>
> I just tried your patch (make repro) with a simple table
>
> foo   bar     
> 1     2       3
>
> I got
>
> * This is test
> | f\0o\0o\0 | \0b\0a\0r\0 | \0    |
> | \01\0     | \02\0       | \03\0 |
> | \0        |             |       |
>
> Something is off with encoding.

I cannot reproduce it on my end.  I tried with different documents and
document types (Excel and LO format).  Would it be possible to send the
faulty file?

>> +(defun org--libreoffice-table-handler (_mimetype data)
>> +  "Insert LibreOffice Calc table DATA as an Org table.
>> +DATA is in the TSV format."
>> +  (let ((beg (point)))
>> +    (insert data)
>> +    ;; LibreOffice source code defines
>> +    ;; 'application/x-libreoffice-tsvc' as Text TSV-Calc so it should
>> +    ;; be safe to handle this as TSV always.
>> +    (org-table-convert-region beg (point) '(16))))
>
> What if the point is in the middle of something else?
> For example, in the middle of another table.
> Then, conversion may yield wild outcomes.
> Maybe it is safer to convert region in a temporary buffer and
> insert the final result into the Org document being edited.

Even if we do the processing in a temporary buffer, we would still end
up inserting the table after point.  I say we leave it to the user to be
prudent and not call yank-media when in the middle of a table or
somesuch.  We do not do any special handling in other handlers, so why
do it here?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]