From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id uBDGDOTMpmVrYAAAqHPOHw:P1 (envelope-from ) for ; Tue, 16 Jan 2024 19:37:24 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id uBDGDOTMpmVrYAAAqHPOHw (envelope-from ) for ; Tue, 16 Jan 2024 19:37:24 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=VlI0Rqau; dmarc=pass (policy=none) header.from=posteo.net; 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=1705430244; 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:dkim-signature; bh=nanSBfxSQPi7fPDri2XT2JFRYwb52BwRrKu2Xd0a7ss=; b=IzP5ScoWE04/0Je5LIWtP6rbke8aRawUe24pjoUxXK6G3JgNgRAqaUzncRVCHLtOUD6AxG 3OCc40bo8Bpt7xCh4KjMcf1SAd7T4CNf1z36yG8ihAEs6WaUHAUfLTO597+xIyyKASrDWO QstrxWhCRkEvCrmdPCEdxuSm7vBbemsgCsDfp0QRdcRxJ535CdUqI4WW5NDiaNWTOqo8Co Y/vY7LTSRip12vZz8zs9dZQDLtrbYV9olqKMehtRNzKCjRyn2ebOwwkZUOfLJiqtxJEnWY m0AbF5+W7bM97h0m2bBA6crTVMox4ZA6LY/xA8Cede+uKprC6xgl6iEB6j1UsQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705430244; a=rsa-sha256; cv=none; b=r4LePzGUCOB3EHbhn7P09IXl5430bKw++RilLe9oQym7MkxvjR3Zaq8NS4byJcxgRHzpNn wz/5LgDGq1Li7laMnWEp/EMR+5aCSsppl7xQd56K9oPdJ0FrjJf5JcrhRqzrMvfrpKVRWU cEreyliNMVmg4vReG5XQeOgxJq15TmS18vhceh3IjMXZMb3JRlSlWzVu2o3XvivqHwS6DT QYfeKp61eLP9kMF2D9f8Disbgl0DUDjVk3hLSC/mNFYEJUx7GdWLhi1HiuhZwV1wRtO6s/ f6GwfD7SP7XXBRt5FVHG6SYv4p9GBu039YRYOpe/zTjIetbjyZsMiIVi3sclqQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=VlI0Rqau; dmarc=pass (policy=none) header.from=posteo.net; 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" 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 CAFF86A5FF for ; Tue, 16 Jan 2024 19:37:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPoII-0002oT-NU; Tue, 16 Jan 2024 13:36:14 -0500 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 1rPoIG-0002oA-HR for emacs-orgmode@gnu.org; Tue, 16 Jan 2024 13:36:12 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rPoIC-0008Bj-Ex for emacs-orgmode@gnu.org; Tue, 16 Jan 2024 13:36:12 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C049C240104 for ; Tue, 16 Jan 2024 19:36:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1705430164; bh=jhhiqczAKjX+L9iyKdacCWZkS1ahnwlOWogzuZNV3pA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=VlI0Rqau4APs/gILuzOUXhbyP85qufyxu99tmIVbByBER9F85lhO1oJhu1X1Wi1Xd ppqj8qUjyHzWfhGktixJMdcfT9z6ORW5wIdFvBleqMXX9Yh3fr/vBefHqH6wRkAq3C R9SQRu5duZWLQBVZcpa+Vsu7GnMK4lsona/1qutOySrjSU7Tgu0O7HvJgOKg98vL+l hpx0bqtECSgc9whSfRJ1310L8RRWsxC3irFEPTOdzOVLlfm7eacWI24oKh38fuGKc6 X0Fb5of4vU8jVyAlx1Bb5Im7RW8ZAQvkizQIARMCLogvKB5BG5eXBd/d8ADvOOSEJV IOFSqLi8gjgnw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TDyPv61nhz9rxK; Tue, 16 Jan 2024 19:36:03 +0100 (CET) From: Ihor Radchenko To: Garulfo Cc: emacs-orgmode@gnu.org Subject: Re: back-end - access to :mode attribute for section and symbol-name In-Reply-To: References: Date: Tue, 16 Jan 2024 18:39:15 +0000 Message-ID: <87v87tjf70.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -9.90 X-Spam-Score: -9.90 X-Migadu-Queue-Id: CAFF86A5FF X-TUID: j7NLG7tNlDIh Garulfo writes: > For "ox-mycontext-section", I try to access the attribute ":mode" of the= =20 > section > in order to make the difference between "first-section" and "section". > > I had to use "symbol-name" : > > =C2=A0=C2=A0 (let* > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((section_mode (symbol-name (org-element-= property :mode section)))) > > Questions : > 1/ Is it the "org-mode" way to do ? :mode is an internal property set by the parser. I do not recommend using it in your code. Instead, you can check if a section is the first section like (if (eq 'org-data (org-element-type (org-element-property :parent section))) "First section" "Ordinary section inside a heading") or shorter (on the development version of Org mode) (if (org-element-type-p (org-element-parent section) 'org-data) "First section" "Ordinary section inside a heading") > 2/ What should I read to understand why "symbol-name" is needed, whereas= =20 > usually "org-element-property" just return the appropriate string. :mode property is set to the parser mode used to parse a given syntax node. Its value is not a string but a symbol. > (section_mode (symbol-name (org-element-property :mode section)))) > (pcase section_mode > ("first-section" (concat "%\n% FIRST SECTION\n%\n")) 'first-section symbol is not equal to "first-section" string. You would need ('first-section ...) to match symbol without converting it to string manually. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at