From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8LA7BYDmUGMYngAAbAwnHQ (envelope-from ) for ; Thu, 20 Oct 2022 08:11:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id SMtQBYDmUGPtWgEA9RJhRA (envelope-from ) for ; Thu, 20 Oct 2022 08:11:12 +0200 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 C8CD14713A for ; Thu, 20 Oct 2022 08:11:11 +0200 (CEST) Received: from localhost ([::1]:45590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olOlo-0007k3-J2 for larch@yhetil.org; Thu, 20 Oct 2022 02:11:09 -0400 Received: from [::1] (port=56822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olOeK-0003Vs-Na for larch@yhetil.org; Thu, 20 Oct 2022 02:03:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olObf-0003QG-KT for emacs-orgmode@gnu.org; Thu, 20 Oct 2022 02:00:47 -0400 Received: from mail.choca.pics ([80.67.172.235]:48888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olObc-0005OS-8q for emacs-orgmode@gnu.org; Thu, 20 Oct 2022 02:00:38 -0400 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id A529D181942B3; Thu, 20 Oct 2022 08:00:31 +0200 (CEST) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 2CF67iUA_CHL; Thu, 20 Oct 2022 08:00:31 +0200 (CEST) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 210AC181942B4; Thu, 20 Oct 2022 08:00:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id wykZfdTjN9OS; Thu, 20 Oct 2022 08:00:31 +0200 (CEST) Received: from localhost (153.226.95.79.rev.sfr.net [79.95.226.153]) by mail.choca.pics (Postfix) with ESMTPSA id DF7EC181942B3; Thu, 20 Oct 2022 08:00:30 +0200 (CEST) From: Damien Cassou To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: Weird behavior of org-element-object-lex In-Reply-To: <87v8of83oy.fsf@localhost> References: <87fsfjd3ds.fsf@cassou.me> <87v8of83oy.fsf@localhost> Date: Thu, 20 Oct 2022 08:00:30 +0200 Message-ID: <87czanc9vl.fsf@cassou.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=80.67.172.235; envelope-from=damien@cassou.me; helo=mail.choca.pics X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666246271; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XYSUWpcwj+dzTWUwT392keEwKI1TLardBpfW15lQVSo=; b=VgsVSqpfArxkXh4DO4yTgRDNKI02FPxxlOUzW0nenLBCqERU9Bu/Xj8hLRerQJzPC5q3MZ lXGTwNqikqA/OWzStcCB0f0gVAQ370lX5lNjanwNLwaUDvv/qXDpFMgw+uMUjf3RkCU6qf 2O0i8oYxXs1P1Ra+o4nIh1q4xKf8xsltTNBsw5DN+iTBNpo3cgk0aEhVc1dpShAKplgKKU oxcrVNssiQobfweDxuZZOkYRyo6MyJLFvfMh2j2Gm+nsjwqCG0UzrECBmOyxU9376v7n5X JGW0VmVkAoL9s6DQCZ4t7mfCFX41v1voBLMRqOMqMZt0laT9ssgq7C0a4kVDUw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666246271; a=rsa-sha256; cv=none; b=VagY1wZuPkQVmNa7+u7ct9P1ZesvuKWL5f8QWgXxg6Mn8Ny9YyiMYxV3xeeRSsusVYJZ5k vAt3uZsye4E9if0frVAqQFXvI1JzkGA54/6Ldy3z2sIbhuIhAIhi06OdLy11fSzjQ2waym 7uJU5/la9HGY/0or2TH5btuwLhqMqxAlRBBIc54opfP8afHUHyot1qieqtqI83Mxms9uAx 4erAwtlzthaci+pvf1/8trxEPJ5fqOzKLjo+dWIXQ5U8QH+ZJfMTN2JAMUNGcD3aihPJ2m wN732bkAauRBIrpD5i8Ye6tAivdMMM+NtDDki8iVgdU8KcFKdEMiHGJ7HyO2tw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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" X-Migadu-Spam-Score: -1.23 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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" X-Migadu-Queue-Id: C8CD14713A X-Spam-Score: -1.23 X-Migadu-Scanner: scn1.migadu.com X-TUID: n+XKa0fDA4ZP Ihor Radchenko writes: > Damien Cassou writes: >> Is that a bug? > > Not really. table-cell and citation-reference do not have a regexp > signature and are handled specially. For these two types of objects, > org-element--object-lex is called only when the parent is a table-row or > citation object. Not very elegant, but it is internal function, and it > works :) I understand. Thank you. This is a problem for me but the workaround is easy. For information, the rest of this email describes my problem and the workaround but I'm not expecting anything from you, the workaround is good enough. I'm writing an exporter that is basically the same as ODT with some differences that are mandatory to get articles published in the magazine GNU/Linux Magazine. This magazine wants lists to have no special markups: - item 1=C2=A0; - item 2=C2=A0; So, I wrote a plain-list transcoder and an item transcoder: (defun ox-linuxmag--plain-list (plain-list contents _info) contents) (defun ox-linuxmag--item (item contents info) (let* ((plain-content (buffer-substring-no-properties (org-element-property :contents-begin item) (org-element-property :contents-end item))) (parse-tree (org-element-parse-secondary-string plain-content ;; org-element-parse-secondary-string acts ;; weirdly if either 'table-cell or ;; 'citation-reference are included: (cl-remove-if (lambda (type) (seq-contains-p '(table-cell citati= on-reference) type)) org-element-all-objects))) (item-content (org-export-data parse-tree info))) (ox-linuxmag--format-text:p (format "- %s" item-content)))) The reason `ox-linuxmag--item` has to parse ITEM again is because CONTENTS contains "item 1=C2=A0;" which misses the initial dash "-" character: i.e., I would like "- item 1=C2=A0;" in the paragraph instead. As you can see, the code uses `org-element-parse-secondary-string` with most of `org-element-all-objects` as RESTRICTION argument but neither `table-cell` nor `citation-reference`. Do you see a simpler way to achieve this? --=20 Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill