From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id WL9/CdtIDWdB7gAA62LTzQ:P1 (envelope-from ) for ; Mon, 14 Oct 2024 16:37:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id WL9/CdtIDWdB7gAA62LTzQ (envelope-from ) for ; Mon, 14 Oct 2024 18:37:47 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bJT0Ydv+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1728923867; a=rsa-sha256; cv=none; b=gi5o8kDHWD68T2d6p+4snw8To3Jt2uElY7GSjW40AVkDLwfsqjCP+7rUmFq41D7vNMalPf Y2LRkVi+ED0f50zpmtftgvvKVpR3x5zduqED5M2/XqjW3DkW1VI3wVJafkeVASOncv/H+0 D2P44m8A6QAnM6EA9crm1+7UPNZa5hiiClIG+s0Krn+bKk8l2hfYv9eUeNkdqeUhlPZHoY nWsKJ9JfB2LytCiAeLS3Ug2WdJx/ruokpJHmS4VmvoxgCcKXTj9vgkUI3eYgplXvmSetHd HoT3XwXxsTDMJIggH88oF2hJcvXZWoKgw/86UX5yoZtIx4whaqh4APt8c9Hpgg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bJT0Ydv+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1728923867; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=l82hzhTkU95pvTz79vgHTb7zC/hBBhau7Dy2HFks9NA=; b=tpGndnQDroUdr3y3jyZ+PQ6bKgiYk+1Fq1uZ9x6tnMNtVLKjdvNO3TS37vMUbh/oNjD9ZI CQO6PBESzNT0U6aX7F4e7QBeDBXekfre7kx5VF5SQY9ysC3FtRA+6xCnpC9GrPdGeZRvey sx4BzR94halXAIxi+MnL1+kJO9+cymaoo6N0MXb4/auO56fGlKThGSzkSMmWC9Bak04vrb j0BKVoSEXGRDavpRN4xQNYV85EHr44YXFrt5hjZcj54oyJeinFkZhE/C3IhMVhS/HqxyrO zD30oihdfmTFMfD3chWUpaQ0/Xb8N4IxRcpqKnGKGSczecCYDqU0EIRH+gXr6w== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AA22E73F48 for ; Mon, 14 Oct 2024 18:37:44 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0O3s-0005LQ-Fn; Mon, 14 Oct 2024 12:36:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0O3q-0005Hy-Ax for emacs-orgmode@gnu.org; Mon, 14 Oct 2024 12:36:46 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0O3o-0001Eq-KK for emacs-orgmode@gnu.org; Mon, 14 Oct 2024 12:36:46 -0400 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-20c805a0753so36258395ad.0 for ; Mon, 14 Oct 2024 09:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728923800; x=1729528600; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=l82hzhTkU95pvTz79vgHTb7zC/hBBhau7Dy2HFks9NA=; b=bJT0Ydv+/4qodgMXtV74SiYoZNl25KDxIfhM92SMSrYNfCwjYTPE0xMJVgyN1JvPEO fkaKvQVRXA+iDodiXn/i5qeAJGJbgMBnfvnS5nPKoegrzETwxSrnlMiFTYmBvWRftbuz LqHy1Asu0ui8n8pq+rNnAxKo2fqjRTmElrO7lLBC1ixh4DNWIR2hwkbw+OxrPYv/pvUx hGP/oSUyRiU970Y5hBuWBNPMDwQoB1LLAY3QLbFXZYmUsafUbdm1pja/fgVNLvi5yhT4 euWrTB546MGpUkqsfW3FqBhG04eZ9mlpVfzpqIMAK3oG7k3OCog6YHHCu5lazSn/3ckj +KIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728923800; x=1729528600; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l82hzhTkU95pvTz79vgHTb7zC/hBBhau7Dy2HFks9NA=; b=lk4RD1UHxb2IPgm1WgS8moIEFTFa/sCc3W6U96resJwmGiL+M6Ir94TmW3buKNax14 Z6trj2YnkBi1RRW0wu/uFTEdTjYosF5xCtJIeMPHykBgXDOAlM/HEE95NeNMhRyzJLCY rboyXkWUwq4PqR+VldKEp13ZuKCJTLF9DGkflu0SeRJVh9mYTBD4kNRHsv11QUv5lnVk uu+/xeqaPSLSD0zfQA1iKoSoPlZNgx3i0q5iKm9QzqRR76NUKYXv2+8krkMil1wCJtMH KMQazXY7PcJUa3YqqCycl/+DmmzKgzfwcNO1uE+LNsrGUUxvIOzgi3z3aJppyxAu2vIQ k29g== X-Gm-Message-State: AOJu0Yyg0vq3ziEbJgsVMmGd8bO+223o6LCgnksJ5tJXMKJkEAZa68zt LSJDCMf6TGoYzqmX3WGseFmAWVcaP+ZAUhUYn0Lat8OfE/AJIdnIjeoQ5IUB X-Google-Smtp-Source: AGHT+IHrb+HM8UFK0G6XSiKHibogJ4a1pQRrWdWiez4FeuQNDmOLEh+pmmteMqml0H+6jyC5qOSG6w== X-Received: by 2002:a17:902:ec83:b0:20b:6188:fc5e with SMTP id d9443c01a7336-20ca147c42fmr197370245ad.28.1728923800240; Mon, 14 Oct 2024 09:36:40 -0700 (PDT) Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c312eccsm68017565ad.237.2024.10.14.09.36.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 09:36:39 -0700 (PDT) From: Visuwesh To: org-mode-email Subject: [PATCH] Add yank-media handler for LibreOffice Calc tables Date: Mon, 14 Oct 2024 22:06:35 +0530 Message-ID: <87r08i3alo.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=visuweshm@gmail.com; helo=mail-pl1-x641.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -5.69 X-Spam-Score: -5.69 X-Migadu-Queue-Id: AA22E73F48 X-Migadu-Scanner: mx10.migadu.com X-TUID: MJB1kftTMQye --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-yank-media-handler-for-LibreOffice-Calc-tables.patch >From 0cd4b1c5402256ed64c9e1711db11ad215c6c1a3 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Mon, 14 Oct 2024 22:04:23 +0530 Subject: [PATCH] Add `yank-media' handler for LibreOffice Calc tables * lisp/org.el (org--libreoffice-table-handler): Add new `yank-media' handler for tables copied from LibreOffice Calc documents. (org-setup-yank-dnd-handlers): Register it. * doc/org-manual.org: (Drag and Drop & ~yank-media~): Update the manual to mention the new feature. * etc/ORG-NEWS: Announce the new feature. --- doc/org-manual.org | 6 +++++- etc/ORG-NEWS | 5 +++++ lisp/org.el | 14 +++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 451fd72cd..e8da07356 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -21640,7 +21640,8 @@ value as ~org-attach-method~ (~cp~ by default).] #+cindex: pasting files, images from clipboard Starting from Emacs 29, Org mode supports ~yank-media~ command to yank -images from the clipboard and files from a file manager. +images from the clipboard, files from a file manager and tables copied +from LibreOffice Calc documents. #+vindex: org-yank-image-save-method When yanking images from clipboard, Org saves the image on disk and @@ -21658,6 +21659,9 @@ of ~org-yank-dnd-method~. Image files pasted this way also respect the value of ~org-yank-image-save-method~ when the action to perform is =attach=. +When yanking tables copied from LibreOffice Calc documents, they are +inserted as Org tables when yanking them. + ** Repeating commands :PROPERTIES: :DESCRIPTION: Repeating navigation commands diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 5d421172f..37ee9a52f 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -114,6 +114,11 @@ The keybindings in the repeat-maps can be changed by customizing See the new [[info:org#Repeating commands]["Repeating commands"]] section in Org mode manual. +*** Tables copied from LibreOffice Calc documents can be pasted as Org tables + +Tables copied into the clipboard from LibreOffice Calc documents can +now be pasted as an Org table using ~yank-media~. + ** New and changed options # Chanes deadling with changing default values of customizations, diff --git a/lisp/org.el b/lisp/org.el index 6177856c3..82ad40527 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20860,7 +20860,9 @@ (defun org-setup-yank-dnd-handlers () ;; Looks like different DEs go for different handler names, ;; https://larsee.com/blog/2019/05/clipboard-files/. (yank-media-handler "x/special-\\(?:gnome\\|KDE\\|mate\\)-files" - #'org--copied-files-yank-media-handler)) + #'org--copied-files-yank-media-handler) + (yank-media-handler "application/x-libreoffice-tsvc" + #'org--libreoffice-table-handler)) (when (boundp 'x-dnd-direct-save-function) (setq-local x-dnd-direct-save-function #'org--dnd-xds-function))) @@ -20953,6 +20955,16 @@ (defun org--copied-files-yank-media-handler (_mimetype data) (org--dnd-local-file-handler f action sep) (message "File `%s' is not readable, skipping" f))))) +(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)))) + (defcustom org-yank-dnd-method 'ask "Action to perform on the dropped and the pasted files. When the value is the symbol, -- 2.45.2 --=-=-=--