From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iGYvI9MYpWAQMAEAgWs5BA (envelope-from ) for ; Wed, 19 May 2021 15:55:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WLrnHtMYpWCjDgAAB5/wlQ (envelope-from ) for ; Wed, 19 May 2021 13:55:31 +0000 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 771262CC46 for ; Wed, 19 May 2021 15:55:30 +0200 (CEST) Received: from localhost ([::1]:34150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljMfZ-0004qf-KO for larch@yhetil.org; Wed, 19 May 2021 09:55:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljMKJ-0000yo-Oq for emacs-orgmode@gnu.org; Wed, 19 May 2021 09:33:31 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:46688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljMKH-0007IR-6F for emacs-orgmode@gnu.org; Wed, 19 May 2021 09:33:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id h3-20020a05600c3503b0290176f13c7715so3337479wmq.5 for ; Wed, 19 May 2021 06:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrew-cmu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hg9PqpNJrYe8oFZLuUkVuZ+msE5o9ixg2wC8Z5dgsVY=; b=qo3UIqB1tg9ZLTIEzp1qtA0nZjyu9TbuKbL/M7OCTvP0kajvO+jRMlmz4RyMQWlulu 1sgDrJTjO57etmPe1VUiVEfYpBJ9QMX+kXbOb+6hHevBI5SvSkeuUYc+JugBEn7i38nb uTS+YpuIkNUYkit2CVOQc9i9yJ8dk4iEgnHpx8ouapcduPvZTPzSaLZ4TLjyNQE0P4+2 bExjma3wAe+Lb7k2h/2VylrDfcCmw0McllpbAodrGEeOyYaEm/bN21AbomSXPpj/Poev 8NMmLNYHUx+0x/T9wHMBjDelXfw796WWqGt1R7RfK/H+YDYFbv3BH4+8Q4L2QJY2ZtWF Umiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hg9PqpNJrYe8oFZLuUkVuZ+msE5o9ixg2wC8Z5dgsVY=; b=un8eWf2gtVUTH/LpCN3peOppS+e1/k/JaJS5e8DnF2fz8GzJzeI4yb90uHp4Nl+XE5 EGKdODyAhdRSHIzIFyikaj7nVmM7paLmw22kCBlplFOSNvS5msWsaNeglAC0oOfVWs5g L7W6UyxUO3ZbHGgesmxKE1sDLB27lcP0OZxbj6VMwUaBp0VjLtHcSUAE21s5EiNxzBGq 70LrVBu0dI2cEgkvCa51oKXx0jUukq4zAfTcO41vIIR+0W9M/YOs6SxGqujQKXUonLYN maO5sV8XfzrGqReyQ7Gtc73r8VEp3Dg+D0FnjJS2pXHbgemaqWrNohWzV9gOW77IRlMU /Esg== X-Gm-Message-State: AOAM5319rQSaFmg/xDyFWwsmzKY5JOiMvA0wPaqYc+IJVqlZl0vqFucX AcuEX/Sp4TrefXpLW9/gGYH3wq9Lu1yNZ2l+Frg= X-Google-Smtp-Source: ABdhPJwBEYlFpzFhGOwhnQEPMudNBnbOhtjzSOPWjzBIrCUiJQq0MSdUEr/OBytdQkEbsICxJ4eqg+9azW4tZ7KCPdk= X-Received: by 2002:a1c:3954:: with SMTP id g81mr11872963wma.61.1621431206900; Wed, 19 May 2021 06:33:26 -0700 (PDT) MIME-Version: 1.0 References: <41-60a4c380-5-7d67d100@4304905> In-Reply-To: <41-60a4c380-5-7d67d100@4304905> From: John Kitchin Date: Wed, 19 May 2021 09:33:16 -0400 Message-ID: Subject: Re: Get list of top-level headings To: Florian Lindner Content-Type: multipart/alternative; boundary="0000000000001d7a6105c2aedf26" Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=johnrkitchin@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org Mode List Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621432530; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Hg9PqpNJrYe8oFZLuUkVuZ+msE5o9ixg2wC8Z5dgsVY=; b=FEjQCZzANtG6RLTRgmbrK5vowkjYcUEap7LFlm2FandvRvKSDzX+PoOwUEnQS1QldHRivW 33Ja/IhY06Qh3gAe2Cs07h9SbWpqDqov5FiQ4SkQQgRzmTCew0LgN0oiEsfgtDUdCDatgD 4Hg/1zNtiwOIS/WA54yTmGZL1MTFtxbTkDou4zI26lHWr2BZNchtj/rfSCK/Q9R6R3mS01 sHOvRzovjczvUrgG94BrzYLtm+DPLySdZmk346NXoFMw7XlAvXxYsCqI+PCqL/De+HA6g4 98g+u+LG1e3XENMHizrQm/fpfQ0SdzU/LPUB5RyP41ZeTkSZbAGlI1DwJbysXA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621432530; a=rsa-sha256; cv=none; b=AuRrbWQFx98MxLGZYbYy1FuooumdWNqf5fqw91aVJWEQ3P8tbh53JfFyrpWtGA9itdLePE npdNzAL1Lud6Z42jBnGzR6iwUvqOFdou7ZEDdW0cC738BGL3E9fudcwJerwzKeShbufTfA uBjo3kvDzrgZ9vZh9YcgJc2LsAsvucuaes/CYoDVv6XKt8hbQzctKJNAKIbf2ZbtNhyiwe DunqYv8mSlcng///DizvrE6ghqrGG9kRo2h/1wutxU5YIO1YcBbLCnaEa+X1nnUDaUVI9F r20MpTHIc8XW4dCV7bwqBXi6w8B9b7meQbKYiHaSGmDGQbwvSMKe8ZMqamuNyw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=qo3UIqB1; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.54 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=qo3UIqB1; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 771262CC46 X-Spam-Score: -2.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: vhFAJ48g687x --0000000000001d7a6105c2aedf26 Content-Type: text/plain; charset="UTF-8" I think this is all you need to get a list of titles of level 1 headings as strings (org-map-entries (lambda () (fifth (org-heading-components))) "LEVEL=1") this also works for me: #+BEGIN_SRC emacs-lisp (org-map-entries (lambda () (org-element-property :title (org-element-at-point)) ) "LEVEL=1") #+END_SRC John ----------------------------------- Professor John Kitchin (he/him/his) Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Wed, May 19, 2021 at 3:51 AM Florian Lindner wrote: > Hello, > > I, an Emacs Lisp newbie, want to get a list of all top-level headings of > the current buffer. My approach so far is: > > (defun test-org-map() > (interactive) > (setq headings '()) > (org-map-entries (lambda () > (setq current-header-item (org-element-property > :title (org-element-at-point)) > (message "Header: %s" current-header-item) > (message "Is String: %s" (stringp > (org-element-property :title (org-element-at-point)))) > (setq headings (append current-header-item headings)) > ) > "LEVEL=1" > ) > (dolist (heading headings) > (message "Header Item: %s" heading) > ) > ) > > This gives the otput: > > Header: AAA > Is String: t > Header: BBB > Is String: t > Header Item: 66 [3 times] > Header Item: 65 [3 times] > > so basically the (org-element-property :title (org-element-at-point) does > exactly what I want, but building the list does not what I want. I suppose > that comes from a fundamental misunderstanding of how strings work in elisp. > > I would appreciate a short explanation (or pointers) why this does not > work. And of course, I am very open to completely different, likely better, > approches to that simply problem! > > Thanks, > Florian > --0000000000001d7a6105c2aedf26 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think this is all you need to get a list of titles = of level 1 headings as strings

(org-map-entries (l= ambda () (fifth (org-heading-components))) "LEVEL=3D1")
=

this also works for me:

#+BEGI= N_SRC emacs-lisp
(org-map-entries (lambda () (org-element-property :titl= e (org-element-at-point)) ) "LEVEL=3D1")
#+END_SRC




John

-----------------------------= ------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Depa= rtment of Chemical Engineering
Carnegie Mellon University
Pittsburgh,= PA 15213
412-268-7803


On Wed, May 19, 20= 21 at 3:51 AM Florian Lindner <ma= ilinglists@xgm.de> wrote:
Hello,

I, an Emacs Lisp newbie, want to get a list = of all top-level headings of the current buffer. My approach so far is:
=
(defun test-org-map()
=C2=A0 (interactive)
=C2=A0 (setq headings = '())
=C2=A0 (org-map-entries (lambda ()
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (setq current-header-item (org-element-property :titl= e (org-element-at-point))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (message "Header: %s" current-header-item)
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (message "Is String: %s" (stringp (or= g-element-property :title (org-element-at-point))))
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq headings (append current-header-item head= ings))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )
=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 "LEVEL=3D1"
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 )
=C2=A0 (dolist (heading headings)
=C2=A0=C2=A0=C2=A0 (messag= e "Header Item: %s" heading)
=C2=A0=C2=A0=C2=A0 )
=C2=A0 )<= br>
This gives the otput:

Header: AAA
Is String: t
Header: = BBB
Is String: t
Header Item: 66 [3 times]
Header Item: 65 [3 time= s]

so basically the (org-element-property :title (org-element-at-poi= nt) does exactly what I want, but building the list does not what I want. I= suppose that comes from a fundamental misunderstanding of how strings work= in elisp.

I would appreciate a short explanation (or pointers) why = this does not work. And of course, I am very open to completely different, = likely better, approches to that simply problem!

Thanks,
Florian<= br>=C2=A0
--0000000000001d7a6105c2aedf26--