emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Visuwesh <visuweshm@gmail.com>
Cc: org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Add yank-media handler for LibreOffice Calc tables
Date: Mon, 14 Oct 2024 18:58:02 +0000	[thread overview]
Message-ID: <871q0ise9x.fsf@localhost> (raw)
In-Reply-To: <87r08i3alo.fsf@gmail.com>

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.

> +(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.

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


  reply	other threads:[~2024-10-14 19:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 16:36 [PATCH] Add yank-media handler for LibreOffice Calc tables Visuwesh
2024-10-14 18:58 ` Ihor Radchenko [this message]
2024-10-15  5:57   ` Visuwesh
2024-10-15 18:42     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871q0ise9x.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=visuweshm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).